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