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