summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index ddac6e4..3aaa50a 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,547 +1,548 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32#ifndef DESKTOP_VERSION 32#ifndef DESKTOP_VERSION
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#else 34#else
35#include <qapplication.h> 35#include <qapplication.h>
36#endif 36#endif
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43 43
44#include <kcalendarsystem.h> 44#include <kcalendarsystem.h>
45 45
46#ifndef KORG_NOPRINTER 46#ifndef KORG_NOPRINTER
47#include "calprinter.h" 47#include "calprinter.h"
48#endif 48#endif
49#include "koprefs.h" 49#include "koprefs.h"
50#ifndef KORG_NOPLUGINS 50#ifndef KORG_NOPLUGINS
51#include "kocore.h" 51#include "kocore.h"
52#endif 52#endif
53#include "koglobals.h" 53#include "koglobals.h"
54#include <libkcal/kincidenceformatter.h> 54#include <libkcal/kincidenceformatter.h>
55 55
56#include "komonthview.h" 56#include "komonthview.h"
57 57
58#define PIXMAP_SIZE 5 58#define PIXMAP_SIZE 5
59#ifdef DESKTOP_VERSION 59#ifdef DESKTOP_VERSION
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p) 69 virtual QString text( const QPoint& p)
70 { 70 {
71 return _wid->getWhatsThisText(p) ; 71 return _wid->getWhatsThisText(p) ;
72 }; 72 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86} 86}
87KNoScrollListBox::~KNoScrollListBox() 87KNoScrollListBox::~KNoScrollListBox()
88{ 88{
89 89
90} 90}
91QString KNoScrollListBox::getWhatsThisText(QPoint p) 91QString KNoScrollListBox::getWhatsThisText(QPoint p)
92{ 92{
93 QListBoxItem* item = itemAt ( p ); 93 QListBoxItem* item = itemAt ( p );
94 if ( ! item ) { 94 if ( ! item ) {
95 return i18n("Click in the cell\nto add an event!"); 95 return i18n("Click in the cell\nto add an event!");
96 } 96 }
97 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 97 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
98 KOPrefs::instance()->mWTshowDetails, 98 KOPrefs::instance()->mWTshowDetails,
99 KOPrefs::instance()->mWTshowCreated, 99 KOPrefs::instance()->mWTshowCreated,
100 KOPrefs::instance()->mWTshowChanged); 100 KOPrefs::instance()->mWTshowChanged);
101} 101}
102void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 102void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
103{ 103{
104 104
105 switch(e->key()) { 105 switch(e->key()) {
106 case Key_Right: 106 case Key_Right:
107 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 107 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
108 { 108 {
109 e->ignore(); 109 e->ignore();
110 return; 110 return;
111 } 111 }
112 scrollBy(10,0); 112 scrollBy(10,0);
113 break; 113 break;
114 case Key_Left: 114 case Key_Left:
115 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 115 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
116 { 116 {
117 e->ignore(); 117 e->ignore();
118 return; 118 return;
119 } 119 }
120 scrollBy(-10,0); 120 scrollBy(-10,0);
121 break; 121 break;
122 case Key_Up: 122 case Key_Up:
123 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 123 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
124 e->ignore(); 124 e->ignore();
125 break; 125 break;
126 } 126 }
127 setCurrentItem((currentItem()+count()-1)%count()); 127 setCurrentItem((currentItem()+count()-1)%count());
128 if(!itemVisible(currentItem())) { 128 if(!itemVisible(currentItem())) {
129 if((unsigned int) currentItem() == (count()-1)) { 129 if((unsigned int) currentItem() == (count()-1)) {
130 setTopItem(currentItem()-numItemsVisible()+1); 130 setTopItem(currentItem()-numItemsVisible()+1);
131 } else { 131 } else {
132 setTopItem(topItem()-1); 132 setTopItem(topItem()-1);
133 } 133 }
134 } 134 }
135 break; 135 break;
136 case Key_Down: 136 case Key_Down:
137 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 137 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
138 e->ignore(); 138 e->ignore();
139 break; 139 break;
140 } 140 }
141 setCurrentItem((currentItem()+1)%count()); 141 setCurrentItem((currentItem()+1)%count());
142 if(!itemVisible(currentItem())) { 142 if(!itemVisible(currentItem())) {
143 if(currentItem() == 0) { 143 if(currentItem() == 0) {
144 setTopItem(0); 144 setTopItem(0);
145 } else { 145 } else {
146 setTopItem(topItem()+1); 146 setTopItem(topItem()+1);
147 } 147 }
148 } 148 }
149 break; 149 break;
150 case Key_I: 150 case Key_I:
151 QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); 151 QTimer::singleShot( 11, this, SLOT ( oneDown() ) );
152 e->ignore(); 152 e->ignore();
153 break; 153 break;
154 case Key_Shift: 154 case Key_Shift:
155 emit shiftDown(); 155 emit shiftDown();
156 break; 156 break;
157 default: 157 default:
158 e->ignore(); 158 e->ignore();
159 break; 159 break;
160 } 160 }
161} 161}
162 162
163void KNoScrollListBox::oneDown() 163void KNoScrollListBox::oneDown()
164{ 164{
165 setCurrentItem((currentItem()+1)%count()); 165 setCurrentItem((currentItem()+1)%count());
166 if(!itemVisible(currentItem())) { 166 if(!itemVisible(currentItem())) {
167 if(currentItem() == 0) { 167 if(currentItem() == 0) {
168 setTopItem(0); 168 setTopItem(0);
169 } else { 169 } else {
170 setTopItem(topItem()+1); 170 setTopItem(topItem()+1);
171 } 171 }
172 } 172 }
173} 173}
174void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 174void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
175{ 175{
176 switch(e->key()) { 176 switch(e->key()) {
177 case Key_Shift: 177 case Key_Shift:
178 emit shiftUp(); 178 emit shiftUp();
179 break; 179 break;
180 default: 180 default:
181 break; 181 break;
182 } 182 }
183} 183}
184 184
185void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 185void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
186{ 186{
187 QListBox::mousePressEvent(e); 187 QListBox::mousePressEvent(e);
188 188
189 if(e->button() == RightButton) { 189 if(e->button() == RightButton) {
190 emit rightClick(); 190 emit rightClick();
191 } 191 }
192} 192}
193 193
194MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 194MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
195 : QListBoxItem() 195 : QListBoxItem()
196{ 196{
197 setText( s ); 197 setText( s );
198 198
199 mIncidence = incidence; 199 mIncidence = incidence;
200 mDate = qd; 200 mDate = qd;
201 mRecur = false; 201 mRecur = false;
202 mAlarm = false; 202 mAlarm = false;
203 mReply = false; 203 mReply = false;
204 mInfo = false; 204 mInfo = false;
205} 205}
206 206
207void MonthViewItem::paint(QPainter *p) 207void MonthViewItem::paint(QPainter *p)
208{ 208{
209#if QT_VERSION >= 0x030000 209#if QT_VERSION >= 0x030000
210 bool sel = isSelected(); 210 bool sel = isSelected();
211#else 211#else
212 bool sel = selected(); 212 bool sel = selected();
213#endif 213#endif
214 214
215 215
216 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 216 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
217 { 217 {
218 p->setBackgroundColor( palette().color( QPalette::Normal, \ 218 p->setBackgroundColor( palette().color( QPalette::Normal, \
219 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 219 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
220 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 220 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
221 } 221 }
222 int x = 1; 222 int x = 1;
223 //int y = 3;//(height() - mRecurPixmap.height()) /2; 223 //int y = 3;//(height() - mRecurPixmap.height()) /2;
224 int size = PIXMAP_SIZE; 224 int size = PIXMAP_SIZE;
225 if ( QApplication::desktop()->width() < 300 ) 225 if ( QApplication::desktop()->width() < 300 )
226 size = 3; 226 size = 3;
227 int y = (height( listBox () ) - size -1 ) /2; 227 int heihei = height( listBox () );
228 int y = (heihei - size -1 ) /2;
228 229
229 if ( KOPrefs::instance()->mMonthShowIcons ) { 230 if ( KOPrefs::instance()->mMonthShowIcons ) {
230 if ( mInfo ) { 231 if ( mInfo ) {
231 p->fillRect ( x, y,size,size, Qt::darkGreen ); 232 p->fillRect ( x, y,size,size, Qt::darkGreen );
232 x += size + 1; 233 x += size + 1;
233 } 234 }
234 if ( mRecur ) { 235 if ( mRecur ) {
235 p->fillRect ( x, y,size,size, Qt::blue ); 236 p->fillRect ( x, y,size,size, Qt::blue );
236 x += size + 1; 237 x += size + 1;
237 } 238 }
238 if ( mAlarm ) { 239 if ( mAlarm ) {
239 p->fillRect ( x, y,size,size, Qt::red ); 240 p->fillRect ( x, y,size,size, Qt::red );
240 x += size + 1; 241 x += size + 1;
241 } 242 }
242 if ( mReply ) { 243 if ( mReply ) {
243 p->fillRect ( x, y,size,size, Qt::yellow ); 244 p->fillRect ( x, y,size,size, Qt::yellow );
244 x += size + 1; 245 x += size + 1;
245 } 246 }
246 } 247 }
247 if ( mMultiday ) { 248 if ( mMultiday ) {
248 int yyy = y+(size/2); 249 int yyy = y+(size/2);
249 int sizeM = size+2; 250 int sizeM = size+2;
250 p->setBrush( QBrush::SolidPattern ); 251 p->setBrush( QBrush::SolidPattern );
251 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 252 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
252 if ( mMultiday == 2 || mMultiday == 3 ) { 253 if ( mMultiday == 2 || mMultiday == 3 ) {
253 QPointArray pa ( 3 ); 254 QPointArray pa ( 3 );
254 pa.setPoint (0, x, yyy ); 255 pa.setPoint (0, x, yyy );
255 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 256 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
256 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 257 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
257 p->drawPolygon( pa ); 258 p->drawPolygon( pa );
258 } 259 }
259 if ( mMultiday == 2 || mMultiday == 1 ) { 260 if ( mMultiday == 2 || mMultiday == 1 ) {
260 QPointArray pa ( 3 ); 261 QPointArray pa ( 3 );
261 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 262 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
262 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 263 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
263 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 264 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
264 p->drawPolygon( pa ); 265 p->drawPolygon( pa );
265 } 266 }
266 if ( mMultiday == 1 ) { 267 if ( mMultiday == 1 ) {
267 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 268 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
268 269
269 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 270 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
270 } 271 }
271 if ( mMultiday == 3 ) { 272 if ( mMultiday == 3 ) {
272 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 273 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
273 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 274 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
274 275
275 } 276 }
276 x += sizeM/2 + 1; 277 x += sizeM/2 + 1;
277 x += sizeM + 1; 278 x += sizeM + 1;
278 } 279 }
279 QFontMetrics fm = p->fontMetrics(); 280 QFontMetrics fm = p->fontMetrics();
280 int yPos; 281 int yPos;
281 int pmheight = size; 282 int pmheight = size;
282 if( pmheight < fm.height() ) 283 if( pmheight < fm.height() )
283 yPos = fm.ascent() + fm.leading()/2; 284 yPos = fm.ascent() + fm.leading()/2;
284 else 285 else
285 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 286 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
286 p->setPen( palette().color( QPalette::Normal, sel ? \ 287 p->setPen( palette().color( QPalette::Normal, sel ? \
287 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 288 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
288 p->drawText( x, yPos, text() ); 289 p->drawText( x, yPos, text() );
289 if ( mIncidence->cancelled() ) { 290 if ( mIncidence->cancelled() ) {
290 int wid = fm.width( text() ); 291 int wid = fm.width( text() );
291 p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); 292 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
292 } 293 }
293 294
294} 295}
295 296
296int MonthViewItem::height(const QListBox *lb) const 297int MonthViewItem::height(const QListBox *lb) const
297{ 298{
298 if ( lb ) 299 if ( lb )
299 return lb->fontMetrics().lineSpacing()+1; 300 return lb->fontMetrics().lineSpacing()+1;
300 return 10; 301 return 10;
301} 302}
302 303
303int MonthViewItem::width(const QListBox *lb) const 304int MonthViewItem::width(const QListBox *lb) const
304{ 305{
305 int size = PIXMAP_SIZE; 306 int size = PIXMAP_SIZE;
306 if ( QApplication::desktop()->width() < 300 ) 307 if ( QApplication::desktop()->width() < 300 )
307 size = 3; 308 size = 3;
308 int x = 1; 309 int x = 1;
309 if ( KOPrefs::instance()->mMonthShowIcons ) { 310 if ( KOPrefs::instance()->mMonthShowIcons ) {
310 if ( mInfo ) { 311 if ( mInfo ) {
311 x += size + 1; 312 x += size + 1;
312 } 313 }
313 if( mRecur ) { 314 if( mRecur ) {
314 x += size+1; 315 x += size+1;
315 } 316 }
316 if( mAlarm ) { 317 if( mAlarm ) {
317 x += size+1; 318 x += size+1;
318 } 319 }
319 if( mReply ) { 320 if( mReply ) {
320 x += size+1; 321 x += size+1;
321 } 322 }
322 } 323 }
323 if( mMultiday ) { 324 if( mMultiday ) {
324 x += size+1+2+size/2; 325 x += size+1+2+size/2;
325 } 326 }
326 327
327 return( x + lb->fontMetrics().width( text() ) + 1 ); 328 return( x + lb->fontMetrics().width( text() ) + 1 );
328} 329}
329 330
330 331
331MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 332MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
332 : QWidget( par ), 333 : QWidget( par ),
333 mMonthView( parent ) 334 mMonthView( parent )
334{ 335{
335 336
336 QVBoxLayout *topLayout = new QVBoxLayout( this ); 337 QVBoxLayout *topLayout = new QVBoxLayout( this );
337 338
338 // mLabel = new QLabel( this );QPushButton 339 // mLabel = new QLabel( this );QPushButton
339 mLabel = new QPushButton( this ); 340 mLabel = new QPushButton( this );
340 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 341 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
341 //mLabel->setLineWidth( 1 ); 342 //mLabel->setLineWidth( 1 );
342 //mLabel->setAlignment( AlignCenter ); 343 //mLabel->setAlignment( AlignCenter );
343 mLabel->setFlat( true ); 344 mLabel->setFlat( true );
344 mLabel->setFocusPolicy(NoFocus); 345 mLabel->setFocusPolicy(NoFocus);
345 mItemList = new KNoScrollListBox( this ); 346 mItemList = new KNoScrollListBox( this );
346 mItemList->setMinimumSize( 10, 10 ); 347 mItemList->setMinimumSize( 10, 10 );
347 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 348 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
348 mItemList->setLineWidth( 1 ); 349 mItemList->setLineWidth( 1 );
349 topLayout->addWidget( mItemList ); 350 topLayout->addWidget( mItemList );
350 mLabel->raise(); 351 mLabel->raise();
351 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 352 // QColor( 0,0,255 ) QColor( 160,1600,255 )
352 mStandardPalette = palette(); 353 mStandardPalette = palette();
353 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 354 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
354 355
355 enableScrollBars( false ); 356 enableScrollBars( false );
356 updateConfig(); 357 updateConfig();
357 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 358 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
358 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 359 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
359 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 360 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
360 SLOT( defaultAction( QListBoxItem * ) ) ); 361 SLOT( defaultAction( QListBoxItem * ) ) );
361 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 362 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
362 const QPoint &) ), 363 const QPoint &) ),
363 SLOT( contextMenu( QListBoxItem * ) ) ); 364 SLOT( contextMenu( QListBoxItem * ) ) );
364 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 365 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
365 SLOT( selection( QListBoxItem * ) ) ); 366 SLOT( selection( QListBoxItem * ) ) );
366 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 367 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
367 SLOT( cellClicked( QListBoxItem * ) ) ); 368 SLOT( cellClicked( QListBoxItem * ) ) );
368 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 369 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
369 SLOT( selection( QListBoxItem * ) ) ); 370 SLOT( selection( QListBoxItem * ) ) );
370} 371}
371#ifdef DESKTOP_VERSION 372#ifdef DESKTOP_VERSION
372QToolTipGroup *MonthViewCell::toolTipGroup() 373QToolTipGroup *MonthViewCell::toolTipGroup()
373{ 374{
374 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 375 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
375 return mToolTipGroup; 376 return mToolTipGroup;
376} 377}
377#endif 378#endif
378 379
379void MonthViewCell::setDate( const QDate &date ) 380void MonthViewCell::setDate( const QDate &date )
380{ 381{
381 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 382 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
382 mDate = date; 383 mDate = date;
383 384
384 385
385 386
386 //resizeEvent( 0 ); 387 //resizeEvent( 0 );
387} 388}
388 389
389QDate MonthViewCell::date() const 390QDate MonthViewCell::date() const
390{ 391{
391 return mDate; 392 return mDate;
392} 393}
393 394
394void MonthViewCell::setPrimary( bool primary ) 395void MonthViewCell::setPrimary( bool primary )
395{ 396{
396 mPrimary = primary; 397 mPrimary = primary;
397 //setMyPalette(); 398 //setMyPalette();
398} 399}
399void MonthViewCell::setMyPalette() 400void MonthViewCell::setMyPalette()
400{ 401{
401 402
402 if ( mHoliday) { 403 if ( mHoliday) {
403 setPalette( mHolidayPalette ); 404 setPalette( mHolidayPalette );
404 } else { 405 } else {
405 if ( mPrimary ) { 406 if ( mPrimary ) {
406 setPalette( mPrimaryPalette ); 407 setPalette( mPrimaryPalette );
407 } else { 408 } else {
408 setPalette( mNonPrimaryPalette ); 409 setPalette( mNonPrimaryPalette );
409 } 410 }
410 } 411 }
411 QPalette pal = palette(); 412 QPalette pal = palette();
412 413
413 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 414 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
414} 415}
415QPalette MonthViewCell::getPalette () 416QPalette MonthViewCell::getPalette ()
416{ 417{
417 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 418 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
418 return mStandardPalette; 419 return mStandardPalette;
419 if ( mHoliday) { 420 if ( mHoliday) {
420 return mHolidayPalette ; 421 return mHolidayPalette ;
421 } else { 422 } else {
422 if ( mPrimary ) { 423 if ( mPrimary ) {
423 return mPrimaryPalette ; 424 return mPrimaryPalette ;
424 } 425 }
425 } 426 }
426 return mNonPrimaryPalette; 427 return mNonPrimaryPalette;
427} 428}
428bool MonthViewCell::isPrimary() const 429bool MonthViewCell::isPrimary() const
429{ 430{
430 return mPrimary; 431 return mPrimary;
431} 432}
432 433
433void MonthViewCell::setHoliday( bool holiday ) 434void MonthViewCell::setHoliday( bool holiday )
434{ 435{
435 mHoliday = holiday; 436 mHoliday = holiday;
436 //setMyPalette(); 437 //setMyPalette();
437} 438}
438 439
439void MonthViewCell::setHoliday( const QString &holiday ) 440void MonthViewCell::setHoliday( const QString &holiday )
440{ 441{
441 mHolidayString = holiday; 442 mHolidayString = holiday;
442 443
443 if ( !holiday.isEmpty() ) { 444 if ( !holiday.isEmpty() ) {
444 setHoliday( true ); 445 setHoliday( true );
445 } 446 }
446} 447}
447void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 448void MonthViewCell::keyPressEvent ( QKeyEvent * e )
448{ 449{
449 450
450 e->ignore(); 451 e->ignore();
451 452
452} 453}
453 454
454void MonthViewCell::startUpdateCell() 455void MonthViewCell::startUpdateCell()
455{ 456{
456 457
457 mItemList->setFocusPolicy(NoFocus); 458 mItemList->setFocusPolicy(NoFocus);
458 if ( !mMonthView->isUpdatePossible() ) 459 if ( !mMonthView->isUpdatePossible() )
459 return; 460 return;
460 461
461 /* 462 /*
462 if ( !isVisible() ){ 463 if ( !isVisible() ){
463 return; 464 return;
464 } 465 }
465 */ 466 */
466 // qDebug("MonthViewCell::updateCell() "); 467 // qDebug("MonthViewCell::updateCell() ");
467 setPrimary( mDate.month()%2 ); 468 setPrimary( mDate.month()%2 );
468 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 469 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
469 if ( mDate == QDate::currentDate() ) { 470 if ( mDate == QDate::currentDate() ) {
470 mItemList->setLineWidth( 3 ); 471 mItemList->setLineWidth( 3 );
471 } else { 472 } else {
472 mItemList->setLineWidth( 1 ); 473 mItemList->setLineWidth( 1 );
473 } 474 }
474 mItemList->clear(); 475 mItemList->clear();
475 476
476#ifdef DESKTOP_VERSION 477#ifdef DESKTOP_VERSION
477 QToolTip::remove(this); 478 QToolTip::remove(this);
478#endif 479#endif
479 mToolTip = ""; 480 mToolTip = "";
480 //qApp->processEvents(); 481 //qApp->processEvents();
481 if ( !mHolidayString.isEmpty() ) { 482 if ( !mHolidayString.isEmpty() ) {
482 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 483 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
483 item->setPalette( mHolidayPalette ); 484 item->setPalette( mHolidayPalette );
484 mItemList->insertItem( item ); 485 mItemList->insertItem( item );
485 mToolTip += mHolidayString+"\n"; 486 mToolTip += mHolidayString+"\n";
486 } 487 }
487} 488}
488 489
489void MonthViewCell::insertEvent(Event *event) 490void MonthViewCell::insertEvent(Event *event)
490{ 491{
491 492
492 mItemList->setFocusPolicy(WheelFocus); 493 mItemList->setFocusPolicy(WheelFocus);
493 if ( !(event->doesRecur() == Recurrence::rNone) ) { 494 if ( !(event->doesRecur() == Recurrence::rNone) ) {
494 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 495 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
495 return; 496 return;
496 else 497 else
497 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 498 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
498 return; 499 return;
499 } 500 }
500 501
501 if ( event->categories().contains("Holiday") || 502 if ( event->categories().contains("Holiday") ||
502 event->categories().contains(i18n("Holiday"))) { 503 event->categories().contains(i18n("Holiday"))) {
503 setHoliday( true ); 504 setHoliday( true );
504 if ( mDate.dayOfWeek() == 7 ) 505 if ( mDate.dayOfWeek() == 7 )
505 mItemList->setLineWidth( 3 ); 506 mItemList->setLineWidth( 3 );
506 } 507 }
507 QString text; 508 QString text;
508 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 509 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
509 if (event->isMultiDay()) { 510 if (event->isMultiDay()) {
510 QString prefix = "<->";multiday = 2; 511 QString prefix = "<->";multiday = 2;
511 QString time; 512 QString time;
512 if ( event->doesRecur() ) { 513 if ( event->doesRecur() ) {
513 if ( event->recursOn( mDate) ) { 514 if ( event->recursOn( mDate) ) {
514 prefix ="->" ;multiday = 1; 515 prefix ="->" ;multiday = 1;
515 } 516 }
516 else { 517 else {
517 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 518 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
518 if ( event->recursOn( mDate.addDays( -days)) ) 519 if ( event->recursOn( mDate.addDays( -days)) )
519 prefix ="<-" ;multiday = 3; 520 prefix ="<-" ;multiday = 3;
520 } 521 }
521 522
522 } else { 523 } else {
523 if (mDate == event->dtStart().date()) { 524 if (mDate == event->dtStart().date()) {
524 prefix ="->" ;multiday = 1; 525 prefix ="->" ;multiday = 1;
525 } else if (mDate == event->dtEnd().date()) { 526 } else if (mDate == event->dtEnd().date()) {
526 prefix ="<-" ;multiday = 3; 527 prefix ="<-" ;multiday = 3;
527 } 528 }
528 } 529 }
529 if ( !event->doesFloat() ) { 530 if ( !event->doesFloat() ) {
530 if ( mDate == event->dtStart().date () ) 531 if ( mDate == event->dtStart().date () )
531 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 532 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
532 else if ( mDate == event->dtEnd().date () ) 533 else if ( mDate == event->dtEnd().date () )
533 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 534 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
534 535
535 } 536 }
536 text = time + event->summary(); 537 text = time + event->summary();
537 mToolTip += prefix + text; 538 mToolTip += prefix + text;
538 } else { 539 } else {
539 if (event->doesFloat()) { 540 if (event->doesFloat()) {
540 text = event->summary(); 541 text = event->summary();
541 mToolTip += text; 542 mToolTip += text;
542 } 543 }
543 else { 544 else {
544 text = KGlobal::locale()->formatTime(event->dtStart().time()); 545 text = KGlobal::locale()->formatTime(event->dtStart().time());
545 text += " " + event->summary(); 546 text += " " + event->summary();
546 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 547 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
547 } 548 }