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