summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-28 12:59:27 (UTC)
committer zautrix <zautrix>2005-07-28 12:59:27 (UTC)
commit8e21306a697d77c80d42f450a721cb3d7c23fd0f (patch) (unidiff)
treea7eed1d0dafc2725709704a3658f1ff42b7d8b8b
parentfee4c893fe8fd01af1b55c1ccd40213fc18a36b4 (diff)
downloadkdepimpi-8e21306a697d77c80d42f450a721cb3d7c23fd0f.zip
kdepimpi-8e21306a697d77c80d42f450a721cb3d7c23fd0f.tar.gz
kdepimpi-8e21306a697d77c80d42f450a721cb3d7c23fd0f.tar.bz2
monv fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp12
-rw-r--r--korganizer/komonthview.h3
2 files changed, 10 insertions, 5 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 4aeb20c..8d06040 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,529 +1,534 @@
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 mBlockDeselect = false;
85 mWT = new KNOWhatsThis(this); 86 mWT = new KNOWhatsThis(this);
86 resetOnFocusIn = true; 87 resetOnFocusIn = true;
87 setVScrollBarMode(QScrollView::AlwaysOff); 88 setVScrollBarMode(QScrollView::AlwaysOff);
88 setHScrollBarMode(QScrollView::AlwaysOff); 89 setHScrollBarMode(QScrollView::AlwaysOff);
89} 90}
90KNoScrollListBox::~KNoScrollListBox() 91KNoScrollListBox::~KNoScrollListBox()
91{ 92{
92#if QT_VERSION >= 0x030000 93#if QT_VERSION >= 0x030000
93 94
94#else 95#else
95 delete mWT; 96 delete mWT;
96#endif 97#endif
97} 98}
98 99
99 100
100void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 101void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
101{ 102{
102 QListBox::focusInEvent ( e ); 103 QListBox::focusInEvent ( e );
103 if ( count() ){ 104 if ( count() ){
104 int ci = currentItem(); 105 int ci = currentItem();
105 if ( ci < 0 ) ci = 0; 106 if ( ci < 0 ) ci = 0;
106 107
107 setCurrentItem( ci ); 108 setCurrentItem( ci );
108 setSelected ( ci, true ); 109 setSelected ( ci, true );
109 emit highlighted( item ( ci ) ); 110 emit highlighted( item ( ci ) );
110 111
111 resetOnFocusIn = true; 112 resetOnFocusIn = true;
112 113
113 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { 114 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
114 QListBoxItem *fi = firstItem (); 115 QListBoxItem *fi = firstItem ();
115 if (fi ) { 116 if (fi ) {
116 int ihei = fi->height( this ); 117 int ihei = fi->height( this );
117 int hei = numRows () * ihei; 118 int hei = numRows () * ihei;
118 if ( hei < height() - horizontalScrollBar()->height () ) { 119 if ( hei < height() - horizontalScrollBar()->height () ) {
119 setVScrollBarMode(QScrollView::AlwaysOff); 120 setVScrollBarMode(QScrollView::AlwaysOff);
120 } 121 }
121 else 122 else
122 setVScrollBarMode(QScrollView::Auto); 123 setVScrollBarMode(QScrollView::Auto);
123 if ( ihei *3 > height() ) { 124 if ( ihei *3 > height() ) {
124 setHScrollBarMode(QScrollView::AlwaysOff); 125 setHScrollBarMode(QScrollView::AlwaysOff);
125 } 126 }
126 else { 127 else {
127 setHScrollBarMode(QScrollView::Auto); 128 setHScrollBarMode(QScrollView::Auto);
128 } 129 }
129 } else { 130 } else {
130 setVScrollBarMode(QScrollView::Auto); 131 setVScrollBarMode(QScrollView::Auto);
131 setHScrollBarMode(QScrollView::Auto); 132 setHScrollBarMode(QScrollView::Auto);
132 } 133 }
133 } 134 }
134 } 135 }
135} 136}
136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 137void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
137{ 138{
139 if ( ! mBlockDeselect ) {
138 int i = currentItem (); 140 int i = currentItem ();
139 if ( i >= 0 ) { 141 if ( i >= 0 ) {
140 setSelected ( i, false ); 142 setSelected ( i, false );
141 } 143 }
142 QListBox::focusOutEvent ( e ); 144 QListBox::focusOutEvent ( e );
145 }
143 setVScrollBarMode(QScrollView::AlwaysOff); 146 setVScrollBarMode(QScrollView::AlwaysOff);
144 setHScrollBarMode(QScrollView::AlwaysOff); 147 setHScrollBarMode(QScrollView::AlwaysOff);
145 emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); 148 if ( ! mBlockDeselect )
149 emit highlightIncidence( 0, (MonthViewCell*)this, 0 );
150 mBlockDeselect = false;
146} 151}
147 152
148QString KNoScrollListBox::getWhatsThisText(QPoint p) 153QString KNoScrollListBox::getWhatsThisText(QPoint p)
149{ 154{
150 QListBoxItem* item = itemAt ( p ); 155 QListBoxItem* item = itemAt ( p );
151 if ( ! item ) { 156 if ( ! item ) {
152 return i18n("Click in the cell\nto add an event!"); 157 return i18n("Click in the cell\nto add an event!");
153 } 158 }
154 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 159 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
155 KOPrefs::instance()->mWTshowDetails, 160 KOPrefs::instance()->mWTshowDetails,
156 KOPrefs::instance()->mWTshowCreated, 161 KOPrefs::instance()->mWTshowCreated,
157 KOPrefs::instance()->mWTshowChanged); 162 KOPrefs::instance()->mWTshowChanged);
158} 163}
159void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 164void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
160{ 165{
161 //qDebug("KNoScrollListBox::keyPressEvent "); 166 //qDebug("KNoScrollListBox::keyPressEvent ");
162 switch(e->key()) { 167 switch(e->key()) {
163 case Key_Right: 168 case Key_Right:
164 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 169 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
165 { 170 {
166 e->ignore(); 171 e->ignore();
167 return; 172 return;
168 } 173 }
169 scrollBy(10,0); 174 scrollBy(10,0);
170 break; 175 break;
171 case Key_Left: 176 case Key_Left:
172 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 177 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
173 { 178 {
174 e->ignore(); 179 e->ignore();
175 return; 180 return;
176 } 181 }
177 scrollBy(-10,0); 182 scrollBy(-10,0);
178 break; 183 break;
179 case Key_Up: 184 case Key_Up:
180 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 185 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
181 e->ignore(); 186 e->ignore();
182 break; 187 break;
183 } 188 }
184 if ( count() ) { 189 if ( count() ) {
185 if ( currentItem() == 0 ) { 190 if ( currentItem() == 0 ) {
186 emit prevCell(); 191 emit prevCell();
187 } else { 192 } else {
188 setCurrentItem((currentItem()+count()-1)%count()); 193 setCurrentItem((currentItem()+count()-1)%count());
189 if(!itemVisible(currentItem())) { 194 if(!itemVisible(currentItem())) {
190 if((unsigned int) currentItem() == (count()-1)) { 195 if((unsigned int) currentItem() == (count()-1)) {
191 setTopItem(currentItem()-numItemsVisible()+1); 196 setTopItem(currentItem()-numItemsVisible()+1);
192 } else { 197 } else {
193 setTopItem(topItem()-1); 198 setTopItem(topItem()-1);
194 } 199 }
195 } 200 }
196 } 201 }
197 } 202 }
198 break; 203 break;
199 case Key_Down: 204 case Key_Down:
200 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 205 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
201 e->ignore(); 206 e->ignore();
202 break; 207 break;
203 } 208 }
204 if ( count () ) { 209 if ( count () ) {
205 if ( ((uint)currentItem()+1) == count () ) { 210 if ( ((uint)currentItem()+1) == count () ) {
206 emit nextCell(); 211 emit nextCell();
207 } else { 212 } else {
208 setCurrentItem((currentItem()+1)%count()); 213 setCurrentItem((currentItem()+1)%count());
209 if(!itemVisible(currentItem())) { 214 if(!itemVisible(currentItem())) {
210 if(currentItem() == 0) { 215 if(currentItem() == 0) {
211 setTopItem(0); 216 setTopItem(0);
212 } else { 217 } else {
213 setTopItem(topItem()+1); 218 setTopItem(topItem()+1);
214 } 219 }
215 } 220 }
216 } 221 }
217 } 222 }
218 break; 223 break;
219 case Key_I: 224 case Key_I:
220 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 225 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
221 e->ignore(); 226 e->ignore();
222 break; 227 break;
223 case Key_Return: 228 case Key_Return:
224 case Key_Enter: 229 case Key_Enter:
225 { 230 {
226 if ( currentItem() >= 0 ) { 231 if ( currentItem() >= 0 ) {
227 emit doubleClicked( item( currentItem() ) ); 232 emit doubleClicked( item( currentItem() ) );
228 e->accept(); 233 e->accept();
229 } else { 234 } else {
230 e->ignore(); 235 e->ignore();
231 } 236 }
232 } 237 }
233 break; 238 break;
234 case Key_Shift: 239 case Key_Shift:
235 emit shiftDown(); 240 emit shiftDown();
236 break; 241 break;
237 default: 242 default:
238 e->ignore(); 243 e->ignore();
239 break; 244 break;
240 } 245 }
241} 246}
242 247
243void KNoScrollListBox::oneDown() 248void KNoScrollListBox::oneDown()
244{ 249{
245 if ( count () ) { 250 if ( count () ) {
246 if ( ((uint)currentItem()+1) == count () ) { 251 if ( ((uint)currentItem()+1) == count () ) {
247 emit nextCell(); 252 emit nextCell();
248 } else { 253 } else {
249 resetOnFocusIn = false; 254 resetOnFocusIn = false;
250 setCurrentItem((currentItem()+1)%count()); 255 setCurrentItem((currentItem()+1)%count());
251 if(!itemVisible(currentItem())) { 256 if(!itemVisible(currentItem())) {
252 if(currentItem() == 0) { 257 if(currentItem() == 0) {
253 setTopItem(0); 258 setTopItem(0);
254 } else { 259 } else {
255 setTopItem(topItem()+1); 260 setTopItem(topItem()+1);
256 } 261 }
257 } 262 }
258 } 263 }
259 } 264 }
260} 265}
261void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 266void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
262{ 267{
263 switch(e->key()) { 268 switch(e->key()) {
264 case Key_Shift: 269 case Key_Shift:
265 emit shiftUp(); 270 emit shiftUp();
266 break; 271 break;
267 default: 272 default:
268 break; 273 break;
269 } 274 }
270} 275}
271 276
272void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 277void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
273{ 278{
274 QListBox::mousePressEvent(e); 279 QListBox::mousePressEvent(e);
275 280
276 if(e->button() == RightButton) { 281 if(e->button() == RightButton) {
277 emit rightClick(); 282 emit rightClick();
278 } 283 }
279} 284}
280 285
281MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) 286MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s)
282 : QListBoxItem() 287 : QListBoxItem()
283{ 288{
284 mblockRepaint = true; 289 mblockRepaint = true;
285 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 290 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
286 recycle( incidence, s ); 291 recycle( incidence, s );
287} 292}
288void MonthViewItem::recycle( Incidence *incidence, const QString & s) 293void MonthViewItem::recycle( Incidence *incidence, const QString & s)
289{ 294{
290 mDisplayHighlighted = false; 295 mDisplayHighlighted = false;
291 setText( s ); 296 setText( s );
292 mMultiday = 0; 297 mMultiday = 0;
293 mIncidence = incidence; 298 mIncidence = incidence;
294 mRecur = false; 299 mRecur = false;
295 mAlarm = false; 300 mAlarm = false;
296 mReply = false; 301 mReply = false;
297 mInfo = false; 302 mInfo = false;
298 mdayPos = 0; 303 mdayPos = 0;
299} 304}
300 305
301bool MonthViewItem::setHighlightedFalse() 306bool MonthViewItem::setHighlightedFalse()
302{ 307{
303 if ( !mDisplayHighlighted ) 308 if ( !mDisplayHighlighted )
304 return false; 309 return false;
305 mDisplayHighlighted = false; 310 mDisplayHighlighted = false;
306 return true; 311 return true;
307} 312}
308 313
309bool MonthViewItem::setHighlighted( Incidence * inc ) 314bool MonthViewItem::setHighlighted( Incidence * inc )
310{ 315{
311 if ( inc == mIncidence ) { 316 if ( inc == mIncidence ) {
312 if ( mDisplayHighlighted ) 317 if ( mDisplayHighlighted )
313 return false; 318 return false;
314 mDisplayHighlighted = true; 319 mDisplayHighlighted = true;
315 return true; 320 return true;
316 } else { 321 } else {
317 if ( !mDisplayHighlighted ) 322 if ( !mDisplayHighlighted )
318 return false; 323 return false;
319 mDisplayHighlighted = false; 324 mDisplayHighlighted = false;
320 return true; 325 return true;
321 } 326 }
322 return false; 327 return false;
323} 328}
324void MonthViewItem::paint(QPainter *p) 329void MonthViewItem::paint(QPainter *p)
325{ 330{
326 if ( mblockRepaint || !mIncidence ) { 331 if ( mblockRepaint || !mIncidence ) {
327 return; 332 return;
328 } 333 }
329#if QT_VERSION >= 0x030000 334#if QT_VERSION >= 0x030000
330 bool sel = isSelected(); 335 bool sel = isSelected();
331#else 336#else
332 bool sel = selected(); 337 bool sel = selected();
333#endif 338#endif
334 int heihei = height( listBox () ); 339 int heihei = height( listBox () );
335 int x = 1; 340 int x = 1;
336 if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) 341 if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel )
337 { 342 {
338 343
339 p->setBackgroundColor( palette().color( QPalette::Normal, \ 344 p->setBackgroundColor( palette().color( QPalette::Normal, \
340 sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); 345 sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) );
341 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); 346 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei );
342 } 347 }
343 348
344 //int y = 3;//(height() - mRecurPixmap.height()) /2; 349 //int y = 3;//(height() - mRecurPixmap.height()) /2;
345 int size = PIXMAP_SIZE; 350 int size = PIXMAP_SIZE;
346 if ( QApplication::desktop()->width() < 300 ) 351 if ( QApplication::desktop()->width() < 300 )
347 size = 3; 352 size = 3;
348 int y = (heihei - size -1 ) /2; 353 int y = (heihei - size -1 ) /2;
349 354
350 if ( mIncidence->calID() > 1 ) { 355 if ( mIncidence->calID() > 1 ) {
351 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); 356 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
352 p->drawRect ( x, y-2,size,size+4); 357 p->drawRect ( x, y-2,size,size+4);
353 x += size + 1; 358 x += size + 1;
354 } 359 }
355 if ( KOPrefs::instance()->mMonthShowIcons ) { 360 if ( KOPrefs::instance()->mMonthShowIcons ) {
356 if ( mInfo ) { 361 if ( mInfo ) {
357 p->fillRect ( x, y,size,size, Qt::darkGreen ); 362 p->fillRect ( x, y,size,size, Qt::darkGreen );
358 x += size + 1; 363 x += size + 1;
359 } 364 }
360 if ( mRecur ) { 365 if ( mRecur ) {
361 p->fillRect ( x, y,size,size, Qt::blue ); 366 p->fillRect ( x, y,size,size, Qt::blue );
362 x += size + 1; 367 x += size + 1;
363 } 368 }
364 if ( mAlarm ) { 369 if ( mAlarm ) {
365 p->fillRect ( x, y,size,size, Qt::red ); 370 p->fillRect ( x, y,size,size, Qt::red );
366 x += size + 1; 371 x += size + 1;
367 } 372 }
368 if ( mReply ) { 373 if ( mReply ) {
369 p->fillRect ( x, y,size,size, Qt::yellow ); 374 p->fillRect ( x, y,size,size, Qt::yellow );
370 x += size + 1; 375 x += size + 1;
371 } 376 }
372 } 377 }
373 378
374 379
375 380
376 381
377 if ( sel ) p->setPen( Qt::white ); 382 if ( sel ) p->setPen( Qt::white );
378 else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); 383 else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) );
379 384
380#if 0 385#if 0
381 p->setPen( palette().color( QPalette::Normal, sel ? \ 386 p->setPen( palette().color( QPalette::Normal, sel ? \
382 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 387 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
383#endif 388#endif
384 QColor textColor = p->pen().color(); 389 QColor textColor = p->pen().color();
385 390
386 391
387 if ( mMultiday ) { 392 if ( mMultiday ) {
388 int yyy = y+(size/2); 393 int yyy = y+(size/2);
389 int sizeM = size+2; 394 int sizeM = size+2;
390 p->setBrush( QBrush( textColor ) ); 395 p->setBrush( QBrush( textColor ) );
391 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 396 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
392 if ( mMultiday == 2 || mMultiday == 3 ) { 397 if ( mMultiday == 2 || mMultiday == 3 ) {
393 QPointArray pa ( 3 ); 398 QPointArray pa ( 3 );
394 pa.setPoint (0, x, yyy ); 399 pa.setPoint (0, x, yyy );
395 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 400 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
396 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 401 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
397 p->drawPolygon( pa ); 402 p->drawPolygon( pa );
398 } 403 }
399 if ( mMultiday == 2 || mMultiday == 1 ) { 404 if ( mMultiday == 2 || mMultiday == 1 ) {
400 QPointArray pa ( 3 ); 405 QPointArray pa ( 3 );
401 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 406 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
402 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 407 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
403 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 408 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
404 p->drawPolygon( pa ); 409 p->drawPolygon( pa );
405 } 410 }
406 if ( mMultiday == 1 ) { 411 if ( mMultiday == 1 ) {
407 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 412 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
408 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 413 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
409 } 414 }
410 if ( mMultiday == 3 ) { 415 if ( mMultiday == 3 ) {
411 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 416 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
412 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 417 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
413 418
414 } 419 }
415 x += sizeM/2 + 1; 420 x += sizeM/2 + 1;
416 x += sizeM + 1; 421 x += sizeM + 1;
417 } 422 }
418 423
419 if ( mIncidence->typeID() == todoID ){ 424 if ( mIncidence->typeID() == todoID ){
420 Todo* td = ( Todo* ) mIncidence; 425 Todo* td = ( Todo* ) mIncidence;
421 if ( td->isCompleted() ) { 426 if ( td->isCompleted() ) {
422 int half = size/2; 427 int half = size/2;
423 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 428 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
424 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 429 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
425 x += half+half + 4; 430 x += half+half + 4;
426 431
427 } else { 432 } else {
428 int val = td->percentComplete()/20; 433 int val = td->percentComplete()/20;
429 p->fillRect ( x+1, y-2, val ,size+4,textColor ); 434 p->fillRect ( x+1, y-2, val ,size+4,textColor );
430 p->drawRect ( x, y-2,7,size+4); 435 p->drawRect ( x, y-2,7,size+4);
431 x += size + 3; 436 x += size + 3;
432 } 437 }
433 } 438 }
434 QFontMetrics fm = p->fontMetrics(); 439 QFontMetrics fm = p->fontMetrics();
435 int yPos; 440 int yPos;
436 int pmheight = size; 441 int pmheight = size;
437 if( pmheight < fm.height() ) 442 if( pmheight < fm.height() )
438 yPos = fm.ascent() + fm.leading()/2; 443 yPos = fm.ascent() + fm.leading()/2;
439 else 444 else
440 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 445 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
441 446
442 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 447 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
443 p->drawText( x, yPos, text() ); 448 p->drawText( x, yPos, text() );
444 if ( mIncidence->cancelled() ) { 449 if ( mIncidence->cancelled() ) {
445 int wid = fm.width( text() ); 450 int wid = fm.width( text() );
446 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 451 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
447 } 452 }
448 } else { 453 } else {
449 QString pText = text(); 454 QString pText = text();
450 if( pText.mid(2,1) == ":" ) 455 if( pText.mid(2,1) == ":" )
451 pText = pText.mid( 6 ); 456 pText = pText.mid( 6 );
452 p->drawText( x, yPos, pText ); 457 p->drawText( x, yPos, pText );
453 if ( mIncidence->cancelled() ) { 458 if ( mIncidence->cancelled() ) {
454 int wid = fm.width( pText ); 459 int wid = fm.width( pText );
455 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 460 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
456 } 461 }
457 } 462 }
458} 463}
459 464
460int MonthViewItem::height(const QListBox *lb) const 465int MonthViewItem::height(const QListBox *lb) const
461{ 466{
462 int ret = 10; 467 int ret = 10;
463 if ( lb ) 468 if ( lb )
464 ret = lb->fontMetrics().lineSpacing()+1; 469 ret = lb->fontMetrics().lineSpacing()+1;
465 return ret; 470 return ret;
466} 471}
467 472
468int MonthViewItem::width(const QListBox *lb) const 473int MonthViewItem::width(const QListBox *lb) const
469{ 474{
470 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 475 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
471 int size = PIXMAP_SIZE; 476 int size = PIXMAP_SIZE;
472 if ( QApplication::desktop()->width() < 300 ) 477 if ( QApplication::desktop()->width() < 300 )
473 size = 3; 478 size = 3;
474 int x = 1; 479 int x = 1;
475 if ( KOPrefs::instance()->mMonthShowIcons ) { 480 if ( KOPrefs::instance()->mMonthShowIcons ) {
476 if ( mInfo ) { 481 if ( mInfo ) {
477 x += size + 1; 482 x += size + 1;
478 } 483 }
479 if( mRecur ) { 484 if( mRecur ) {
480 x += size+1; 485 x += size+1;
481 } 486 }
482 if( mAlarm ) { 487 if( mAlarm ) {
483 x += size+1; 488 x += size+1;
484 } 489 }
485 if( mReply ) { 490 if( mReply ) {
486 x += size+1; 491 x += size+1;
487 } 492 }
488 } 493 }
489 if( mMultiday ) { 494 if( mMultiday ) {
490 x += size+1+2+size/2; 495 x += size+1+2+size/2;
491 } 496 }
492 return( x + lb->fontMetrics().width( text() ) + 1 ); 497 return( x + lb->fontMetrics().width( text() ) + 1 );
493 } 498 }
494 if ( ! lb ) 499 if ( ! lb )
495 return 10; 500 return 10;
496 return lb->width(); 501 return lb->width();
497} 502}
498 503
499 504
500MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 505MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
501 : KNoScrollListBox( par ), 506 : KNoScrollListBox( par ),
502 mMonthView( parent ) 507 mMonthView( parent )
503{ 508{
504 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 509 //QVBoxLayout *topLayout = new QVBoxLayout( this );
505 currentPalette = 0; 510 currentPalette = 0;
506 // mLabel = new QLabel( this );QPushButton 511 // mLabel = new QLabel( this );QPushButton
507 mLabel = new QPushButton( this ); 512 mLabel = new QPushButton( this );
508 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 513 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
509 //mLabel->setLineWidth( 1 ); 514 //mLabel->setLineWidth( 1 );
510 //mLabel->setAlignment( AlignCenter ); 515 //mLabel->setAlignment( AlignCenter );
511 mLabel->setFlat( true ); 516 mLabel->setFlat( true );
512 mLabel->setFocusPolicy(NoFocus); 517 mLabel->setFocusPolicy(NoFocus);
513 //mItemList = new KNoScrollListBox( this ); 518 //mItemList = new KNoScrollListBox( this );
514 setMinimumSize( 10, 10 ); 519 setMinimumSize( 10, 10 );
515 setFrameStyle( QFrame::Panel | QFrame::Plain ); 520 setFrameStyle( QFrame::Panel | QFrame::Plain );
516 setLineWidth( 1 ); 521 setLineWidth( 1 );
517 //topLayout->addWidget( mItemList ); 522 //topLayout->addWidget( mItemList );
518 mLabel->raise(); 523 mLabel->raise();
519 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 524 // QColor( 0,0,255 ) QColor( 160,1600,255 )
520 mStandardPalette = palette(); 525 mStandardPalette = palette();
521 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 526 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
522 527
523 enableScrollBars( false ); 528 enableScrollBars( false );
524 updateConfig(); 529 updateConfig();
525 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 530 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
526 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 531 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
527 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 532 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
528 SLOT( defaultAction( QListBoxItem * ) ) ); 533 SLOT( defaultAction( QListBoxItem * ) ) );
529 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 534 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
@@ -729,771 +734,770 @@ int MonthViewCell::insertEvent(Event *event)
729 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 734 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
730 else if ( mDate == event->dtEnd().date () ) 735 else if ( mDate == event->dtEnd().date () )
731 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 736 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
732 737
733 } 738 }
734 text = time + event->summary(); 739 text = time + event->summary();
735 if ( useToolTips ) 740 if ( useToolTips )
736 mToolTipText += prefix + text; 741 mToolTipText += prefix + text;
737 } else { 742 } else {
738 if (event->doesFloat()) { 743 if (event->doesFloat()) {
739 text = event->summary(); 744 text = event->summary();
740 if ( useToolTips ) 745 if ( useToolTips )
741 mToolTipText += text; 746 mToolTipText += text;
742 } 747 }
743 else { 748 else {
744 text = KGlobal::locale()->formatTime(event->dtStart().time()); 749 text = KGlobal::locale()->formatTime(event->dtStart().time());
745 text += " " + event->summary(); 750 text += " " + event->summary();
746 if ( useToolTips ) 751 if ( useToolTips )
747 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 752 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
748 } 753 }
749 } 754 }
750 if ( useToolTips && ! event->location().isEmpty() ) { 755 if ( useToolTips && ! event->location().isEmpty() ) {
751 mToolTipText += " (" + event->location() +")"; 756 mToolTipText += " (" + event->location() +")";
752 } 757 }
753 MonthViewItem *item ; 758 MonthViewItem *item ;
754 759
755 if ( mAvailItemList.count() ) { 760 if ( mAvailItemList.count() ) {
756 item = mAvailItemList.first(); 761 item = mAvailItemList.first();
757 mAvailItemList.remove( item ); 762 mAvailItemList.remove( item );
758 item->recycle( event, text ); 763 item->recycle( event, text );
759 } else { 764 } else {
760 item = new MonthViewItem( event, text ); 765 item = new MonthViewItem( event, text );
761 } 766 }
762 767
763 QPalette pal; 768 QPalette pal;
764 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 769 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
765 QStringList categories = event->categories(); 770 QStringList categories = event->categories();
766 QString cat = categories.first(); 771 QString cat = categories.first();
767 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 772 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
768 pal = getPalette(); 773 pal = getPalette();
769 if (cat.isEmpty()) { 774 if (cat.isEmpty()) {
770 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 775 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
771 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); 776 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() ));
772 } else { 777 } else {
773 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 778 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
774 } 779 }
775 780
776 } else { 781 } else {
777 if (cat.isEmpty()) { 782 if (cat.isEmpty()) {
778 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 783 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
779 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); 784 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() ));
780 } else { 785 } else {
781 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 786 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
782 } 787 }
783 } 788 }
784 789
785 } else { 790 } else {
786 pal = mStandardPalette ; 791 pal = mStandardPalette ;
787 } 792 }
788 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); 793 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor);
789 item->setPalette( pal ); 794 item->setPalette( pal );
790 item->setRecur( event->doesRecur() ); 795 item->setRecur( event->doesRecur() );
791 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); 796 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() );
792 item->setMoreInfo( event->description().length() > 0 ); 797 item->setMoreInfo( event->description().length() > 0 );
793#ifdef DESKTOP_VERSION 798#ifdef DESKTOP_VERSION
794 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 799 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
795 KOPrefs::instance()->email()); 800 KOPrefs::instance()->email());
796 if ( me != 0 ) { 801 if ( me != 0 ) {
797 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 802 if ( me->status() == Attendee::NeedsAction && me->RSVP())
798 item->setReply(true && multiday < 2); 803 item->setReply(true && multiday < 2);
799 else 804 else
800 item->setReply(false); 805 item->setReply(false);
801 } else 806 } else
802 item->setReply(false); 807 item->setReply(false);
803#endif 808#endif
804 809
805 item->setMultiDay( multiday ); 810 item->setMultiDay( multiday );
806 if ( multiday ) { 811 if ( multiday ) {
807 insertItem( item ,mdayCount); 812 insertItem( item ,mdayCount);
808 ++mdayCount; 813 ++mdayCount;
809 } else { 814 } else {
810 uint i = mdayCount; 815 uint i = mdayCount;
811 uint pos = mdayCount; 816 uint pos = mdayCount;
812 uint itcount = count(); 817 uint itcount = count();
813 if ( itcount > 1000 ) { 818 if ( itcount > 1000 ) {
814 qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); 819 qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount);
815 itcount = 0; 820 itcount = 0;
816 } 821 }
817 for ( i = pos; i < itcount;++i ) { 822 for ( i = pos; i < itcount;++i ) {
818 // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); 823 // qDebug("i %d mday %u count %d ",i,itcount,mdayCount );
819 QListBoxItem* it = this->item ( i ); 824 QListBoxItem* it = this->item ( i );
820 if ( it && text < it->text() ) { 825 if ( it && text < it->text() ) {
821 pos = i; 826 pos = i;
822 break; 827 break;
823 } 828 }
824 ++pos; 829 ++pos;
825 } 830 }
826 insertItem( item ,pos); 831 insertItem( item ,pos);
827 } 832 }
828 if ( useToolTips ) { 833 if ( useToolTips ) {
829 mToolTip.append( mToolTipText ); 834 mToolTip.append( mToolTipText );
830 } 835 }
831 return mdayCount; 836 return mdayCount;
832} 837}
833void MonthViewCell::insertTodo(Todo *todo) 838void MonthViewCell::insertTodo(Todo *todo)
834{ 839{
835 setFocusPolicy(WheelFocus); 840 setFocusPolicy(WheelFocus);
836 QString text; 841 QString text;
837 if (todo->hasDueDate()) { 842 if (todo->hasDueDate()) {
838 if (!todo->doesFloat()) { 843 if (!todo->doesFloat()) {
839 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 844 text += KGlobal::locale()->formatTime(todo->dtDue().time());
840 text += " "; 845 text += " ";
841 } 846 }
842 } 847 }
843 text += todo->summary(); 848 text += todo->summary();
844 MonthViewItem *item ; 849 MonthViewItem *item ;
845 if ( mAvailItemList.count() ) { 850 if ( mAvailItemList.count() ) {
846 item = mAvailItemList.first(); 851 item = mAvailItemList.first();
847 mAvailItemList.remove( item ); 852 mAvailItemList.remove( item );
848 item->recycle( todo, text ); 853 item->recycle( todo, text );
849 } else { 854 } else {
850 item = new MonthViewItem( todo, text ); 855 item = new MonthViewItem( todo, text );
851 } 856 }
852 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 857 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
853 //item->setPalette( mStandardPalette ); 858 //item->setPalette( mStandardPalette );
854 QPalette pal; 859 QPalette pal;
855 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 860 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
856 QStringList categories = todo->categories(); 861 QStringList categories = todo->categories();
857 QString cat = categories.first(); 862 QString cat = categories.first();
858 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 863 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
859 pal = getPalette(); 864 pal = getPalette();
860 if (cat.isEmpty()) { 865 if (cat.isEmpty()) {
861 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 866 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
862 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); 867 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() ));
863 } else { 868 } else {
864 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 869 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
865 } 870 }
866 871
867 } else { 872 } else {
868 if (cat.isEmpty()) { 873 if (cat.isEmpty()) {
869 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 874 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
870 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); 875 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() ));
871 } else { 876 } else {
872 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 877 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
873 } 878 }
874 } 879 }
875 880
876 } else { 881 } else {
877 pal = mStandardPalette ; 882 pal = mStandardPalette ;
878 } 883 }
879 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); 884 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor);
880 item->setPalette( pal ); 885 item->setPalette( pal );
881 item->setRecur( todo->doesRecur() ); 886 item->setRecur( todo->doesRecur() );
882 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); 887 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() );
883 item->setMoreInfo( todo->description().length() > 0 ); 888 item->setMoreInfo( todo->description().length() > 0 );
884 insertItem( item , count()); 889 insertItem( item , count());
885#ifdef DESKTOP_VERSION 890#ifdef DESKTOP_VERSION
886 mToolTip.append( text ); 891 mToolTip.append( text );
887#endif 892#endif
888} 893}
889void MonthViewCell::repaintfinishUpdateCell() 894void MonthViewCell::repaintfinishUpdateCell()
890{ 895{
891 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 896 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
892 while ( mitem ) { 897 while ( mitem ) {
893 mitem->setBlockRepaint( false ); 898 mitem->setBlockRepaint( false );
894 updateItem ( mitem ); 899 updateItem ( mitem );
895 mitem = (MonthViewItem *)mitem->next(); 900 mitem = (MonthViewItem *)mitem->next();
896 } 901 }
897 blockSignals( false ); 902 blockSignals( false );
898} 903}
899void MonthViewCell::finishUpdateCell() 904void MonthViewCell::finishUpdateCell()
900{ 905{
901 906
902 907
903 908
904#ifdef DESKTOP_VERSION 909#ifdef DESKTOP_VERSION
905 if (mToolTip.count() > 0 ) { 910 if (mToolTip.count() > 0 ) {
906 mToolTip.sort(); 911 mToolTip.sort();
907 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 912 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
908 } 913 }
909#endif 914#endif
910 //sort(); 915 //sort();
911 //setMyPalette(); 916 //setMyPalette();
912 setMyPalette(); 917 setMyPalette();
913 918
914 resizeEvent( 0 ); 919 resizeEvent( 0 );
915 920
916} 921}
917void MonthViewCell::updateCell() 922void MonthViewCell::updateCell()
918{ 923{
919 if ( !mMonthView->isUpdatePossible() ) 924 if ( !mMonthView->isUpdatePossible() )
920 return; 925 return;
921 startUpdateCell(); 926 startUpdateCell();
922 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 927 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
923 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 928 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
924 Event *event; 929 Event *event;
925 for( event = events.first(); event; event = events.next() ) { // for event 930 for( event = events.first(); event; event = events.next() ) { // for event
926 insertEvent(event); 931 insertEvent(event);
927 } 932 }
928 // insert due todos 933 // insert due todos
929 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 934 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
930 Todo *todo; 935 Todo *todo;
931 for(todo = todos.first(); todo; todo = todos.next()) { 936 for(todo = todos.first(); todo; todo = todos.next()) {
932 insertTodo( todo ); 937 insertTodo( todo );
933 } 938 }
934 finishUpdateCell(); 939 finishUpdateCell();
935 // if ( isVisible()) 940 // if ( isVisible())
936 //qApp->processEvents(); 941 //qApp->processEvents();
937} 942}
938 943
939void MonthViewCell::updateConfig( bool bigFont ) // = false 944void MonthViewCell::updateConfig( bool bigFont ) // = false
940{ 945{
941 946
942 if ( bigFont ) { 947 if ( bigFont ) {
943 QFont fo = KOPrefs::instance()->mMonthViewFont; 948 QFont fo = KOPrefs::instance()->mMonthViewFont;
944 int ps = fo.pointSize() + 2; 949 int ps = fo.pointSize() + 2;
945 if ( ps < 18 ) 950 if ( ps < 18 )
946 ps += 2; 951 ps += 2;
947 fo.setPointSize( ps ); 952 fo.setPointSize( ps );
948 setFont( fo ); 953 setFont( fo );
949 } else 954 } else
950 setFont( KOPrefs::instance()->mMonthViewFont ); 955 setFont( KOPrefs::instance()->mMonthViewFont );
951 956
952 QFontMetrics fm( font() ); 957 QFontMetrics fm( font() );
953 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 958 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
954 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 959 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
955 mHolidayPalette = mStandardPalette; 960 mHolidayPalette = mStandardPalette;
956 mPrimaryPalette = mStandardPalette; 961 mPrimaryPalette = mStandardPalette;
957 mNonPrimaryPalette = mStandardPalette; 962 mNonPrimaryPalette = mStandardPalette;
958 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 963 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
959 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 964 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
960 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 965 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
961 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 966 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
962 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 967 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
963 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 968 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
964 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 969 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
965 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 970 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
966 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 971 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
967 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 972 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
968 } 973 }
969 //updateCell(); 974 //updateCell();
970} 975}
971 976
972void MonthViewCell::enableScrollBars( bool enabled ) 977void MonthViewCell::enableScrollBars( bool enabled )
973{ 978{
974 979
975 return; 980 return;
976 if ( enabled ) { 981 if ( enabled ) {
977 QListBoxItem *fi = firstItem (); 982 QListBoxItem *fi = firstItem ();
978 if (fi ) { 983 if (fi ) {
979 int ihei = fi->height( this ); 984 int ihei = fi->height( this );
980 int hei = numRows () * ihei; 985 int hei = numRows () * ihei;
981 if ( hei < height() - horizontalScrollBar()->height () ) { 986 if ( hei < height() - horizontalScrollBar()->height () ) {
982 setVScrollBarMode(QScrollView::AlwaysOff); 987 setVScrollBarMode(QScrollView::AlwaysOff);
983 } 988 }
984 else 989 else
985 setVScrollBarMode(QScrollView::Auto); 990 setVScrollBarMode(QScrollView::Auto);
986 if ( ihei *3 > height() ) { 991 if ( ihei *3 > height() ) {
987 setHScrollBarMode(QScrollView::AlwaysOff); 992 setHScrollBarMode(QScrollView::AlwaysOff);
988 } 993 }
989 else { 994 else {
990 setHScrollBarMode(QScrollView::Auto); 995 setHScrollBarMode(QScrollView::Auto);
991 } 996 }
992 } else { 997 } else {
993 setVScrollBarMode(QScrollView::Auto); 998 setVScrollBarMode(QScrollView::Auto);
994 setHScrollBarMode(QScrollView::Auto); 999 setHScrollBarMode(QScrollView::Auto);
995 } 1000 }
996 } else { 1001 } else {
997 setVScrollBarMode(QScrollView::AlwaysOff); 1002 setVScrollBarMode(QScrollView::AlwaysOff);
998 setHScrollBarMode(QScrollView::AlwaysOff); 1003 setHScrollBarMode(QScrollView::AlwaysOff);
999 } 1004 }
1000} 1005}
1001 1006
1002Incidence *MonthViewCell::selectedIncidence() 1007Incidence *MonthViewCell::selectedIncidence()
1003{ 1008{
1004 int index = currentItem(); 1009 int index = currentItem();
1005 if ( index < 0 ) return 0; 1010 if ( index < 0 ) return 0;
1006 1011
1007 MonthViewItem *mitem = 1012 MonthViewItem *mitem =
1008 static_cast<MonthViewItem *>( item( index ) ); 1013 static_cast<MonthViewItem *>( item( index ) );
1009 1014
1010 if ( !mitem ) return 0; 1015 if ( !mitem ) return 0;
1011 1016
1012 return mitem->incidence(); 1017 return mitem->incidence();
1013} 1018}
1014 1019
1015QDate MonthViewCell::selectedIncidenceDate() 1020QDate MonthViewCell::selectedIncidenceDate()
1016{ 1021{
1017 QDate qd; 1022 QDate qd;
1018 int index = currentItem(); 1023 int index = currentItem();
1019 if ( index < 0 ) return qd; 1024 if ( index < 0 ) return qd;
1020 return mDate; 1025 return mDate;
1021} 1026}
1022 1027
1023void MonthViewCell::deselect() 1028void MonthViewCell::deselect()
1024{ 1029{
1025 clearSelection(); 1030 clearSelection();
1026 enableScrollBars( false ); 1031 enableScrollBars( false );
1027 // updateCell(); 1032 // updateCell();
1028} 1033}
1029void MonthViewCell::select() 1034void MonthViewCell::select()
1030{ 1035{
1031 ;// updateCell(); 1036 ;// updateCell();
1032} 1037}
1033 1038
1034void MonthViewCell::resizeEvent ( QResizeEvent * e ) 1039void MonthViewCell::resizeEvent ( QResizeEvent * e )
1035{ 1040{
1036 if ( !mMonthView->isUpdatePossible() ) 1041 if ( !mMonthView->isUpdatePossible() )
1037 return; 1042 return;
1038 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 1043 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
1039 deselect(); 1044 deselect();
1040 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 1045 mLabel->setMaximumHeight( height() - lineWidth()*2 );
1041 1046
1042 QString text; 1047 QString text;
1043 //mLabel->setText( text ); 1048 //mLabel->setText( text );
1044 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 1049 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1045 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 1050 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
1046 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); 1051 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() );
1047 mLabel->resize( mLabelBigSize ); 1052 mLabel->resize( mLabelBigSize );
1048 } else { 1053 } else {
1049 mLabel->resize( mLabelSize ); 1054 mLabel->resize( mLabelSize );
1050 text = QString::number( mDate.day() ); 1055 text = QString::number( mDate.day() );
1051 } 1056 }
1052 mLabel->setText( text ); 1057 mLabel->setText( text );
1053 1058
1054 int size = height() - mLabel->height() - lineWidth()-1; 1059 int size = height() - mLabel->height() - lineWidth()-1;
1055 //qDebug("LW %d ", lineWidth()); 1060 //qDebug("LW %d ", lineWidth());
1056 if ( size > 0 ) 1061 if ( size > 0 )
1057 verticalScrollBar()->setMaximumHeight( size ); 1062 verticalScrollBar()->setMaximumHeight( size );
1058 size = width() - mLabel->width() -lineWidth()-1; 1063 size = width() - mLabel->width() -lineWidth()-1;
1059 if ( size > 0 ) 1064 if ( size > 0 )
1060 horizontalScrollBar()->setMaximumWidth( size ); 1065 horizontalScrollBar()->setMaximumWidth( size );
1061 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1066 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1062 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1067 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1063 // mItemList->resize ( width(), height () ); 1068 // mItemList->resize ( width(), height () );
1064 if ( e ) 1069 if ( e )
1065 KNoScrollListBox::resizeEvent ( e ); 1070 KNoScrollListBox::resizeEvent ( e );
1066} 1071}
1067 1072
1068void MonthViewCell::defaultAction( QListBoxItem *item ) 1073void MonthViewCell::defaultAction( QListBoxItem *item )
1069{ 1074{
1070 1075
1071 if ( !item ) { 1076 if ( !item ) {
1072 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1077 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1073 emit newEventSignal( dt ); 1078 emit newEventSignal( dt );
1074 return; 1079 return;
1075 } 1080 }
1076 1081
1077 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1082 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1078 Incidence *incidence = eventItem->incidence(); 1083 Incidence *incidence = eventItem->incidence();
1079 if ( incidence ) mMonthView->defaultAction( incidence ); 1084 if ( incidence ) mMonthView->defaultAction( incidence );
1080} 1085}
1081void MonthViewCell::showDay() 1086void MonthViewCell::showDay()
1082{ 1087{
1083 emit showDaySignal( date() ); 1088 emit showDaySignal( date() );
1084} 1089}
1085void MonthViewCell::newEvent() 1090void MonthViewCell::newEvent()
1086{ 1091{
1087 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1092 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1088 emit newEventSignal( dt ); 1093 emit newEventSignal( dt );
1089} 1094}
1090void MonthViewCell::cellClicked( QListBoxItem *item ) 1095void MonthViewCell::cellClicked( QListBoxItem *item )
1091{ 1096{
1092 mMonthView->setSelectedCell( this ); 1097 mMonthView->setSelectedCell( this );
1093 if ( item == 0 ) { 1098 if ( item == 0 ) {
1094 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1099 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1095 emit newEventSignal( dt ); 1100 emit newEventSignal( dt );
1096 return; 1101 return;
1097 } 1102 }
1098 1103
1099} 1104}
1100 1105
1101void MonthViewCell::contextMenu( QListBoxItem *item ) 1106void MonthViewCell::contextMenu( QListBoxItem *item )
1102{ 1107{
1103 mMonthView->setPopupCell( this ); 1108 mMonthView->setPopupCell( this );
1104 if ( !item ) { 1109 if ( !item ) {
1105 mMonthView->showContextMenu( 0 ); 1110 mMonthView->showContextMenu( 0 );
1106 return; 1111 return;
1107 } 1112 }
1108 //selection( item ); 1113 //selection( item );
1109 //qApp->processEvents(); 1114 //qApp->processEvents();
1110 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1115 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1111 Incidence *incidence = eventItem->incidence(); 1116 Incidence *incidence = eventItem->incidence();
1112 if ( incidence ) { 1117 if ( incidence ) {
1118 mBlockDeselect = true;
1113 mMonthView->showContextMenu( incidence ); 1119 mMonthView->showContextMenu( incidence );
1114 selection( item );
1115 doHighLight( incidence );
1116 } 1120 }
1117} 1121}
1118 1122
1119void MonthViewCell::selection( QListBoxItem *item ) 1123void MonthViewCell::selection( QListBoxItem *item )
1120{ 1124{
1121 if ( !item ) { 1125 if ( !item ) {
1122 emit highlightIncidence( 0 , this, 0 ); 1126 emit highlightIncidence( 0 , this, 0 );
1123 return; 1127 return;
1124 } 1128 }
1125 MonthViewItem * it = (static_cast<MonthViewItem *>( item )); 1129 MonthViewItem * it = (static_cast<MonthViewItem *>( item ));
1126 emit highlightIncidence( it->incidence(), this, it->multiDay() ); 1130 emit highlightIncidence( it->incidence(), this, it->multiDay() );
1127 mMonthView->setSelectedCell( this ); 1131 mMonthView->setSelectedCell( this );
1128} 1132}
1129 1133
1130void MonthViewCell::deHighLight() 1134void MonthViewCell::deHighLight()
1131{ 1135{
1132 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 1136 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
1133 while ( mitem ) { 1137 while ( mitem ) {
1134 if ( mitem->setHighlightedFalse() ) 1138 if ( mitem->setHighlightedFalse() )
1135 updateItem ( mitem ); 1139 updateItem ( mitem );
1136 mitem = (MonthViewItem *)mitem->next(); 1140 mitem = (MonthViewItem *)mitem->next();
1137 } 1141 }
1138} 1142}
1139// returns true if no inc found 1143// returns true if no inc found
1140bool MonthViewCell::doHighLight( Incidence * inc ) 1144bool MonthViewCell::doHighLight( Incidence * inc )
1141{ 1145{
1142 1146
1143 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 1147 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
1144 while ( mitem ) { 1148 while ( mitem ) {
1145 if ( mitem->incidence() == inc ) { 1149 if ( mitem->incidence() == inc ) {
1146 if ( mitem->setHighlighted( inc ) ) 1150 if ( mitem->setHighlighted( inc ) )
1147 updateItem ( mitem ); 1151 updateItem ( mitem );
1148 return false; 1152 return false;
1149 } 1153 }
1150 mitem = (MonthViewItem *)mitem->next(); 1154 mitem = (MonthViewItem *)mitem->next();
1151 } 1155 }
1152 return true; 1156 return true;
1153} 1157}
1154// ******************************************************************************* 1158// *******************************************************************************
1155// ******************************************************************************* 1159// *******************************************************************************
1156// ******************************************************************************* 1160// *******************************************************************************
1157 1161
1158 1162
1159KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1163KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1160 : KOEventView( calendar, parent, name ), 1164 : KOEventView( calendar, parent, name ),
1161 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1165 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1162 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1166 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1163{ 1167{
1164 mFlagKeyPressed = false; 1168 mFlagKeyPressed = false;
1165 mShortDayLabelsM = false; 1169 mShortDayLabelsM = false;
1166 mShortDayLabelsW = false; 1170 mShortDayLabelsW = false;
1167 skipResize = false; 1171 skipResize = false;
1168 clPending = true; 1172 clPending = true;
1169 mPopupCell = 0; 1173 mPopupCell = 0;
1170 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1174 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1171 mWidStack = new QWidgetStack( this ); 1175 mWidStack = new QWidgetStack( this );
1172 QVBoxLayout* hb = new QVBoxLayout( this ); 1176 QVBoxLayout* hb = new QVBoxLayout( this );
1173 mMonthView = new QWidget( mWidStack ); 1177 mMonthView = new QWidget( mWidStack );
1174 mWeekView = new QWidget( mWidStack ); 1178 mWeekView = new QWidget( mWidStack );
1175#if QT_VERSION >= 0x030000 1179#if QT_VERSION >= 0x030000
1176 mWidStack->addWidget(mMonthView ); 1180 mWidStack->addWidget(mMonthView );
1177 mWidStack->addWidget(mWeekView ); 1181 mWidStack->addWidget(mWeekView );
1178#else 1182#else
1179 mWidStack->addWidget( mMonthView, 1 ); 1183 mWidStack->addWidget( mMonthView, 1 );
1180 mWidStack->addWidget( mWeekView , 1 ); 1184 mWidStack->addWidget( mWeekView , 1 );
1181#endif 1185#endif
1182 hb->addWidget( mNavigatorBar ); 1186 hb->addWidget( mNavigatorBar );
1183 hb->addWidget( mWidStack ); 1187 hb->addWidget( mWidStack );
1184 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1188 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1185 updatePossible = false; 1189 updatePossible = false;
1186 //updatePossible = true; 1190 //updatePossible = true;
1187 mCells.setAutoDelete( true ); 1191 mCells.setAutoDelete( true );
1188 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1192 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1189 mDayLabels.resize( mDaysPerWeek ); 1193 mDayLabels.resize( mDaysPerWeek );
1190 mDayLabelsW.resize( mDaysPerWeek ); 1194 mDayLabelsW.resize( mDaysPerWeek );
1191 QFont bfont = font(); 1195 QFont bfont = font();
1192 if ( QApplication::desktop()->width() < 650 ) { 1196 if ( QApplication::desktop()->width() < 650 ) {
1193 bfont.setPointSize( bfont.pointSize() - 2 ); 1197 bfont.setPointSize( bfont.pointSize() - 2 );
1194 } 1198 }
1195 bfont.setBold( true ); 1199 bfont.setBold( true );
1196 int i; 1200 int i;
1197 1201
1198 for( i = 0; i < mDaysPerWeek; i++ ) { 1202 for( i = 0; i < mDaysPerWeek; i++ ) {
1199 QLabel *label = new QLabel( mMonthView ); 1203 QLabel *label = new QLabel( mMonthView );
1200 label->setFont(bfont); 1204 label->setFont(bfont);
1201 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1205 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1202 label->setLineWidth(1); 1206 label->setLineWidth(1);
1203 label->setAlignment(AlignCenter); 1207 label->setAlignment(AlignCenter);
1204 mDayLabels.insert( i, label ); 1208 mDayLabels.insert( i, label );
1205 label = new QLabel( mWeekView ); 1209 label = new QLabel( mWeekView );
1206 label->setFont(bfont); 1210 label->setFont(bfont);
1207 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1211 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1208 label->setLineWidth(1); 1212 label->setLineWidth(1);
1209 label->setAlignment(AlignCenter); 1213 label->setAlignment(AlignCenter);
1210 mDayLabelsW.insert( i, label ); 1214 mDayLabelsW.insert( i, label );
1211 } 1215 }
1212 1216
1213 bfont.setBold( false ); 1217 bfont.setBold( false );
1214 mWeekLabels.resize( mNumWeeks+1 ); 1218 mWeekLabels.resize( mNumWeeks+1 );
1215 mWeekLabelsW.resize( 2 ); 1219 mWeekLabelsW.resize( 2 );
1216 for( i = 0; i < mNumWeeks+1; i++ ) { 1220 for( i = 0; i < mNumWeeks+1; i++ ) {
1217 KOWeekButton *label = new KOWeekButton( mMonthView ); 1221 KOWeekButton *label = new KOWeekButton( mMonthView );
1218 label->setFocusPolicy(NoFocus); 1222 label->setFocusPolicy(NoFocus);
1219 label->setFont(bfont); 1223 label->setFont(bfont);
1220 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1224 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1221 label->setFlat(true); 1225 label->setFlat(true);
1222 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1226 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1223 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1227 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1224 //label->setLineWidth(1); 1228 //label->setLineWidth(1);
1225 //label->setAlignment(AlignCenter); 1229 //label->setAlignment(AlignCenter);
1226 mWeekLabels.insert( i, label ); 1230 mWeekLabels.insert( i, label );
1227 } 1231 }
1228 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1232 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1229 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1233 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1230 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1234 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1231 1235
1232 for( i = 0; i < 1+1; i++ ) { 1236 for( i = 0; i < 1+1; i++ ) {
1233 KOWeekButton *label = new KOWeekButton( mWeekView ); 1237 KOWeekButton *label = new KOWeekButton( mWeekView );
1234 label->setFocusPolicy(NoFocus); 1238 label->setFocusPolicy(NoFocus);
1235 label->setFont(bfont); 1239 label->setFont(bfont);
1236 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1240 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1237 label->setFlat(true); 1241 label->setFlat(true);
1238 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1242 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1239 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1243 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1240 //label->setLineWidth(1); 1244 //label->setLineWidth(1);
1241 //label->setAlignment(AlignCenter); 1245 //label->setAlignment(AlignCenter);
1242 mWeekLabelsW.insert( i, label ); 1246 mWeekLabelsW.insert( i, label );
1243 } 1247 }
1244 mWeekLabelsW[1]->setText( i18n("W")); 1248 mWeekLabelsW[1]->setText( i18n("W"));
1245 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1249 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1246 1250
1247 1251
1248 int row, col; 1252 int row, col;
1249 mCells.resize( mNumCells ); 1253 mCells.resize( mNumCells );
1250 for( row = 0; row < mNumWeeks; ++row ) { 1254 for( row = 0; row < mNumWeeks; ++row ) {
1251 for( col = 0; col < mDaysPerWeek; ++col ) { 1255 for( col = 0; col < mDaysPerWeek; ++col ) {
1252 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1256 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1253 mCells.insert( row * mDaysPerWeek + col, cell ); 1257 mCells.insert( row * mDaysPerWeek + col, cell );
1254 1258
1255 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1259 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1256 SLOT( defaultAction( Incidence * ) ) ); 1260 SLOT( defaultAction( Incidence * ) ) );
1257 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1261 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1258 SIGNAL( newEventSignal( QDateTime ) ) ); 1262 SIGNAL( newEventSignal( QDateTime ) ) );
1259 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1263 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1260 SIGNAL( showDaySignal( QDate ) ) ); 1264 SIGNAL( showDaySignal( QDate ) ) );
1261 connect( cell, SIGNAL( nextCell() ), 1265 connect( cell, SIGNAL( nextCell() ),
1262 SLOT( nextCell() ) ); 1266 SLOT( nextCell() ) );
1263 connect( cell, SIGNAL( prevCell() ), 1267 connect( cell, SIGNAL( prevCell() ),
1264 SLOT( prevCell() ) ); 1268 SLOT( prevCell() ) );
1265 connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), 1269 connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ),
1266 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); 1270 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
1267 } 1271 }
1268 } 1272 }
1269 mCellsW.resize( mDaysPerWeek ); 1273 mCellsW.resize( mDaysPerWeek );
1270 for( col = 0; col < mDaysPerWeek; ++col ) { 1274 for( col = 0; col < mDaysPerWeek; ++col ) {
1271 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1275 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1272 mCellsW.insert( col, cell ); 1276 mCellsW.insert( col, cell );
1273 1277
1274 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1278 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1275 SLOT( defaultAction( Incidence * ) ) ); 1279 SLOT( defaultAction( Incidence * ) ) );
1276 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1280 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1277 SIGNAL( newEventSignal( QDateTime ) ) ); 1281 SIGNAL( newEventSignal( QDateTime ) ) );
1278 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1282 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1279 SIGNAL( showDaySignal( QDate ) ) ); 1283 SIGNAL( showDaySignal( QDate ) ) );
1280 connect( cell, SIGNAL( nextCell() ), 1284 connect( cell, SIGNAL( nextCell() ),
1281 SLOT( nextCell() ) ); 1285 SLOT( nextCell() ) );
1282 connect( cell, SIGNAL( prevCell() ), 1286 connect( cell, SIGNAL( prevCell() ),
1283 SLOT( prevCell() ) ); 1287 SLOT( prevCell() ) );
1284 connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), 1288 connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ),
1285 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); 1289 SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
1286 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1290 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1287 } 1291 }
1288 1292
1289 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1293 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1290 mContextMenu = eventPopup(); 1294 mContextMenu = eventPopup();
1291 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1295 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1292 i18n("New Event..."),this, 1296 i18n("New Event..."),this,
1293 SLOT(slotNewEvent()),false); 1297 SLOT(slotNewEvent()),false);
1294 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1298 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1295 i18n("New Todo..."),this, 1299 i18n("New Todo..."),this,
1296 SLOT(slotNewTodo()),false); 1300 SLOT(slotNewTodo()),false);
1297 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1301 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1298 i18n("Journal"),this, 1302 i18n("Journal"),this,
1299 SLOT(slotEditJournal()),false); 1303 SLOT(slotEditJournal()),false);
1300 1304
1301 connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, 1305 connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this,
1302 SLOT( catChanged( Incidence * ) )); 1306 SLOT( catChanged( Incidence * ) ));
1303 1307
1304 1308
1305 QString pathString = ""; 1309 QString pathString = "";
1306 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 1310 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
1307 if ( QApplication::desktop()->width() < 480 ) 1311 if ( QApplication::desktop()->width() < 480 )
1308 pathString += "icons16/"; 1312 pathString += "icons16/";
1309 } else 1313 } else
1310 pathString += "iconsmini/"; 1314 pathString += "iconsmini/";
1311 mNewItemMenu = new QPopupMenu( this ); 1315 mNewItemMenu = new QPopupMenu( this );
1312 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); 1316 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent()));
1313 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); 1317 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
1314 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); 1318 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
1315 1319
1316 // updateConfig(); //useless here... 1320 // updateConfig(); //useless here...
1317 // ... but we need mWidthLongDayLabel computed 1321 // ... but we need mWidthLongDayLabel computed
1318 QFontMetrics fontmetric(mDayLabels[0]->font()); 1322 QFontMetrics fontmetric(mDayLabels[0]->font());
1319 mWidthLongDayLabel = 0; 1323 mWidthLongDayLabel = 0;
1320 for (int i = 0; i < 7; i++) { 1324 for (int i = 0; i < 7; i++) {
1321 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1325 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1322 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1326 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1323 } 1327 }
1324 1328
1325 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1329 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1326 1330
1327#if 0 1331#if 0
1328 if ( mShowWeekView ) 1332 if ( mShowWeekView )
1329 mWidStack->raiseWidget( mWeekView ); 1333 mWidStack->raiseWidget( mWeekView );
1330 else 1334 else
1331 mWidStack->raiseWidget( mMonthView ); 1335 mWidStack->raiseWidget( mMonthView );
1332#endif 1336#endif
1333 1337
1334 emit incidenceSelected( 0 ); 1338 emit incidenceSelected( 0 );
1335 1339
1336 mComputeLayoutTimer = new QTimer( this ); 1340 mComputeLayoutTimer = new QTimer( this );
1337 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1341 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1338 1342
1339 1343
1340#ifndef DESKTOP_VERSION 1344#ifndef DESKTOP_VERSION
1341 resize( QApplication::desktop()->size() ); 1345 resize( QApplication::desktop()->size() );
1342#else 1346#else
1343 resize(640, 480 ); 1347 resize(640, 480 );
1344 updatePossible = true; 1348 updatePossible = true;
1345#endif 1349#endif
1346 computeLayout(); 1350 computeLayout();
1347 1351
1348 if ( mShowWeekView ) 1352 if ( mShowWeekView )
1349 mWidStack->raiseWidget( mWeekView ); 1353 mWidStack->raiseWidget( mWeekView );
1350 else 1354 else
1351 mWidStack->raiseWidget( mMonthView ); 1355 mWidStack->raiseWidget( mMonthView );
1352} 1356}
1353 1357
1354KOMonthView::~KOMonthView() 1358KOMonthView::~KOMonthView()
1355{ 1359{
1356 delete mContextMenu; 1360 delete mContextMenu;
1357} 1361}
1358 1362
1359void KOMonthView::catChanged( Incidence * ) 1363void KOMonthView::catChanged( Incidence * )
1360{ 1364{
1361 updateView(); 1365 updateView();
1362} 1366}
1363void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) 1367void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday )
1364{ 1368{
1365 static Incidence * lastInc = 0; 1369 static Incidence * lastInc = 0;
1366 static MonthViewCell * lastCell = 0; 1370 static MonthViewCell * lastCell = 0;
1367 1371
1368 if ( lastInc == inc && lastCell == mc ) 1372 if ( lastInc == inc && lastCell == mc )
1369 return; 1373 return;
1370 lastInc = inc; 1374 lastInc = inc;
1371 lastCell = mc; 1375 lastCell = mc;
1372 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); 1376 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
1373 1377
1374 bool weekview = false; 1378 bool weekview = false;
1375 uint index = 0; 1379 uint index = 0;
1376 for (uint i = 0; i < mCellsW.count(); ++i) { 1380 for (uint i = 0; i < mCellsW.count(); ++i) {
1377 if ( mCellsW[i] == mc ) { 1381 if ( mCellsW[i] == mc ) {
1378 weekview = true; 1382 weekview = true;
1379 index = i; 1383 index = i;
1380 break; 1384 break;
1381 } 1385 }
1382 } 1386 }
1383 QPtrVector<MonthViewCell> *cells; 1387 QPtrVector<MonthViewCell> *cells;
1384 if ( weekview ) 1388 if ( weekview )
1385 cells = &mCellsW; 1389 cells = &mCellsW;
1386 else { 1390 else {
1387 for (uint i = 0; i < mCells.count(); ++i) { 1391 for (uint i = 0; i < mCells.count(); ++i) {
1388 if ( mCells[i] == mc ) { 1392 if ( mCells[i] == mc ) {
1389 index = i; 1393 index = i;
1390 break; 1394 break;
1391 } 1395 }
1392 } 1396 }
1393 cells = &mCells; 1397 cells = &mCells;
1394 } 1398 }
1395 for (uint i = 0; i < (*cells).count(); ++i) { 1399 for (uint i = 0; i < (*cells).count(); ++i) {
1396 (*cells)[i]->deHighLight(); 1400 (*cells)[i]->deHighLight();
1397 } 1401 }
1398 if ( ! inc ) 1402 if ( ! inc )
1399 return; 1403 return;
1400 1404
1401 uint count = (*cells).count(); 1405 uint count = (*cells).count();
1402 bool goLeft = (mday > 1 && index > 0); 1406 bool goLeft = (mday > 1 && index > 0);
1403 bool goRight = (mday < 3 && mday > 0 && index < count -1); 1407 bool goRight = (mday < 3 && mday > 0 && index < count -1);
1404 for (uint iii = 1; iii < count; ++iii) { 1408 for (uint iii = 1; iii < count; ++iii) {
1405 if ( goLeft ) { 1409 if ( goLeft ) {
1406 int left = index - iii; 1410 int left = index - iii;
1407 if ( left >= 0 ) { 1411 if ( left >= 0 ) {
1408 if ( (*cells)[(uint)left]->doHighLight(inc) ) 1412 if ( (*cells)[(uint)left]->doHighLight(inc) )
1409 goLeft = false; 1413 goLeft = false;
1410 } else 1414 } else
1411 goLeft = false; 1415 goLeft = false;
1412 } 1416 }
1413 if ( goRight ) { 1417 if ( goRight ) {
1414 uint right = index + iii; 1418 uint right = index + iii;
1415 if ( right < count ) { 1419 if ( right < count ) {
1416 if ( (*cells)[right]->doHighLight(inc) ) 1420 if ( (*cells)[right]->doHighLight(inc) )
1417 goRight = false; 1421 goRight = false;
1418 1422
1419 } else 1423 } else
1420 goRight = false; 1424 goRight = false;
1421 } 1425 }
1422 1426
1423 } 1427 }
1424#if 0 1428#if 0
1425 if ( mday > 1 && index > 0 ) 1429 if ( mday > 1 && index > 0 )
1426 for (int i = index-1; i >= 0; --i) { 1430 for (int i = index-1; i >= 0; --i) {
1427 //qDebug("index %d iii %d ", index, i); 1431 //qDebug("index %d iii %d ", index, i);
1428 if ( (*cells)[(uint)i]->doHighLight(inc) ) 1432 if ( (*cells)[(uint)i]->doHighLight(inc) )
1429 break; 1433 break;
1430 } 1434 }
1431 if ( mday < 3 && mday > 0 && index < (*cells).count()-1) 1435 if ( mday < 3 && mday > 0 && index < (*cells).count()-1)
1432 for (uint i = index+1; i < (*cells).count(); ++i) { 1436 for (uint i = index+1; i < (*cells).count(); ++i) {
1433 if ( (*cells)[i]->doHighLight(inc) ) 1437 if ( (*cells)[i]->doHighLight(inc) )
1434 break; 1438 break;
1435 } 1439 }
1436#endif 1440#endif
1437 1441
1438} 1442}
1439void KOMonthView::selectInternalWeekNum ( int n ) 1443void KOMonthView::selectInternalWeekNum ( int n )
1440{ 1444{
1441 switchView(); 1445 switchView();
1442 if ( !KOPrefs::instance()->mMonthViewWeek ) 1446 if ( !KOPrefs::instance()->mMonthViewWeek )
1443 emit selectMonth (); 1447 emit selectMonth ();
1444 else 1448 else
1445 emit selectWeekNum ( n ); 1449 emit selectWeekNum ( n );
1446} 1450}
1447 1451
1448int KOMonthView::currentWeek() 1452int KOMonthView::currentWeek()
1449{ 1453{
1450 if ( mShowWeekView ) 1454 if ( mShowWeekView )
1451 return mWeekLabelsW[0]->getWeekNum(); 1455 return mWeekLabelsW[0]->getWeekNum();
1452 return mWeekLabels[0]->getWeekNum(); 1456 return mWeekLabels[0]->getWeekNum();
1453} 1457}
1454void KOMonthView::switchView() 1458void KOMonthView::switchView()
1455{ 1459{
1456 if ( selectedCell( ) ) 1460 if ( selectedCell( ) )
1457 selectedCell()->deselect(); 1461 selectedCell()->deselect();
1458 mShowWeekView = !mShowWeekView; 1462 mShowWeekView = !mShowWeekView;
1459 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1463 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1460 if ( clPending ) { 1464 if ( clPending ) {
1461 computeLayout(); 1465 computeLayout();
1462 updateConfig(); 1466 updateConfig();
1463 } 1467 }
1464 if ( mShowWeekView ) 1468 if ( mShowWeekView )
1465 mWidStack->raiseWidget( mWeekView ); 1469 mWidStack->raiseWidget( mWeekView );
1466 else 1470 else
1467 mWidStack->raiseWidget( mMonthView ); 1471 mWidStack->raiseWidget( mMonthView );
1468 clPending = false; 1472 clPending = false;
1469} 1473}
1470 1474
1471int KOMonthView::maxDatesHint() 1475int KOMonthView::maxDatesHint()
1472{ 1476{
1473 return mNumCells; 1477 return mNumCells;
1474} 1478}
1475 1479
1476int KOMonthView::currentDateCount() 1480int KOMonthView::currentDateCount()
1477{ 1481{
1478 return mNumCells; 1482 return mNumCells;
1479} 1483}
1480 1484
1481QPtrList<Incidence> KOMonthView::selectedIncidences() 1485QPtrList<Incidence> KOMonthView::selectedIncidences()
1482{ 1486{
1483 QPtrList<Incidence> selected; 1487 QPtrList<Incidence> selected;
1484 1488
1485 if ( mSelectedCell ) { 1489 if ( mSelectedCell ) {
1486 Incidence *incidence = mSelectedCell->selectedIncidence(); 1490 Incidence *incidence = mSelectedCell->selectedIncidence();
1487 if ( incidence ) selected.append( incidence ); 1491 if ( incidence ) selected.append( incidence );
1488 } 1492 }
1489 1493
1490 return selected; 1494 return selected;
1491} 1495}
1492 1496
1493DateList KOMonthView::selectedDates() 1497DateList KOMonthView::selectedDates()
1494{ 1498{
1495 DateList selected; 1499 DateList selected;
1496 1500
1497 if ( mSelectedCell ) { 1501 if ( mSelectedCell ) {
1498 QDate qd = mSelectedCell->selectedIncidenceDate(); 1502 QDate qd = mSelectedCell->selectedIncidenceDate();
1499 if ( qd.isValid() ) selected.append( qd ); 1503 if ( qd.isValid() ) selected.append( qd );
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 61a141a..1a9d16d 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,350 +1,351 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qintdict.h> 31#include <qintdict.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qvaluelist.h> 33#include <qvaluelist.h>
34#include <qptrvector.h> 34#include <qptrvector.h>
35 35
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37#include <libkcal/event.h> 37#include <libkcal/event.h>
38 38
39#include "koeventview.h" 39#include "koeventview.h"
40#include "navigatorbar.h" 40#include "navigatorbar.h"
41 41
42#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
43class QToolTipGroup; 43class QToolTipGroup;
44#endif 44#endif
45 45
46class KNOWhatsThis; 46class KNOWhatsThis;
47class MonthViewCell; 47class MonthViewCell;
48class KOWeekButton : public QPushButton 48class KOWeekButton : public QPushButton
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 public: 51 public:
52 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 52 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
53 QPushButton( parent, name) 53 QPushButton( parent, name)
54 { 54 {
55 connect( this, SIGNAL( clicked() ), 55 connect( this, SIGNAL( clicked() ),
56 SLOT( bottonClicked() )); 56 SLOT( bottonClicked() ));
57 mNumber = -1; 57 mNumber = -1;
58 } 58 }
59 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 59 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
60 int getWeekNum() { return mNumber;} 60 int getWeekNum() { return mNumber;}
61 signals: 61 signals:
62 void selectWeekNum ( int ); 62 void selectWeekNum ( int );
63private: 63private:
64 void focusInEvent ( QFocusEvent * ){;} 64 void focusInEvent ( QFocusEvent * ){;}
65 int mNumber; 65 int mNumber;
66 void keyPressEvent ( QKeyEvent * e ) 66 void keyPressEvent ( QKeyEvent * e )
67 { 67 {
68 e->ignore(); 68 e->ignore();
69 } 69 }
70 70
71private slots : 71private slots :
72 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 72 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
73}; 73};
74 74
75class KNoScrollListBox: public QListBox 75class KNoScrollListBox: public QListBox
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 public: 78 public:
79 KNoScrollListBox(QWidget *parent=0, const char *name=0); 79 KNoScrollListBox(QWidget *parent=0, const char *name=0);
80 ~KNoScrollListBox(); 80 ~KNoScrollListBox();
81 QString getWhatsThisText(QPoint p) ; 81 QString getWhatsThisText(QPoint p) ;
82 82
83 signals: 83 signals:
84 void shiftDown(); 84 void shiftDown();
85 void shiftUp(); 85 void shiftUp();
86 void rightClick(); 86 void rightClick();
87 void nextCell(); 87 void nextCell();
88 void prevCell(); 88 void prevCell();
89 void highlightIncidence( Incidence * , MonthViewCell*, int ); 89 void highlightIncidence( Incidence * , MonthViewCell*, int );
90 90 protected:
91 bool mBlockDeselect;
91 protected slots: 92 protected slots:
92 void oneDown(); 93 void oneDown();
93 void keyPressEvent(QKeyEvent *); 94 void keyPressEvent(QKeyEvent *);
94 void keyReleaseEvent(QKeyEvent *); 95 void keyReleaseEvent(QKeyEvent *);
95 void mousePressEvent(QMouseEvent *); 96 void mousePressEvent(QMouseEvent *);
96 void focusInEvent ( QFocusEvent * ); 97 void focusInEvent ( QFocusEvent * );
97 void focusOutEvent ( QFocusEvent * ); 98 void focusOutEvent ( QFocusEvent * );
98 99
99 private: 100 private:
100 bool resetOnFocusIn; 101 bool resetOnFocusIn;
101 KNOWhatsThis * mWT; 102 KNOWhatsThis * mWT;
102}; 103};
103 104
104 105
105class MonthViewItem: public QListBoxItem 106class MonthViewItem: public QListBoxItem
106{ 107{
107 public: 108 public:
108 MonthViewItem( Incidence *,const QString & title ); 109 MonthViewItem( Incidence *,const QString & title );
109 void recycle( Incidence *incidence, const QString & s); 110 void recycle( Incidence *incidence, const QString & s);
110 void setRecur(bool on) { mRecur = on; } 111 void setRecur(bool on) { mRecur = on; }
111 void setAlarm(bool on) { mAlarm = on; } 112 void setAlarm(bool on) { mAlarm = on; }
112 void setReply(bool on) { mReply = on; } 113 void setReply(bool on) { mReply = on; }
113 void setMoreInfo(bool on) { mInfo = on; } 114 void setMoreInfo(bool on) { mInfo = on; }
114 void setMultiDay(int type) { mMultiday = type; } 115 void setMultiDay(int type) { mMultiday = type; }
115 int multiDay() { return mMultiday; } 116 int multiDay() { return mMultiday; }
116 void setMultiDayPos(int type) { mdayPos = type; } 117 void setMultiDayPos(int type) { mdayPos = type; }
117 int gettMultiDayPos() { return mdayPos; } 118 int gettMultiDayPos() { return mdayPos; }
118 void setBlockRepaint(bool on) { mblockRepaint = on; } 119 void setBlockRepaint(bool on) { mblockRepaint = on; }
119 bool setHighlighted( Incidence * ); 120 bool setHighlighted( Incidence * );
120 121
121 void setPalette(const QPalette &p) { mPalette = p; } 122 void setPalette(const QPalette &p) { mPalette = p; }
122 QPalette palette() const { return mPalette; } 123 QPalette palette() const { return mPalette; }
123 bool setHighlightedFalse(); 124 bool setHighlightedFalse();
124 Incidence *incidence() const { return mIncidence; } 125 Incidence *incidence() const { return mIncidence; }
125 126
126 protected: 127 protected:
127 virtual void paint(QPainter *); 128 virtual void paint(QPainter *);
128 virtual int height(const QListBox *) const; 129 virtual int height(const QListBox *) const;
129 virtual int width(const QListBox *) const; 130 virtual int width(const QListBox *) const;
130 131
131 private: 132 private:
132 int mdayPos; 133 int mdayPos;
133 bool isWeekItem; 134 bool isWeekItem;
134 bool mblockRepaint; 135 bool mblockRepaint;
135 int mMultiday; 136 int mMultiday;
136 bool mRecur; 137 bool mRecur;
137 bool mAlarm; 138 bool mAlarm;
138 bool mReply; 139 bool mReply;
139 bool mInfo; 140 bool mInfo;
140 bool mDisplayHighlighted; 141 bool mDisplayHighlighted;
141 142
142 QPalette mPalette; 143 QPalette mPalette;
143 QDate mDate; 144 QDate mDate;
144 145
145 Incidence *mIncidence; 146 Incidence *mIncidence;
146}; 147};
147 148
148 149
149class KOMonthView; 150class KOMonthView;
150 151
151class MonthViewCell : public KNoScrollListBox 152class MonthViewCell : public KNoScrollListBox
152{ 153{
153 Q_OBJECT 154 Q_OBJECT
154 public: 155 public:
155 MonthViewCell(KOMonthView *,QWidget* ); 156 MonthViewCell(KOMonthView *,QWidget* );
156 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 157 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
157 158
158 void setDate( const QDate & ); 159 void setDate( const QDate & );
159 QDate date() const; 160 QDate date() const;
160 161
161 void setPrimary( bool ); 162 void setPrimary( bool );
162 bool isPrimary() const; 163 bool isPrimary() const;
163 164
164 void setHoliday( bool ); 165 void setHoliday( bool );
165 void setHoliday( const QString & ); 166 void setHoliday( const QString & );
166 167
167 void updateCell(); 168 void updateCell();
168 void startUpdateCell(); 169 void startUpdateCell();
169 void finishUpdateCell(); 170 void finishUpdateCell();
170 int insertEvent(Event *); 171 int insertEvent(Event *);
171 void insertTodo(Todo *); 172 void insertTodo(Todo *);
172 173
173 void updateConfig( bool bigFont = false ); 174 void updateConfig( bool bigFont = false );
174 175
175 void enableScrollBars( bool ); 176 void enableScrollBars( bool );
176 177
177 Incidence *selectedIncidence(); 178 Incidence *selectedIncidence();
178 QDate selectedIncidenceDate(); 179 QDate selectedIncidenceDate();
179 QPushButton * dateLabel() { return mLabel; } 180 QPushButton * dateLabel() { return mLabel; }
180 bool doHighLight( Incidence *); 181 bool doHighLight( Incidence *);
181 void deselect(); 182 void deselect();
182 void select(); 183 void select();
183#ifdef DESKTOP_VERSION 184#ifdef DESKTOP_VERSION
184 static QToolTipGroup *toolTipGroup(); 185 static QToolTipGroup *toolTipGroup();
185#endif 186#endif
186 signals: 187 signals:
187 void defaultAction( Incidence * ); 188 void defaultAction( Incidence * );
188 void newEventSignal( QDateTime ); 189 void newEventSignal( QDateTime );
189 void showDaySignal( QDate ); 190 void showDaySignal( QDate );
190 191
191 protected: 192 protected:
192 QStringList mToolTip; 193 QStringList mToolTip;
193 void resizeEvent( QResizeEvent * ); 194 void resizeEvent( QResizeEvent * );
194 195
195public slots: 196public slots:
196 void showDay(); 197 void showDay();
197 void deHighLight(); 198 void deHighLight();
198 void repaintfinishUpdateCell(); 199 void repaintfinishUpdateCell();
199 protected slots: 200 protected slots:
200 void defaultAction( QListBoxItem * ); 201 void defaultAction( QListBoxItem * );
201 void contextMenu( QListBoxItem * ); 202 void contextMenu( QListBoxItem * );
202 void selection( QListBoxItem * ); 203 void selection( QListBoxItem * );
203 void cellClicked( QListBoxItem * ); 204 void cellClicked( QListBoxItem * );
204 void newEvent(); 205 void newEvent();
205 206
206 private: 207 private:
207 int mdayCount; 208 int mdayCount;
208 QPtrList <MonthViewItem> mAvailItemList; 209 QPtrList <MonthViewItem> mAvailItemList;
209 KOMonthView *mMonthView; 210 KOMonthView *mMonthView;
210 int currentPalette; 211 int currentPalette;
211 212
212 QDate mDate; 213 QDate mDate;
213 bool mPrimary; 214 bool mPrimary;
214 bool mHoliday; 215 bool mHoliday;
215 QString mHolidayString; 216 QString mHolidayString;
216 217
217 //QLabel *mLabel; 218 //QLabel *mLabel;
218 QPushButton *mLabel; 219 QPushButton *mLabel;
219 //QListBox *mItemList; 220 //QListBox *mItemList;
220#ifdef DESKTOP_VERSION 221#ifdef DESKTOP_VERSION
221 static QToolTipGroup *mToolTipGroup; 222 static QToolTipGroup *mToolTipGroup;
222#endif 223#endif
223 QSize mLabelSize; 224 QSize mLabelSize;
224 QSize mLabelBigSize; 225 QSize mLabelBigSize;
225 QPalette mHolidayPalette; 226 QPalette mHolidayPalette;
226 QPalette mStandardPalette; 227 QPalette mStandardPalette;
227 QPalette mPrimaryPalette; 228 QPalette mPrimaryPalette;
228 QPalette mNonPrimaryPalette; 229 QPalette mNonPrimaryPalette;
229 void setMyPalette(); 230 void setMyPalette();
230 QPalette getPalette (); 231 QPalette getPalette ();
231 232
232}; 233};
233 234
234 235
235class KOMonthView: public KOEventView 236class KOMonthView: public KOEventView
236{ 237{
237 Q_OBJECT 238 Q_OBJECT
238 public: 239 public:
239 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 240 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
240 ~KOMonthView(); 241 ~KOMonthView();
241 242
242 /** Returns maximum number of days supported by the komonthview */ 243 /** Returns maximum number of days supported by the komonthview */
243 virtual int maxDatesHint(); 244 virtual int maxDatesHint();
244 245
245 /** Returns number of currently shown dates. */ 246 /** Returns number of currently shown dates. */
246 virtual int currentDateCount(); 247 virtual int currentDateCount();
247 248
248 /** returns the currently selected events */ 249 /** returns the currently selected events */
249 virtual QPtrList<Incidence> selectedIncidences(); 250 virtual QPtrList<Incidence> selectedIncidences();
250 251
251 /** returns dates of the currently selected events */ 252 /** returns dates of the currently selected events */
252 virtual DateList selectedDates(); 253 virtual DateList selectedDates();
253#if 0 254#if 0
254 virtual void printPreview(CalPrinter *calPrinter, 255 virtual void printPreview(CalPrinter *calPrinter,
255 const QDate &, const QDate &); 256 const QDate &, const QDate &);
256#endif 257#endif
257 bool isMonthView() { return !mShowWeekView; } 258 bool isMonthView() { return !mShowWeekView; }
258 bool isUpdatePossible() { return updatePossible; } 259 bool isUpdatePossible() { return updatePossible; }
259 260
260 MonthViewCell * selectedCell(); 261 MonthViewCell * selectedCell();
261 bool skipResize; 262 bool skipResize;
262 NavigatorBar* navigatorBar() { return mNavigatorBar ;} 263 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
263 void clearList(); 264 void clearList();
264 public slots: 265 public slots:
265 void incidenceHighlighted( Incidence *, MonthViewCell*, int ); 266 void incidenceHighlighted( Incidence *, MonthViewCell*, int );
266 void nextCell(); 267 void nextCell();
267 void prevCell(); 268 void prevCell();
268 virtual void updateView(); 269 virtual void updateView();
269 virtual void updateConfig(); 270 virtual void updateConfig();
270 virtual void showDates(const QDate &start, const QDate &end); 271 virtual void showDates(const QDate &start, const QDate &end);
271 virtual void showEvents(QPtrList<Event> eventList); 272 virtual void showEvents(QPtrList<Event> eventList);
272 273
273 void changeEventDisplay(Event *, int); 274 void changeEventDisplay(Event *, int);
274 275
275 void clearSelection(); 276 void clearSelection();
276 277
277 void showContextMenu( Incidence * ); 278 void showContextMenu( Incidence * );
278 279
279 void setSelectedCell( MonthViewCell * ); 280 void setSelectedCell( MonthViewCell * );
280 void setPopupCell( MonthViewCell * ); 281 void setPopupCell( MonthViewCell * );
281 void switchView(); 282 void switchView();
282 void setKeyBFocus(); 283 void setKeyBFocus();
283 284
284 protected slots: 285 protected slots:
285 void catChanged( Incidence * ); 286 void catChanged( Incidence * );
286 void setKeyBoardFocus(); 287 void setKeyBoardFocus();
287 void slotNewTodo(); 288 void slotNewTodo();
288 void slotNewEvent(); 289 void slotNewEvent();
289 void slotEditJournal(); 290 void slotEditJournal();
290 void slotComputeLayout(); 291 void slotComputeLayout();
291 void selectInternalWeekNum ( int ); 292 void selectInternalWeekNum ( int );
292 void processSelectionChange(); 293 void processSelectionChange();
293 signals: 294 signals:
294 void nextMonth(); 295 void nextMonth();
295 void prevMonth(); 296 void prevMonth();
296 void selectWeekNum ( int ); 297 void selectWeekNum ( int );
297 void selectMonth (); 298 void selectMonth ();
298 void showDaySignal( QDate ); 299 void showDaySignal( QDate );
299 void newTodoSignal( QDateTime, bool ); 300 void newTodoSignal( QDateTime, bool );
300 void showJournalSignal( int,QDate ); 301 void showJournalSignal( int,QDate );
301 protected: 302 protected:
302 void resizeEvent(QResizeEvent *); 303 void resizeEvent(QResizeEvent *);
303 void viewChanged(); 304 void viewChanged();
304 void updateDayLabels(); 305 void updateDayLabels();
305 int mapWeekLayout( int, bool ); 306 int mapWeekLayout( int, bool );
306 307
307 private: 308 private:
308 int mKBFcounter; 309 int mKBFcounter;
309 QTimer* mComputeLayoutTimer; 310 QTimer* mComputeLayoutTimer;
310 NavigatorBar* mNavigatorBar; 311 NavigatorBar* mNavigatorBar;
311 int currentWeek(); 312 int currentWeek();
312 bool clPending; 313 bool clPending;
313 QWidgetStack * mWidStack; 314 QWidgetStack * mWidStack;
314 QWidget* mMonthView; 315 QWidget* mMonthView;
315 QWidget* mWeekView; 316 QWidget* mWeekView;
316 bool mShowWeekView; 317 bool mShowWeekView;
317 bool updatePossible; 318 bool updatePossible;
318 int mDaysPerWeek; 319 int mDaysPerWeek;
319 int mNumWeeks; 320 int mNumWeeks;
320 int mNumCells; 321 int mNumCells;
321 //bool mWeekStartsMonday; 322 //bool mWeekStartsMonday;
322 bool mShowSatSunComp; 323 bool mShowSatSunComp;
323 void computeLayout(); 324 void computeLayout();
324 void computeLayoutWeek(); 325 void computeLayoutWeek();
325 void doComputeLayoutWeek(); 326 void doComputeLayoutWeek();
326 327
327 QPtrVector<MonthViewCell> mCells; 328 QPtrVector<MonthViewCell> mCells;
328 QPtrVector<QLabel> mDayLabels; 329 QPtrVector<QLabel> mDayLabels;
329 QPtrVector<KOWeekButton> mWeekLabels; 330 QPtrVector<KOWeekButton> mWeekLabels;
330 QPtrVector<MonthViewCell> mCellsW; 331 QPtrVector<MonthViewCell> mCellsW;
331 QPtrVector<QLabel> mDayLabelsW; 332 QPtrVector<QLabel> mDayLabelsW;
332 QPtrVector<KOWeekButton> mWeekLabelsW; 333 QPtrVector<KOWeekButton> mWeekLabelsW;
333 334
334 bool mShortDayLabelsM; 335 bool mShortDayLabelsM;
335 bool mShortDayLabelsW; 336 bool mShortDayLabelsW;
336 int mWidthLongDayLabel; 337 int mWidthLongDayLabel;
337 338
338 QDate mStartDate; 339 QDate mStartDate;
339 340
340 MonthViewCell *mSelectedCell; 341 MonthViewCell *mSelectedCell;
341 MonthViewCell *mPopupCell; 342 MonthViewCell *mPopupCell;
342 bool mFlagKeyPressed; 343 bool mFlagKeyPressed;
343 KOEventPopupMenu *mContextMenu; 344 KOEventPopupMenu *mContextMenu;
344 QPopupMenu *mNewItemMenu; 345 QPopupMenu *mNewItemMenu;
345 void keyPressEvent ( QKeyEvent * ) ; 346 void keyPressEvent ( QKeyEvent * ) ;
346 void keyReleaseEvent ( QKeyEvent * ) ; 347 void keyReleaseEvent ( QKeyEvent * ) ;
347 348
348}; 349};
349 350
350#endif 351#endif