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