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