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