summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-15 16:07:02 (UTC)
committer zautrix <zautrix>2005-06-15 16:07:02 (UTC)
commit2a788f41ebeb7d8edab7010fb1a00799cb9e036d (patch) (unidiff)
tree0d8f635abc48d64add3131f8b5891ee70a877802
parent40fa3e374fd96c0cb8925a1c3c46d40e1ea2b111 (diff)
downloadkdepimpi-2a788f41ebeb7d8edab7010fb1a00799cb9e036d.zip
kdepimpi-2a788f41ebeb7d8edab7010fb1a00799cb9e036d.tar.gz
kdepimpi-2a788f41ebeb7d8edab7010fb1a00799cb9e036d.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 2150654..475bb4a 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1157 +1,1172 @@
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} 145}
146 146
147QString KNoScrollListBox::getWhatsThisText(QPoint p) 147QString KNoScrollListBox::getWhatsThisText(QPoint p)
148{ 148{
149 QListBoxItem* item = itemAt ( p ); 149 QListBoxItem* item = itemAt ( p );
150 if ( ! item ) { 150 if ( ! item ) {
151 return i18n("Click in the cell\nto add an event!"); 151 return i18n("Click in the cell\nto add an event!");
152 } 152 }
153 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 153 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
154 KOPrefs::instance()->mWTshowDetails, 154 KOPrefs::instance()->mWTshowDetails,
155 KOPrefs::instance()->mWTshowCreated, 155 KOPrefs::instance()->mWTshowCreated,
156 KOPrefs::instance()->mWTshowChanged); 156 KOPrefs::instance()->mWTshowChanged);
157} 157}
158void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 158void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
159{ 159{
160 //qDebug("KNoScrollListBox::keyPressEvent "); 160 //qDebug("KNoScrollListBox::keyPressEvent ");
161 switch(e->key()) { 161 switch(e->key()) {
162 case Key_Right: 162 case Key_Right:
163 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 163 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
164 { 164 {
165 e->ignore(); 165 e->ignore();
166 return; 166 return;
167 } 167 }
168 scrollBy(10,0); 168 scrollBy(10,0);
169 break; 169 break;
170 case Key_Left: 170 case Key_Left:
171 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 171 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
172 { 172 {
173 e->ignore(); 173 e->ignore();
174 return; 174 return;
175 } 175 }
176 scrollBy(-10,0); 176 scrollBy(-10,0);
177 break; 177 break;
178 case Key_Up: 178 case Key_Up:
179 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 179 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
180 e->ignore(); 180 e->ignore();
181 break; 181 break;
182 } 182 }
183 if ( count() ) { 183 if ( count() ) {
184 if ( currentItem() == 0 ) { 184 if ( currentItem() == 0 ) {
185 emit prevCell(); 185 emit prevCell();
186 } else { 186 } else {
187 setCurrentItem((currentItem()+count()-1)%count()); 187 setCurrentItem((currentItem()+count()-1)%count());
188 if(!itemVisible(currentItem())) { 188 if(!itemVisible(currentItem())) {
189 if((unsigned int) currentItem() == (count()-1)) { 189 if((unsigned int) currentItem() == (count()-1)) {
190 setTopItem(currentItem()-numItemsVisible()+1); 190 setTopItem(currentItem()-numItemsVisible()+1);
191 } else { 191 } else {
192 setTopItem(topItem()-1); 192 setTopItem(topItem()-1);
193 } 193 }
194 } 194 }
195 } 195 }
196 } 196 }
197 break; 197 break;
198 case Key_Down: 198 case Key_Down:
199 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 199 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
200 e->ignore(); 200 e->ignore();
201 break; 201 break;
202 } 202 }
203 if ( count () ) { 203 if ( count () ) {
204 if ( currentItem()+1 == count () ) { 204 if ( currentItem()+1 == count () ) {
205 emit nextCell(); 205 emit nextCell();
206 } else { 206 } else {
207 setCurrentItem((currentItem()+1)%count()); 207 setCurrentItem((currentItem()+1)%count());
208 if(!itemVisible(currentItem())) { 208 if(!itemVisible(currentItem())) {
209 if(currentItem() == 0) { 209 if(currentItem() == 0) {
210 setTopItem(0); 210 setTopItem(0);
211 } else { 211 } else {
212 setTopItem(topItem()+1); 212 setTopItem(topItem()+1);
213 } 213 }
214 } 214 }
215 } 215 }
216 } 216 }
217 break; 217 break;
218 case Key_I: 218 case Key_I:
219 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 219 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
220 e->ignore(); 220 e->ignore();
221 break; 221 break;
222 case Key_Return: 222 case Key_Return:
223 case Key_Enter: 223 case Key_Enter:
224 { 224 {
225 if ( currentItem() >= 0 ) { 225 if ( currentItem() >= 0 ) {
226 emit doubleClicked( item( currentItem() ) ); 226 emit doubleClicked( item( currentItem() ) );
227 e->accept(); 227 e->accept();
228 } else { 228 } else {
229 e->ignore(); 229 e->ignore();
230 } 230 }
231 } 231 }
232 break; 232 break;
233 case Key_Shift: 233 case Key_Shift:
234 emit shiftDown(); 234 emit shiftDown();
235 break; 235 break;
236 default: 236 default:
237 e->ignore(); 237 e->ignore();
238 break; 238 break;
239 } 239 }
240} 240}
241 241
242void KNoScrollListBox::oneDown() 242void KNoScrollListBox::oneDown()
243{ 243{
244 if ( count () ) { 244 if ( count () ) {
245 if ( currentItem()+1 == count () ) { 245 if ( currentItem()+1 == count () ) {
246 emit nextCell(); 246 emit nextCell();
247 } else { 247 } else {
248 resetOnFocusIn = false; 248 resetOnFocusIn = false;
249 setCurrentItem((currentItem()+1)%count()); 249 setCurrentItem((currentItem()+1)%count());
250 if(!itemVisible(currentItem())) { 250 if(!itemVisible(currentItem())) {
251 if(currentItem() == 0) { 251 if(currentItem() == 0) {
252 setTopItem(0); 252 setTopItem(0);
253 } else { 253 } else {
254 setTopItem(topItem()+1); 254 setTopItem(topItem()+1);
255 } 255 }
256 } 256 }
257 } 257 }
258 } 258 }
259} 259}
260void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 260void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
261{ 261{
262 switch(e->key()) { 262 switch(e->key()) {
263 case Key_Shift: 263 case Key_Shift:
264 emit shiftUp(); 264 emit shiftUp();
265 break; 265 break;
266 default: 266 default:
267 break; 267 break;
268 } 268 }
269} 269}
270 270
271void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 271void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
272{ 272{
273 QListBox::mousePressEvent(e); 273 QListBox::mousePressEvent(e);
274 274
275 if(e->button() == RightButton) { 275 if(e->button() == RightButton) {
276 emit rightClick(); 276 emit rightClick();
277 } 277 }
278} 278}
279 279
280MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 280MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
281 : QListBoxItem() 281 : QListBoxItem()
282{ 282{
283 mblockRepaint = true; 283 mblockRepaint = true;
284 setText( s ); 284 setText( s );
285 mMultiday = 0; 285 mMultiday = 0;
286 mIncidence = incidence; 286 mIncidence = incidence;
287 mDate = qd; 287 mDate = qd;
288 mRecur = false; 288 mRecur = false;
289 mAlarm = false; 289 mAlarm = false;
290 mReply = false; 290 mReply = false;
291 mInfo = false; 291 mInfo = false;
292 mdayPos = 0; 292 mdayPos = 0;
293 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 293 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
294} 294}
295void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 295void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
296{ 296{
297 setText( s ); 297 setText( s );
298 mMultiday = 0; 298 mMultiday = 0;
299 mIncidence = incidence; 299 mIncidence = incidence;
300 mDate = qd; 300 mDate = qd;
301 mRecur = false; 301 mRecur = false;
302 mAlarm = false; 302 mAlarm = false;
303 mReply = false; 303 mReply = false;
304 mInfo = false; 304 mInfo = false;
305 mdayPos = 0; 305 mdayPos = 0;
306} 306}
307 307
308void MonthViewItem::paint(QPainter *p) 308void MonthViewItem::paint(QPainter *p)
309{ 309{
310 if ( mblockRepaint ) { 310 if ( mblockRepaint ) {
311 return; 311 return;
312 } 312 }
313#if QT_VERSION >= 0x030000 313#if QT_VERSION >= 0x030000
314 bool sel = isSelected(); 314 bool sel = isSelected();
315#else 315#else
316 bool sel = selected(); 316 bool sel = selected();
317#endif 317#endif
318 318
319 319
320 int heihei = height( listBox () );
321 int x = 1;
320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 322 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
321 { 323 {
322 p->setBackgroundColor( palette().color( QPalette::Normal, \ 324 p->setBackgroundColor( palette().color( QPalette::Normal, \
323 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 325 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 326 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei );
325 } 327 }
326 int x = 1; 328
327 //int y = 3;//(height() - mRecurPixmap.height()) /2; 329 //int y = 3;//(height() - mRecurPixmap.height()) /2;
328 int size = PIXMAP_SIZE; 330 int size = PIXMAP_SIZE;
329 if ( QApplication::desktop()->width() < 300 ) 331 if ( QApplication::desktop()->width() < 300 )
330 size = 3; 332 size = 3;
331 int heihei = height( listBox () );
332 int y = (heihei - size -1 ) /2; 333 int y = (heihei - size -1 ) /2;
333 334
335 if ( mIncidence->calID() > 1 ) {
336 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
337 p->drawRect ( x, y-2,size,size+4);
338 x += size + 1;
339 }
340
334 if ( KOPrefs::instance()->mMonthShowIcons ) { 341 if ( KOPrefs::instance()->mMonthShowIcons ) {
335 if ( mInfo ) { 342 if ( mInfo ) {
336 p->fillRect ( x, y,size,size, Qt::darkGreen ); 343 p->fillRect ( x, y,size,size, Qt::darkGreen );
337 x += size + 1; 344 x += size + 1;
338 } 345 }
339 if ( mRecur ) { 346 if ( mRecur ) {
340 p->fillRect ( x, y,size,size, Qt::blue ); 347 p->fillRect ( x, y,size,size, Qt::blue );
341 x += size + 1; 348 x += size + 1;
342 } 349 }
343 if ( mAlarm ) { 350 if ( mAlarm ) {
344 p->fillRect ( x, y,size,size, Qt::red ); 351 p->fillRect ( x, y,size,size, Qt::red );
345 x += size + 1; 352 x += size + 1;
346 } 353 }
347 if ( mReply ) { 354 if ( mReply ) {
348 p->fillRect ( x, y,size,size, Qt::yellow ); 355 p->fillRect ( x, y,size,size, Qt::yellow );
349 x += size + 1; 356 x += size + 1;
350 } 357 }
351 } 358 }
352 if ( mMultiday ) { 359 if ( mMultiday ) {
353 int yyy = y+(size/2); 360 int yyy = y+(size/2);
354 int sizeM = size+2; 361 int sizeM = size+2;
355 p->setBrush( QBrush::SolidPattern ); 362 p->setBrush( QBrush::SolidPattern );
356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 363 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
357 if ( mMultiday == 2 || mMultiday == 3 ) { 364 if ( mMultiday == 2 || mMultiday == 3 ) {
358 QPointArray pa ( 3 ); 365 QPointArray pa ( 3 );
359 pa.setPoint (0, x, yyy ); 366 pa.setPoint (0, x, yyy );
360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 367 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
361 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 368 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
362 p->drawPolygon( pa ); 369 p->drawPolygon( pa );
363 } 370 }
364 if ( mMultiday == 2 || mMultiday == 1 ) { 371 if ( mMultiday == 2 || mMultiday == 1 ) {
365 QPointArray pa ( 3 ); 372 QPointArray pa ( 3 );
366 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 373 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
367 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 374 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
368 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 375 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
369 p->drawPolygon( pa ); 376 p->drawPolygon( pa );
370 } 377 }
371 if ( mMultiday == 1 ) { 378 if ( mMultiday == 1 ) {
372 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 379 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
373 380
374 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 381 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
375 } 382 }
376 if ( mMultiday == 3 ) { 383 if ( mMultiday == 3 ) {
377 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 384 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
378 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 385 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
379 386
380 } 387 }
381 x += sizeM/2 + 1; 388 x += sizeM/2 + 1;
382 x += sizeM + 1; 389 x += sizeM + 1;
383 } 390 }
384 391
385 if ( mIncidence->typeID() == todoID ){ 392 if ( mIncidence->typeID() == todoID ){
386 Todo* td = ( Todo* ) mIncidence; 393 Todo* td = ( Todo* ) mIncidence;
387 if ( td->isCompleted() ) { 394 if ( td->isCompleted() ) {
388 int half = size/2; 395 int half = size/2;
389 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 396 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
390 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 397 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
391 x += half+half + 4; 398 x += half+half + 4;
392 399
393 } else { 400 } else {
394 int val = td->percentComplete()/20; 401 int val = td->percentComplete()/20;
395 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 402 p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
396 p->drawRect ( x, y-2,7,size+4); 403 p->drawRect ( x, y-2,7,size+4);
397 x += size + 3; 404 x += size + 3;
398 } 405 }
399 } 406 }
400 QFontMetrics fm = p->fontMetrics(); 407 QFontMetrics fm = p->fontMetrics();
401 int yPos; 408 int yPos;
402 int pmheight = size; 409 int pmheight = size;
403 if( pmheight < fm.height() ) 410 if( pmheight < fm.height() )
404 yPos = fm.ascent() + fm.leading()/2; 411 yPos = fm.ascent() + fm.leading()/2;
405 else 412 else
406 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 413 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
407 p->setPen( palette().color( QPalette::Normal, sel ? \ 414 p->setPen( palette().color( QPalette::Normal, sel ? \
408 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 415 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
409 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 416 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
410 p->drawText( x, yPos, text() ); 417 p->drawText( x, yPos, text() );
411 if ( mIncidence->cancelled() ) { 418 if ( mIncidence->cancelled() ) {
412 int wid = fm.width( text() ); 419 int wid = fm.width( text() );
413 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 420 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
414 } 421 }
415 } else { 422 } else {
416 QString pText = text(); 423 QString pText = text();
417 if( pText.mid(2,1) == ":" ) 424 if( pText.mid(2,1) == ":" )
418 pText = pText.mid( 6 ); 425 pText = pText.mid( 6 );
419 p->drawText( x, yPos, pText ); 426 p->drawText( x, yPos, pText );
420 if ( mIncidence->cancelled() ) { 427 if ( mIncidence->cancelled() ) {
421 int wid = fm.width( pText ); 428 int wid = fm.width( pText );
422 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 429 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
423 } 430 }
424 } 431 }
425} 432}
426 433
427int MonthViewItem::height(const QListBox *lb) const 434int MonthViewItem::height(const QListBox *lb) const
428{ 435{
429 int ret = 10; 436 int ret = 10;
430 if ( lb ) 437 if ( lb )
431 ret = lb->fontMetrics().lineSpacing()+1; 438 ret = lb->fontMetrics().lineSpacing()+1;
432 return ret; 439 return ret;
433} 440}
434 441
435int MonthViewItem::width(const QListBox *lb) const 442int MonthViewItem::width(const QListBox *lb) const
436{ 443{
437 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 444 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
438 int size = PIXMAP_SIZE; 445 int size = PIXMAP_SIZE;
439 if ( QApplication::desktop()->width() < 300 ) 446 if ( QApplication::desktop()->width() < 300 )
440 size = 3; 447 size = 3;
441 int x = 1; 448 int x = 1;
442 if ( KOPrefs::instance()->mMonthShowIcons ) { 449 if ( KOPrefs::instance()->mMonthShowIcons ) {
443 if ( mInfo ) { 450 if ( mInfo ) {
444 x += size + 1; 451 x += size + 1;
445 } 452 }
446 if( mRecur ) { 453 if( mRecur ) {
447 x += size+1; 454 x += size+1;
448 } 455 }
449 if( mAlarm ) { 456 if( mAlarm ) {
450 x += size+1; 457 x += size+1;
451 } 458 }
452 if( mReply ) { 459 if( mReply ) {
453 x += size+1; 460 x += size+1;
454 } 461 }
455 } 462 }
456 if( mMultiday ) { 463 if( mMultiday ) {
457 x += size+1+2+size/2; 464 x += size+1+2+size/2;
458 } 465 }
459 return( x + lb->fontMetrics().width( text() ) + 1 ); 466 return( x + lb->fontMetrics().width( text() ) + 1 );
460 } 467 }
461 if ( ! lb ) 468 if ( ! lb )
462 return 10; 469 return 10;
463 return lb->width(); 470 return lb->width();
464} 471}
465 472
466 473
467MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 474MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
468 : KNoScrollListBox( par ), 475 : KNoScrollListBox( par ),
469 mMonthView( parent ) 476 mMonthView( parent )
470{ 477{
471 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 478 //QVBoxLayout *topLayout = new QVBoxLayout( this );
472 currentPalette = 0; 479 currentPalette = 0;
473 // mLabel = new QLabel( this );QPushButton 480 // mLabel = new QLabel( this );QPushButton
474 mLabel = new QPushButton( this ); 481 mLabel = new QPushButton( this );
475 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 482 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
476 //mLabel->setLineWidth( 1 ); 483 //mLabel->setLineWidth( 1 );
477 //mLabel->setAlignment( AlignCenter ); 484 //mLabel->setAlignment( AlignCenter );
478 mLabel->setFlat( true ); 485 mLabel->setFlat( true );
479 mLabel->setFocusPolicy(NoFocus); 486 mLabel->setFocusPolicy(NoFocus);
480 //mItemList = new KNoScrollListBox( this ); 487 //mItemList = new KNoScrollListBox( this );
481 setMinimumSize( 10, 10 ); 488 setMinimumSize( 10, 10 );
482 setFrameStyle( QFrame::Panel | QFrame::Plain ); 489 setFrameStyle( QFrame::Panel | QFrame::Plain );
483 setLineWidth( 1 ); 490 setLineWidth( 1 );
484 //topLayout->addWidget( mItemList ); 491 //topLayout->addWidget( mItemList );
485 mLabel->raise(); 492 mLabel->raise();
486 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 493 // QColor( 0,0,255 ) QColor( 160,1600,255 )
487 mStandardPalette = palette(); 494 mStandardPalette = palette();
488 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 495 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
489 496
490 enableScrollBars( false ); 497 enableScrollBars( false );
491 updateConfig(); 498 updateConfig();
492 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 499 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
493 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 500 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
494 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 501 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
495 SLOT( defaultAction( QListBoxItem * ) ) ); 502 SLOT( defaultAction( QListBoxItem * ) ) );
496 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 503 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
497 const QPoint &) ), 504 const QPoint &) ),
498 SLOT( contextMenu( QListBoxItem * ) ) ); 505 SLOT( contextMenu( QListBoxItem * ) ) );
499 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 506 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
500 SLOT( selection( QListBoxItem * ) ) ); 507 SLOT( selection( QListBoxItem * ) ) );
501 508
502 /* 509 /*
503 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 510 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
504 SLOT( selection( QListBoxItem * ) ) ); 511 SLOT( selection( QListBoxItem * ) ) );
505 */ 512 */
506} 513}
507#ifdef DESKTOP_VERSION 514#ifdef DESKTOP_VERSION
508QToolTipGroup *MonthViewCell::toolTipGroup() 515QToolTipGroup *MonthViewCell::toolTipGroup()
509{ 516{
510 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 517 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
511 return mToolTipGroup; 518 return mToolTipGroup;
512} 519}
513#endif 520#endif
514 521
515void MonthViewCell::setDate( const QDate &date ) 522void MonthViewCell::setDate( const QDate &date )
516{ 523{
517 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 524 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
518 mDate = date; 525 mDate = date;
519 526
520 527
521 528
522 //resizeEvent( 0 ); 529 //resizeEvent( 0 );
523} 530}
524 531
525QDate MonthViewCell::date() const 532QDate MonthViewCell::date() const
526{ 533{
527 return mDate; 534 return mDate;
528} 535}
529 536
530void MonthViewCell::setPrimary( bool primary ) 537void MonthViewCell::setPrimary( bool primary )
531{ 538{
532 mPrimary = primary; 539 mPrimary = primary;
533 //setMyPalette(); 540 //setMyPalette();
534} 541}
535void MonthViewCell::setMyPalette() 542void MonthViewCell::setMyPalette()
536{ 543{
537 544
538 if ( mHoliday) { 545 if ( mHoliday) {
539 if ( currentPalette == 1 ) return; 546 if ( currentPalette == 1 ) return;
540 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 547 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
541 setPalette( mHolidayPalette ); 548 setPalette( mHolidayPalette );
542 //mLabel->setPalette( mHolidayPalette ); 549 //mLabel->setPalette( mHolidayPalette );
543 currentPalette = 1; 550 currentPalette = 1;
544 551
545 } else { 552 } else {
546 if ( mPrimary ) { 553 if ( mPrimary ) {
547 if ( currentPalette == 2 ) return; 554 if ( currentPalette == 2 ) return;
548 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 555 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
549 //mLabel->setPalette( mPrimaryPalette ); 556 //mLabel->setPalette( mPrimaryPalette );
550 setPalette( mPrimaryPalette ); 557 setPalette( mPrimaryPalette );
551 currentPalette = 2; 558 currentPalette = 2;
552 559
553 } else { 560 } else {
554 if ( currentPalette == 3 ) return; 561 if ( currentPalette == 3 ) return;
555 setPalette( mNonPrimaryPalette ); 562 setPalette( mNonPrimaryPalette );
556 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 563 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
557 //mLabel->setPalette( mNonPrimaryPalette );; 564 //mLabel->setPalette( mNonPrimaryPalette );;
558 currentPalette = 3; 565 currentPalette = 3;
559 } 566 }
560 } 567 }
561 //QPalette pal = palette(); 568 //QPalette pal = palette();
562 569
563 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 570 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
564} 571}
565QPalette MonthViewCell::getPalette () 572QPalette MonthViewCell::getPalette ()
566{ 573{
567 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 574 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
568 return mStandardPalette; 575 return mStandardPalette;
569 if ( mHoliday) { 576 if ( mHoliday) {
570 return mHolidayPalette ; 577 return mHolidayPalette ;
571 } else { 578 } else {
572 if ( mPrimary ) { 579 if ( mPrimary ) {
573 return mPrimaryPalette ; 580 return mPrimaryPalette ;
574 } 581 }
575 } 582 }
576 return mNonPrimaryPalette; 583 return mNonPrimaryPalette;
577} 584}
578bool MonthViewCell::isPrimary() const 585bool MonthViewCell::isPrimary() const
579{ 586{
580 return mPrimary; 587 return mPrimary;
581} 588}
582 589
583void MonthViewCell::setHoliday( bool holiday ) 590void MonthViewCell::setHoliday( bool holiday )
584{ 591{
585 mHoliday = holiday; 592 mHoliday = holiday;
586 //setMyPalette(); 593 //setMyPalette();
587} 594}
588 595
589void MonthViewCell::setHoliday( const QString &holiday ) 596void MonthViewCell::setHoliday( const QString &holiday )
590{ 597{
591 mHolidayString = holiday; 598 mHolidayString = holiday;
592 599
593 if ( !holiday.isEmpty() ) { 600 if ( !holiday.isEmpty() ) {
594 setHoliday( true ); 601 setHoliday( true );
595 } 602 }
596} 603}
597 604
598void MonthViewCell::startUpdateCell() 605void MonthViewCell::startUpdateCell()
599{ 606{
600 mdayCount = 0; 607 mdayCount = 0;
601 setFocusPolicy(NoFocus); 608 setFocusPolicy(NoFocus);
602 if ( !mMonthView->isUpdatePossible() ) 609 if ( !mMonthView->isUpdatePossible() )
603 return; 610 return;
604 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 611 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
605 while ( mitem ) { 612 while ( mitem ) {
606 mitem->setBlockRepaint( true ); 613 mitem->setBlockRepaint( true );
607 mitem = (MonthViewItem *)mitem->next(); 614 mitem = (MonthViewItem *)mitem->next();
608 } 615 }
609 if ( mAvailItemList.count() > 20 ) { 616 if ( mAvailItemList.count() > 20 ) {
610 mAvailItemList.setAutoDelete( true ); 617 mAvailItemList.setAutoDelete( true );
611 mAvailItemList.clear(); 618 mAvailItemList.clear();
612 mAvailItemList.setAutoDelete( false ); 619 mAvailItemList.setAutoDelete( false );
620 clear();
613 } 621 }
614 622
615 setPrimary( mDate.month()%2 ); 623 setPrimary( mDate.month()%2 );
616 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 624 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
617 if ( mDate == QDate::currentDate() ) { 625 if ( mDate == QDate::currentDate() ) {
618 setLineWidth( 3 ); 626 setLineWidth( 3 );
619 } else { 627 } else {
620 setLineWidth( 1 ); 628 setLineWidth( 1 );
621 } 629 }
622 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 630 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
623 //clear(); 631 //clear();
624 while ( CurrentAvailItem ) { 632 while ( CurrentAvailItem ) {
625 MonthViewItem *item = CurrentAvailItem; 633 MonthViewItem *item = CurrentAvailItem;
626 CurrentAvailItem = (MonthViewItem *)item->next(); 634 CurrentAvailItem = (MonthViewItem *)item->next();
627 mAvailItemList.append( item ); 635 mAvailItemList.append( item );
628 takeItem ( item ); 636 takeItem ( item );
629 } 637 }
630 638
631#ifdef DESKTOP_VERSION 639#ifdef DESKTOP_VERSION
632 QToolTip::remove(this); 640 QToolTip::remove(this);
633#endif 641#endif
634 mToolTip.clear(); 642 mToolTip.clear();
635 //qApp->processEvents(); 643 //qApp->processEvents();
636#if 0 644#if 0
637 if ( !mHolidayString.isEmpty() ) { 645 if ( !mHolidayString.isEmpty() ) {
638 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 646 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
639 item->setPalette( mHolidayPalette ); 647 item->setPalette( mHolidayPalette );
640 insertItem( item ); 648 insertItem( item );
641 mToolTip.append ( mHolidayString ); 649 mToolTip.append ( mHolidayString );
642 } 650 }
643#endif 651#endif
644} 652}
645 653
646int MonthViewCell::insertEvent(Event *event) 654int MonthViewCell::insertEvent(Event *event)
647{ 655{
648 bool useToolTips = true; 656 bool useToolTips = true;
649#ifndef DESKTOP_VERSION 657#ifndef DESKTOP_VERSION
650 useToolTips = false; 658 useToolTips = false;
651#endif 659#endif
652 QString mToolTipText; 660 QString mToolTipText;
653 setFocusPolicy(WheelFocus); 661 setFocusPolicy(WheelFocus);
654 if ( !(event->doesRecur() == Recurrence::rNone) ) { 662 if ( !(event->doesRecur() == Recurrence::rNone) ) {
655 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 663 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
656 return mdayCount; 664 return mdayCount;
657 else 665 else
658 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 666 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
659 return mdayCount; 667 return mdayCount;
660 } 668 }
661 669
662 if ( event->isHoliday()) { 670 if ( event->isHoliday()) {
663 setHoliday( true ); 671 setHoliday( true );
664 if ( mDate.dayOfWeek() == 7 ) 672 if ( mDate.dayOfWeek() == 7 )
665 setLineWidth( 3 ); 673 setLineWidth( 3 );
666 } 674 }
667 QString text; 675 QString text;
668 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 676 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
669 if (event->isMultiDay()) { 677 if (event->isMultiDay()) {
670 QString prefix = "<->";multiday = 2; 678 QString prefix = "<->";multiday = 2;
671 QString time; 679 QString time;
672 if ( event->doesRecur() ) { 680 if ( event->doesRecur() ) {
673 if ( event->recursOn( mDate) ) { 681 if ( event->recursOn( mDate) ) {
674 prefix ="->" ;multiday = 1; 682 prefix ="->" ;multiday = 1;
675 } 683 }
676 else { 684 else {
677 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 685 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
678 if ( event->recursOn( mDate.addDays( -days)) ) { 686 if ( event->recursOn( mDate.addDays( -days)) ) {
679 prefix ="<-" ;multiday = 3; 687 prefix ="<-" ;multiday = 3;
680 } 688 }
681 } 689 }
682 690
683 } else { 691 } else {
684 if (mDate == event->dtStart().date()) { 692 if (mDate == event->dtStart().date()) {
685 prefix ="->" ;multiday = 1; 693 prefix ="->" ;multiday = 1;
686 } else if (mDate == event->dtEnd().date()) { 694 } else if (mDate == event->dtEnd().date()) {
687 prefix ="<-" ;multiday = 3; 695 prefix ="<-" ;multiday = 3;
688 } 696 }
689 } 697 }
690 if ( !event->doesFloat() ) { 698 if ( !event->doesFloat() ) {
691 if ( mDate == event->dtStart().date () ) 699 if ( mDate == event->dtStart().date () )
692 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 700 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
693 else if ( mDate == event->dtEnd().date () ) 701 else if ( mDate == event->dtEnd().date () )
694 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 702 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
695 703
696 } 704 }
697 text = time + event->summary(); 705 text = time + event->summary();
698 if ( useToolTips ) 706 if ( useToolTips )
699 mToolTipText += prefix + text; 707 mToolTipText += prefix + text;
700 } else { 708 } else {
701 if (event->doesFloat()) { 709 if (event->doesFloat()) {
702 text = event->summary(); 710 text = event->summary();
703 if ( useToolTips ) 711 if ( useToolTips )
704 mToolTipText += text; 712 mToolTipText += text;
705 } 713 }
706 else { 714 else {
707 text = KGlobal::locale()->formatTime(event->dtStart().time()); 715 text = KGlobal::locale()->formatTime(event->dtStart().time());
708 text += " " + event->summary(); 716 text += " " + event->summary();
709 if ( useToolTips ) 717 if ( useToolTips )
710 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 718 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
711 } 719 }
712 } 720 }
713 if ( useToolTips && ! event->location().isEmpty() ) { 721 if ( useToolTips && ! event->location().isEmpty() ) {
714 mToolTipText += " (" + event->location() +")"; 722 mToolTipText += " (" + event->location() +")";
715 } 723 }
716 MonthViewItem *item ; 724 MonthViewItem *item ;
717 725
718 if ( mAvailItemList.count() ) { 726 if ( mAvailItemList.count() ) {
719 item = mAvailItemList.first(); 727 item = mAvailItemList.first();
720 mAvailItemList.remove( item ); 728 mAvailItemList.remove( item );
721 item->recycle( event, mDate, text ); 729 item->recycle( event, mDate, text );
722 } else { 730 } else {
723 item = new MonthViewItem( event, mDate, text ); 731 item = new MonthViewItem( event, mDate, text );
724 } 732 }
725 733
726 QPalette pal; 734 QPalette pal;
727 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 735 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
728 QStringList categories = event->categories(); 736 QStringList categories = event->categories();
729 QString cat = categories.first(); 737 QString cat = categories.first();
730 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 738 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
731 pal = getPalette(); 739 pal = getPalette();
732 if (cat.isEmpty()) { 740 if (cat.isEmpty()) {
733 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 741 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
734 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); 742 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() ));
735 } else { 743 } else {
736 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 744 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
737 } 745 }
738 746
739 } else { 747 } else {
740 if (cat.isEmpty()) { 748 if (cat.isEmpty()) {
741 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 749 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
742 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); 750 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() ));
743 } else { 751 } else {
744 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 752 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
745 } 753 }
746 } 754 }
747 755
748 } else { 756 } else {
749 pal = mStandardPalette ; 757 pal = mStandardPalette ;
750 } 758 }
751 item->setPalette( pal ); 759 item->setPalette( pal );
752 item->setRecur( event->recurrence()->doesRecur() ); 760 item->setRecur( event->recurrence()->doesRecur() );
753 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); 761 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() );
754 item->setMoreInfo( event->description().length() > 0 ); 762 item->setMoreInfo( event->description().length() > 0 );
755#ifdef DESKTOP_VERSION 763#ifdef DESKTOP_VERSION
756 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 764 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
757 KOPrefs::instance()->email()); 765 KOPrefs::instance()->email());
758 if ( me != 0 ) { 766 if ( me != 0 ) {
759 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 767 if ( me->status() == Attendee::NeedsAction && me->RSVP())
760 item->setReply(true && multiday < 2); 768 item->setReply(true && multiday < 2);
761 else 769 else
762 item->setReply(false); 770 item->setReply(false);
763 } else 771 } else
764 item->setReply(false); 772 item->setReply(false);
765#endif 773#endif
774
766 item->setMultiDay( multiday ); 775 item->setMultiDay( multiday );
767 if ( multiday ) { 776 if ( multiday ) {
768 insertItem( item ,mdayCount); 777 insertItem( item ,mdayCount);
769 ++mdayCount; 778 ++mdayCount;
770 } else { 779 } else {
771 uint i; 780 uint i = mdayCount;
772 int pos = mdayCount; 781 uint pos = mdayCount;
773 for ( i = mdayCount; i < count();++i ) { 782 uint itcount = count();
783 if ( itcount > 1000 ) {
784 qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount);
785 itcount = 0;
786 }
787 for ( i = pos; i < itcount;++i ) {
788 // qDebug("i %d mday %u count %d ",i,itcount,mdayCount );
774 QListBoxItem* it = this->item ( i ); 789 QListBoxItem* it = this->item ( i );
775 if ( it && text < it->text() ) { 790 if ( it && text < it->text() ) {
776 pos = i; 791 pos = i;
777 break; 792 break;
778 } 793 }
779 ++pos; 794 ++pos;
780 } 795 }
781 insertItem( item ,pos); 796 insertItem( item ,pos);
782 } 797 }
783 if ( useToolTips ) { 798 if ( useToolTips ) {
784 mToolTip.append( mToolTipText ); 799 mToolTip.append( mToolTipText );
785 } 800 }
786 return mdayCount; 801 return mdayCount;
787} 802}
788void MonthViewCell::insertTodo(Todo *todo) 803void MonthViewCell::insertTodo(Todo *todo)
789{ 804{
790 setFocusPolicy(WheelFocus); 805 setFocusPolicy(WheelFocus);
791 QString text; 806 QString text;
792 if (todo->hasDueDate()) { 807 if (todo->hasDueDate()) {
793 if (!todo->doesFloat()) { 808 if (!todo->doesFloat()) {
794 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 809 text += KGlobal::locale()->formatTime(todo->dtDue().time());
795 text += " "; 810 text += " ";
796 } 811 }
797 } 812 }
798 text += todo->summary(); 813 text += todo->summary();
799 MonthViewItem *item ; 814 MonthViewItem *item ;
800 if ( mAvailItemList.count() ) { 815 if ( mAvailItemList.count() ) {
801 item = mAvailItemList.first(); 816 item = mAvailItemList.first();
802 mAvailItemList.remove( item ); 817 mAvailItemList.remove( item );
803 item->recycle( todo, mDate, text ); 818 item->recycle( todo, mDate, text );
804 } else { 819 } else {
805 item = new MonthViewItem( todo, mDate, text ); 820 item = new MonthViewItem( todo, mDate, text );
806 } 821 }
807 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 822 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
808 //item->setPalette( mStandardPalette ); 823 //item->setPalette( mStandardPalette );
809 QPalette pal; 824 QPalette pal;
810 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 825 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
811 QStringList categories = todo->categories(); 826 QStringList categories = todo->categories();
812 QString cat = categories.first(); 827 QString cat = categories.first();
813 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 828 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
814 pal = getPalette(); 829 pal = getPalette();
815 if (cat.isEmpty()) { 830 if (cat.isEmpty()) {
816 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 831 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
817 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); 832 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() ));
818 } else { 833 } else {
819 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 834 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
820 } 835 }
821 836
822 } else { 837 } else {
823 if (cat.isEmpty()) { 838 if (cat.isEmpty()) {
824 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 839 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
825 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); 840 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() ));
826 } else { 841 } else {
827 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 842 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
828 } 843 }
829 } 844 }
830 845
831 } else { 846 } else {
832 pal = mStandardPalette ; 847 pal = mStandardPalette ;
833 } 848 }
834 item->setPalette( pal ); 849 item->setPalette( pal );
835 item->setRecur( todo->recurrence()->doesRecur() ); 850 item->setRecur( todo->recurrence()->doesRecur() );
836 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); 851 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() );
837 item->setMoreInfo( todo->description().length() > 0 ); 852 item->setMoreInfo( todo->description().length() > 0 );
838 insertItem( item , count()); 853 insertItem( item , count());
839#ifdef DESKTOP_VERSION 854#ifdef DESKTOP_VERSION
840 mToolTip.append( text ); 855 mToolTip.append( text );
841#endif 856#endif
842} 857}
843void MonthViewCell::repaintfinishUpdateCell() 858void MonthViewCell::repaintfinishUpdateCell()
844{ 859{
845 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 860 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
846 while ( mitem ) { 861 while ( mitem ) {
847 mitem->setBlockRepaint( false ); 862 mitem->setBlockRepaint( false );
848 updateItem ( mitem ); 863 updateItem ( mitem );
849 mitem = (MonthViewItem *)mitem->next(); 864 mitem = (MonthViewItem *)mitem->next();
850 } 865 }
851} 866}
852void MonthViewCell::finishUpdateCell() 867void MonthViewCell::finishUpdateCell()
853{ 868{
854 869
855 870
856 871
857#ifdef DESKTOP_VERSION 872#ifdef DESKTOP_VERSION
858 if (mToolTip.count() > 0 ) { 873 if (mToolTip.count() > 0 ) {
859 mToolTip.sort(); 874 mToolTip.sort();
860 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 875 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
861 } 876 }
862#endif 877#endif
863 //sort(); 878 //sort();
864 //setMyPalette(); 879 //setMyPalette();
865 setMyPalette(); 880 setMyPalette();
866 881
867 resizeEvent( 0 ); 882 resizeEvent( 0 );
868 883
869} 884}
870void MonthViewCell::updateCell() 885void MonthViewCell::updateCell()
871{ 886{
872 if ( !mMonthView->isUpdatePossible() ) 887 if ( !mMonthView->isUpdatePossible() )
873 return; 888 return;
874 startUpdateCell(); 889 startUpdateCell();
875 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 890 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
876 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 891 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
877 Event *event; 892 Event *event;
878 for( event = events.first(); event; event = events.next() ) { // for event 893 for( event = events.first(); event; event = events.next() ) { // for event
879 insertEvent(event); 894 insertEvent(event);
880 } 895 }
881 // insert due todos 896 // insert due todos
882 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 897 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
883 Todo *todo; 898 Todo *todo;
884 for(todo = todos.first(); todo; todo = todos.next()) { 899 for(todo = todos.first(); todo; todo = todos.next()) {
885 insertTodo( todo ); 900 insertTodo( todo );
886 } 901 }
887 finishUpdateCell(); 902 finishUpdateCell();
888 // if ( isVisible()) 903 // if ( isVisible())
889 //qApp->processEvents(); 904 //qApp->processEvents();
890} 905}
891 906
892void MonthViewCell::updateConfig( bool bigFont ) // = false 907void MonthViewCell::updateConfig( bool bigFont ) // = false
893{ 908{
894 909
895 if ( bigFont ) { 910 if ( bigFont ) {
896 QFont fo = KOPrefs::instance()->mMonthViewFont; 911 QFont fo = KOPrefs::instance()->mMonthViewFont;
897 int ps = fo.pointSize() + 2; 912 int ps = fo.pointSize() + 2;
898 if ( ps < 18 ) 913 if ( ps < 18 )
899 ps += 2; 914 ps += 2;
900 fo.setPointSize( ps ); 915 fo.setPointSize( ps );
901 setFont( fo ); 916 setFont( fo );
902 } else 917 } else
903 setFont( KOPrefs::instance()->mMonthViewFont ); 918 setFont( KOPrefs::instance()->mMonthViewFont );
904 919
905 QFontMetrics fm( font() ); 920 QFontMetrics fm( font() );
906 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 921 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
907 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 922 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
908 mHolidayPalette = mStandardPalette; 923 mHolidayPalette = mStandardPalette;
909 mPrimaryPalette = mStandardPalette; 924 mPrimaryPalette = mStandardPalette;
910 mNonPrimaryPalette = mStandardPalette; 925 mNonPrimaryPalette = mStandardPalette;
911 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 926 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
912 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 927 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
913 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 928 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
914 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 929 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
915 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 930 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
916 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 931 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
917 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 932 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
918 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 933 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
919 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 934 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
920 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 935 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
921 } 936 }
922 //updateCell(); 937 //updateCell();
923} 938}
924 939
925void MonthViewCell::enableScrollBars( bool enabled ) 940void MonthViewCell::enableScrollBars( bool enabled )
926{ 941{
927 942
928 return; 943 return;
929 if ( enabled ) { 944 if ( enabled ) {
930 QListBoxItem *fi = firstItem (); 945 QListBoxItem *fi = firstItem ();
931 if (fi ) { 946 if (fi ) {
932 int ihei = fi->height( this ); 947 int ihei = fi->height( this );
933 int hei = numRows () * ihei; 948 int hei = numRows () * ihei;
934 if ( hei < height() - horizontalScrollBar()->height () ) { 949 if ( hei < height() - horizontalScrollBar()->height () ) {
935 setVScrollBarMode(QScrollView::AlwaysOff); 950 setVScrollBarMode(QScrollView::AlwaysOff);
936 } 951 }
937 else 952 else
938 setVScrollBarMode(QScrollView::Auto); 953 setVScrollBarMode(QScrollView::Auto);
939 if ( ihei *3 > height() ) { 954 if ( ihei *3 > height() ) {
940 setHScrollBarMode(QScrollView::AlwaysOff); 955 setHScrollBarMode(QScrollView::AlwaysOff);
941 } 956 }
942 else { 957 else {
943 setHScrollBarMode(QScrollView::Auto); 958 setHScrollBarMode(QScrollView::Auto);
944 } 959 }
945 } else { 960 } else {
946 setVScrollBarMode(QScrollView::Auto); 961 setVScrollBarMode(QScrollView::Auto);
947 setHScrollBarMode(QScrollView::Auto); 962 setHScrollBarMode(QScrollView::Auto);
948 } 963 }
949 } else { 964 } else {
950 setVScrollBarMode(QScrollView::AlwaysOff); 965 setVScrollBarMode(QScrollView::AlwaysOff);
951 setHScrollBarMode(QScrollView::AlwaysOff); 966 setHScrollBarMode(QScrollView::AlwaysOff);
952 } 967 }
953} 968}
954 969
955Incidence *MonthViewCell::selectedIncidence() 970Incidence *MonthViewCell::selectedIncidence()
956{ 971{
957 int index = currentItem(); 972 int index = currentItem();
958 if ( index < 0 ) return 0; 973 if ( index < 0 ) return 0;
959 974
960 MonthViewItem *mitem = 975 MonthViewItem *mitem =
961 static_cast<MonthViewItem *>( item( index ) ); 976 static_cast<MonthViewItem *>( item( index ) );
962 977
963 if ( !mitem ) return 0; 978 if ( !mitem ) return 0;
964 979
965 return mitem->incidence(); 980 return mitem->incidence();
966} 981}
967 982
968QDate MonthViewCell::selectedIncidenceDate() 983QDate MonthViewCell::selectedIncidenceDate()
969{ 984{
970 QDate qd; 985 QDate qd;
971 int index = currentItem(); 986 int index = currentItem();
972 if ( index < 0 ) return qd; 987 if ( index < 0 ) return qd;
973 988
974 MonthViewItem *mitem = 989 MonthViewItem *mitem =
975 static_cast<MonthViewItem *>( item( index ) ); 990 static_cast<MonthViewItem *>( item( index ) );
976 991
977 if ( !mitem ) return qd; 992 if ( !mitem ) return qd;
978 993
979 return mitem->incidenceDate(); 994 return mitem->incidenceDate();
980} 995}
981 996
982void MonthViewCell::deselect() 997void MonthViewCell::deselect()
983{ 998{
984 clearSelection(); 999 clearSelection();
985 enableScrollBars( false ); 1000 enableScrollBars( false );
986 // updateCell(); 1001 // updateCell();
987} 1002}
988void MonthViewCell::select() 1003void MonthViewCell::select()
989{ 1004{
990 ;// updateCell(); 1005 ;// updateCell();
991} 1006}
992 1007
993void MonthViewCell::resizeEvent ( QResizeEvent * e ) 1008void MonthViewCell::resizeEvent ( QResizeEvent * e )
994{ 1009{
995 if ( !mMonthView->isUpdatePossible() ) 1010 if ( !mMonthView->isUpdatePossible() )
996 return; 1011 return;
997 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 1012 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
998 deselect(); 1013 deselect();
999 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 1014 mLabel->setMaximumHeight( height() - lineWidth()*2 );
1000 1015
1001 QString text; 1016 QString text;
1002 mLabel->setText( text ); 1017 mLabel->setText( text );
1003 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 1018 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1004 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 1019 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
1005 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 1020 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
1006 mLabel->resize( mLabelBigSize ); 1021 mLabel->resize( mLabelBigSize );
1007 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1022 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1008 } else { 1023 } else {
1009 mLabel->resize( mLabelSize ); 1024 mLabel->resize( mLabelSize );
1010 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1025 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1011 } 1026 }
1012 mLabel->setText( text ); 1027 mLabel->setText( text );
1013 1028
1014 int size = height() - mLabel->height() - lineWidth()-1; 1029 int size = height() - mLabel->height() - lineWidth()-1;
1015 //qDebug("LW %d ", lineWidth()); 1030 //qDebug("LW %d ", lineWidth());
1016 if ( size > 0 ) 1031 if ( size > 0 )
1017 verticalScrollBar()->setMaximumHeight( size ); 1032 verticalScrollBar()->setMaximumHeight( size );
1018 size = width() - mLabel->width() -lineWidth()-1; 1033 size = width() - mLabel->width() -lineWidth()-1;
1019 if ( size > 0 ) 1034 if ( size > 0 )
1020 horizontalScrollBar()->setMaximumWidth( size ); 1035 horizontalScrollBar()->setMaximumWidth( size );
1021 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1036 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1022 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1037 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1023 // mItemList->resize ( width(), height () ); 1038 // mItemList->resize ( width(), height () );
1024 if ( e ) 1039 if ( e )
1025 KNoScrollListBox::resizeEvent ( e ); 1040 KNoScrollListBox::resizeEvent ( e );
1026} 1041}
1027 1042
1028void MonthViewCell::defaultAction( QListBoxItem *item ) 1043void MonthViewCell::defaultAction( QListBoxItem *item )
1029{ 1044{
1030 1045
1031 if ( !item ) { 1046 if ( !item ) {
1032 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1047 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1033 emit newEventSignal( dt ); 1048 emit newEventSignal( dt );
1034 return; 1049 return;
1035 } 1050 }
1036 1051
1037 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1052 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1038 Incidence *incidence = eventItem->incidence(); 1053 Incidence *incidence = eventItem->incidence();
1039 if ( incidence ) mMonthView->defaultAction( incidence ); 1054 if ( incidence ) mMonthView->defaultAction( incidence );
1040} 1055}
1041void MonthViewCell::showDay() 1056void MonthViewCell::showDay()
1042{ 1057{
1043 emit showDaySignal( date() ); 1058 emit showDaySignal( date() );
1044} 1059}
1045void MonthViewCell::newEvent() 1060void MonthViewCell::newEvent()
1046{ 1061{
1047 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1062 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1048 emit newEventSignal( dt ); 1063 emit newEventSignal( dt );
1049} 1064}
1050void MonthViewCell::cellClicked( QListBoxItem *item ) 1065void MonthViewCell::cellClicked( QListBoxItem *item )
1051{ 1066{
1052 mMonthView->setSelectedCell( this ); 1067 mMonthView->setSelectedCell( this );
1053 if ( item == 0 ) { 1068 if ( item == 0 ) {
1054 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1069 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1055 emit newEventSignal( dt ); 1070 emit newEventSignal( dt );
1056 return; 1071 return;
1057 } 1072 }
1058 1073
1059} 1074}
1060 1075
1061void MonthViewCell::contextMenu( QListBoxItem *item ) 1076void MonthViewCell::contextMenu( QListBoxItem *item )
1062{ 1077{
1063 mMonthView->setPopupCell( this ); 1078 mMonthView->setPopupCell( this );
1064 if ( !item ) { 1079 if ( !item ) {
1065 mMonthView->showContextMenu( 0 ); 1080 mMonthView->showContextMenu( 0 );
1066 return; 1081 return;
1067 } 1082 }
1068 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1083 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1069 Incidence *incidence = eventItem->incidence(); 1084 Incidence *incidence = eventItem->incidence();
1070 if ( incidence ) mMonthView->showContextMenu( incidence ); 1085 if ( incidence ) mMonthView->showContextMenu( incidence );
1071} 1086}
1072 1087
1073void MonthViewCell::selection( QListBoxItem *item ) 1088void MonthViewCell::selection( QListBoxItem *item )
1074{ 1089{
1075 if ( !item ) return; 1090 if ( !item ) return;
1076 1091
1077 mMonthView->setSelectedCell( this ); 1092 mMonthView->setSelectedCell( this );
1078} 1093}
1079 1094
1080 1095
1081// ******************************************************************************* 1096// *******************************************************************************
1082// ******************************************************************************* 1097// *******************************************************************************
1083// ******************************************************************************* 1098// *******************************************************************************
1084 1099
1085 1100
1086KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1101KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1087 : KOEventView( calendar, parent, name ), 1102 : KOEventView( calendar, parent, name ),
1088 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1103 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1089 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1104 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1090{ 1105{
1091 mFlagKeyPressed = false; 1106 mFlagKeyPressed = false;
1092 mShortDayLabelsM = false; 1107 mShortDayLabelsM = false;
1093 mShortDayLabelsW = false; 1108 mShortDayLabelsW = false;
1094 skipResize = false; 1109 skipResize = false;
1095 clPending = true; 1110 clPending = true;
1096 mPopupCell = 0; 1111 mPopupCell = 0;
1097 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1112 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1098 mWidStack = new QWidgetStack( this ); 1113 mWidStack = new QWidgetStack( this );
1099 QVBoxLayout* hb = new QVBoxLayout( this ); 1114 QVBoxLayout* hb = new QVBoxLayout( this );
1100 mMonthView = new QWidget( mWidStack ); 1115 mMonthView = new QWidget( mWidStack );
1101 mWeekView = new QWidget( mWidStack ); 1116 mWeekView = new QWidget( mWidStack );
1102#if QT_VERSION >= 0x030000 1117#if QT_VERSION >= 0x030000
1103 mWidStack->addWidget(mMonthView ); 1118 mWidStack->addWidget(mMonthView );
1104 mWidStack->addWidget(mWeekView ); 1119 mWidStack->addWidget(mWeekView );
1105#else 1120#else
1106 mWidStack->addWidget( mMonthView, 1 ); 1121 mWidStack->addWidget( mMonthView, 1 );
1107 mWidStack->addWidget( mWeekView , 1 ); 1122 mWidStack->addWidget( mWeekView , 1 );
1108#endif 1123#endif
1109 hb->addWidget( mNavigatorBar ); 1124 hb->addWidget( mNavigatorBar );
1110 hb->addWidget( mWidStack ); 1125 hb->addWidget( mWidStack );
1111 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1126 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1112 updatePossible = false; 1127 updatePossible = false;
1113 //updatePossible = true; 1128 //updatePossible = true;
1114 mCells.setAutoDelete( true ); 1129 mCells.setAutoDelete( true );
1115 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1130 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1116 mDayLabels.resize( mDaysPerWeek ); 1131 mDayLabels.resize( mDaysPerWeek );
1117 mDayLabelsW.resize( mDaysPerWeek ); 1132 mDayLabelsW.resize( mDaysPerWeek );
1118 QFont bfont = font(); 1133 QFont bfont = font();
1119 if ( QApplication::desktop()->width() < 650 ) { 1134 if ( QApplication::desktop()->width() < 650 ) {
1120 bfont.setPointSize( bfont.pointSize() - 2 ); 1135 bfont.setPointSize( bfont.pointSize() - 2 );
1121 } 1136 }
1122 bfont.setBold( true ); 1137 bfont.setBold( true );
1123 int i; 1138 int i;
1124 1139
1125 for( i = 0; i < mDaysPerWeek; i++ ) { 1140 for( i = 0; i < mDaysPerWeek; i++ ) {
1126 QLabel *label = new QLabel( mMonthView ); 1141 QLabel *label = new QLabel( mMonthView );
1127 label->setFont(bfont); 1142 label->setFont(bfont);
1128 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1143 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1129 label->setLineWidth(1); 1144 label->setLineWidth(1);
1130 label->setAlignment(AlignCenter); 1145 label->setAlignment(AlignCenter);
1131 mDayLabels.insert( i, label ); 1146 mDayLabels.insert( i, label );
1132 label = new QLabel( mWeekView ); 1147 label = new QLabel( mWeekView );
1133 label->setFont(bfont); 1148 label->setFont(bfont);
1134 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1149 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1135 label->setLineWidth(1); 1150 label->setLineWidth(1);
1136 label->setAlignment(AlignCenter); 1151 label->setAlignment(AlignCenter);
1137 mDayLabelsW.insert( i, label ); 1152 mDayLabelsW.insert( i, label );
1138 } 1153 }
1139 1154
1140 bfont.setBold( false ); 1155 bfont.setBold( false );
1141 mWeekLabels.resize( mNumWeeks+1 ); 1156 mWeekLabels.resize( mNumWeeks+1 );
1142 mWeekLabelsW.resize( 2 ); 1157 mWeekLabelsW.resize( 2 );
1143 for( i = 0; i < mNumWeeks+1; i++ ) { 1158 for( i = 0; i < mNumWeeks+1; i++ ) {
1144 KOWeekButton *label = new KOWeekButton( mMonthView ); 1159 KOWeekButton *label = new KOWeekButton( mMonthView );
1145 label->setFocusPolicy(NoFocus); 1160 label->setFocusPolicy(NoFocus);
1146 label->setFont(bfont); 1161 label->setFont(bfont);
1147 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1162 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1148 label->setFlat(true); 1163 label->setFlat(true);
1149 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1164 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1150 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1165 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1151 //label->setLineWidth(1); 1166 //label->setLineWidth(1);
1152 //label->setAlignment(AlignCenter); 1167 //label->setAlignment(AlignCenter);
1153 mWeekLabels.insert( i, label ); 1168 mWeekLabels.insert( i, label );
1154 } 1169 }
1155 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1170 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1156 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1171 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1157 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1172 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));