summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp855
-rw-r--r--korganizer/komonthview.h2
-rw-r--r--korganizer/koviewmanager.cpp4
-rw-r--r--korganizer/mainwindow.cpp2
4 files changed, 447 insertions, 416 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 437debe..10e4f1d 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,456 +1,462 @@
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 <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qtooltip.h> 27#include <qtooltip.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35 35
36#include <kdebug.h> 36#include <kdebug.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPRINTER 44#ifndef KORG_NOPRINTER
45#include "calprinter.h" 45#include "calprinter.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#ifndef KORG_NOPLUGINS 48#ifndef KORG_NOPLUGINS
49#include "kocore.h" 49#include "kocore.h"
50#endif 50#endif
51#include "koglobals.h" 51#include "koglobals.h"
52#include <libkcal/kincidenceformatter.h> 52#include <libkcal/kincidenceformatter.h>
53 53
54#include "komonthview.h" 54#include "komonthview.h"
55 55
56#define PIXMAP_SIZE 5 56#define PIXMAP_SIZE 5
57#ifdef DESKTOP_VERSION 57#ifdef DESKTOP_VERSION
58 QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 58QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
59#endif 59#endif
60class KNOWhatsThis :public QWhatsThis 60class KNOWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 63 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
64 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 64 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
65 65
66protected: 66protected:
67 virtual QString text( const QPoint& p) 67 virtual QString text( const QPoint& p)
68 { 68 {
69 return _wid->getWhatsThisText(p) ; 69 return _wid->getWhatsThisText(p) ;
70 }; 70 };
71private: 71private:
72 KNoScrollListBox* _wid; 72 KNoScrollListBox* _wid;
73 73
74}; 74};
75 75
76 76
77KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 77KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
78 : QListBox(parent, name, WRepaintNoErase) 78 : QListBox(parent, name, WRepaintNoErase)
79{ 79{
80#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
81 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 81 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
82#endif 82#endif
83 mWT = new KNOWhatsThis(this); 83 mWT = new KNOWhatsThis(this);
84} 84}
85KNoScrollListBox::~KNoScrollListBox() 85KNoScrollListBox::~KNoScrollListBox()
86{ 86{
87 87
88} 88}
89QString KNoScrollListBox::getWhatsThisText(QPoint p) 89QString KNoScrollListBox::getWhatsThisText(QPoint p)
90{ 90{
91 QListBoxItem* item = itemAt ( p ); 91 QListBoxItem* item = itemAt ( p );
92 if ( ! item ) { 92 if ( ! item ) {
93 return i18n("Click in the cell\nto add an event!"); 93 return i18n("Click in the cell\nto add an event!");
94 } 94 }
95 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 95 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
96} 96}
97void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 97void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
98{ 98{
99 99
100 switch(e->key()) { 100 switch(e->key()) {
101 case Key_Right: 101 case Key_Right:
102 // if ( e->state() == Qt::ControlButton ) 102 // if ( e->state() == Qt::ControlButton )
103 { 103 {
104 e->ignore(); 104 e->ignore();
105 return; 105 return;
106 } 106 }
107 scrollBy(4,0); 107 scrollBy(4,0);
108 break; 108 break;
109 case Key_Left: 109 case Key_Left:
110 // if ( e->state() == Qt::ControlButton ) 110 // if ( e->state() == Qt::ControlButton )
111 { 111 {
112 e->ignore(); 112 e->ignore();
113 return; 113 return;
114 } 114 }
115 scrollBy(-4,0); 115 scrollBy(-4,0);
116 break; 116 break;
117 case Key_Up: 117 case Key_Up:
118 if(!count()) break; 118 if(count() < 2) {
119 setCurrentItem((currentItem()+count()-1)%count()); 119 e->ignore();
120 if(!itemVisible(currentItem())) { 120 break;
121 if((unsigned int) currentItem() == (count()-1)) {
122 setTopItem(currentItem()-numItemsVisible()+1);
123 } else {
124 setTopItem(topItem()-1);
125 } 121 }
126 } 122 setCurrentItem((currentItem()+count()-1)%count());
127 break; 123 if(!itemVisible(currentItem())) {
124 if((unsigned int) currentItem() == (count()-1)) {
125 setTopItem(currentItem()-numItemsVisible()+1);
126 } else {
127 setTopItem(topItem()-1);
128 }
129 }
130 break;
128 case Key_Down: 131 case Key_Down:
129 if(!count()) break; 132 if(count() < 2) {
130 setCurrentItem((currentItem()+1)%count()); 133 e->ignore();
131 if(!itemVisible(currentItem())) { 134 break;
132 if(currentItem() == 0) {
133 setTopItem(0);
134 } else {
135 setTopItem(topItem()+1);
136 } 135 }
137 } 136 setCurrentItem((currentItem()+1)%count());
138 break; 137 if(!itemVisible(currentItem())) {
138 if(currentItem() == 0) {
139 setTopItem(0);
140 } else {
141 setTopItem(topItem()+1);
142 }
143 }
144 break;
139 case Key_Shift: 145 case Key_Shift:
140 emit shiftDown(); 146 emit shiftDown();
141 break; 147 break;
142 default: 148 default:
143 e->ignore(); 149 e->ignore();
144 break; 150 break;
145 } 151 }
146} 152}
147 153
148void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 154void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
149{ 155{
150 switch(e->key()) { 156 switch(e->key()) {
151 case Key_Shift: 157 case Key_Shift:
152 emit shiftUp(); 158 emit shiftUp();
153 break; 159 break;
154 default: 160 default:
155 break; 161 break;
156 } 162 }
157} 163}
158 164
159void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 165void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
160{ 166{
161 QListBox::mousePressEvent(e); 167 QListBox::mousePressEvent(e);
162 168
163 if(e->button() == RightButton) { 169 if(e->button() == RightButton) {
164 emit rightClick(); 170 emit rightClick();
165 } 171 }
166} 172}
167 173
168MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 174MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
169 : QListBoxItem() 175 : QListBoxItem()
170{ 176{
171 setText( s ); 177 setText( s );
172 178
173 mIncidence = incidence; 179 mIncidence = incidence;
174 mDate = qd; 180 mDate = qd;
175 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 181 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
176 mRecur = false; 182 mRecur = false;
177 mAlarm = false; 183 mAlarm = false;
178 mReply = false; 184 mReply = false;
179 mInfo = false; 185 mInfo = false;
180} 186}
181 187
182void MonthViewItem::paint(QPainter *p) 188void MonthViewItem::paint(QPainter *p)
183{ 189{
184#if QT_VERSION >= 0x030000 190#if QT_VERSION >= 0x030000
185 bool sel = isSelected(); 191 bool sel = isSelected();
186#else 192#else
187 bool sel = selected(); 193 bool sel = selected();
188#endif 194#endif
189 195
190 196
191 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 197 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
192 { 198 {
193 p->setBackgroundColor( palette().color( QPalette::Normal, \ 199 p->setBackgroundColor( palette().color( QPalette::Normal, \
194 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 200 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
195 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 201 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
196 } 202 }
197 int x = 1; 203 int x = 1;
198 int y = 3;//(height() - mRecurPixmap.height()) /2; 204 int y = 3;//(height() - mRecurPixmap.height()) /2;
199 int size = PIXMAP_SIZE; 205 int size = PIXMAP_SIZE;
200 if ( QApplication::desktop()->width() < 300 ) 206 if ( QApplication::desktop()->width() < 300 )
201 size = 3; 207 size = 3;
202 if ( KOPrefs::instance()->mMonthShowIcons ) { 208 if ( KOPrefs::instance()->mMonthShowIcons ) {
203 if ( mInfo ) { 209 if ( mInfo ) {
204 p->fillRect ( x, y,size,size, Qt::darkGreen ); 210 p->fillRect ( x, y,size,size, Qt::darkGreen );
205 x += size + 1; 211 x += size + 1;
206 } 212 }
207 if ( mRecur ) { 213 if ( mRecur ) {
208 p->fillRect ( x, y,size,size, Qt::blue ); 214 p->fillRect ( x, y,size,size, Qt::blue );
209 x += size + 1; 215 x += size + 1;
210 } 216 }
211 if ( mAlarm ) { 217 if ( mAlarm ) {
212 p->fillRect ( x, y,size,size, Qt::red ); 218 p->fillRect ( x, y,size,size, Qt::red );
213 x += size + 1; 219 x += size + 1;
214 } 220 }
215 if ( mReply ) { 221 if ( mReply ) {
216 p->fillRect ( x, y,size,size, Qt::yellow ); 222 p->fillRect ( x, y,size,size, Qt::yellow );
217 x += size + 1; 223 x += size + 1;
218 } 224 }
219 } 225 }
220 QFontMetrics fm = p->fontMetrics(); 226 QFontMetrics fm = p->fontMetrics();
221 int yPos; 227 int yPos;
222 int pmheight = size; 228 int pmheight = size;
223 if( pmheight < fm.height() ) 229 if( pmheight < fm.height() )
224 yPos = fm.ascent() + fm.leading()/2; 230 yPos = fm.ascent() + fm.leading()/2;
225 else 231 else
226 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 232 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
227 p->setPen( palette().color( QPalette::Normal, sel ? \ 233 p->setPen( palette().color( QPalette::Normal, sel ? \
228 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 234 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
229 p->drawText( x, yPos, text() ); 235 p->drawText( x, yPos, text() );
230 if ( mIncidence->cancelled() ) { 236 if ( mIncidence->cancelled() ) {
231 int wid = fm.width( text() ); 237 int wid = fm.width( text() );
232 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); 238 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
233 } 239 }
234 240
235} 241}
236 242
237int MonthViewItem::height(const QListBox *lb) const 243int MonthViewItem::height(const QListBox *lb) const
238{ 244{
239 return lb->fontMetrics().lineSpacing()+1; 245 return lb->fontMetrics().lineSpacing()+1;
240} 246}
241 247
242int MonthViewItem::width(const QListBox *lb) const 248int MonthViewItem::width(const QListBox *lb) const
243{ 249{
244 int size = PIXMAP_SIZE; 250 int size = PIXMAP_SIZE;
245 if ( QApplication::desktop()->width() < 300 ) 251 if ( QApplication::desktop()->width() < 300 )
246 size = 3; 252 size = 3;
247 int x = 1; 253 int x = 1;
248 if ( mInfo ) { 254 if ( mInfo ) {
249 x += size + 1; 255 x += size + 1;
250 } 256 }
251 if( mRecur ) { 257 if( mRecur ) {
252 x += size+1; 258 x += size+1;
253 } 259 }
254 if( mAlarm ) { 260 if( mAlarm ) {
255 x += size+1; 261 x += size+1;
256 } 262 }
257 if( mReply ) { 263 if( mReply ) {
258 x += size+1; 264 x += size+1;
259 } 265 }
260 266
261 return( x + lb->fontMetrics().width( text() ) + 1 ); 267 return( x + lb->fontMetrics().width( text() ) + 1 );
262} 268}
263 269
264 270
265MonthViewCell::MonthViewCell( KOMonthView *parent) 271MonthViewCell::MonthViewCell( KOMonthView *parent)
266 : QWidget( parent ), 272 : QWidget( parent ),
267 mMonthView( parent ) 273 mMonthView( parent )
268{ 274{
269 275
270 QVBoxLayout *topLayout = new QVBoxLayout( this ); 276 QVBoxLayout *topLayout = new QVBoxLayout( this );
271 277
272 // mLabel = new QLabel( this );QPushButton 278 // mLabel = new QLabel( this );QPushButton
273 mLabel = new QPushButton( this ); 279 mLabel = new QPushButton( this );
274 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 280 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
275 //mLabel->setLineWidth( 1 ); 281 //mLabel->setLineWidth( 1 );
276 //mLabel->setAlignment( AlignCenter ); 282 //mLabel->setAlignment( AlignCenter );
277 mLabel->setFlat( true ); 283 mLabel->setFlat( true );
278 mItemList = new KNoScrollListBox( this ); 284 mItemList = new KNoScrollListBox( this );
279 mItemList->setMinimumSize( 10, 10 ); 285 mItemList->setMinimumSize( 10, 10 );
280 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 286 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
281 mItemList->setLineWidth( 1 ); 287 mItemList->setLineWidth( 1 );
282 topLayout->addWidget( mItemList ); 288 topLayout->addWidget( mItemList );
283 mLabel->raise(); 289 mLabel->raise();
284 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 290 // QColor( 0,0,255 ) QColor( 160,1600,255 )
285 mStandardPalette = palette(); 291 mStandardPalette = palette();
286 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 292 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
287 293
288 enableScrollBars( false ); 294 enableScrollBars( false );
289 updateConfig(); 295 updateConfig();
290 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 296 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
291 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 297 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
292 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 298 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
293 SLOT( defaultAction( QListBoxItem * ) ) ); 299 SLOT( defaultAction( QListBoxItem * ) ) );
294 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 300 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
295 const QPoint &) ), 301 const QPoint &) ),
296 SLOT( contextMenu( QListBoxItem * ) ) ); 302 SLOT( contextMenu( QListBoxItem * ) ) );
297 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 303 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
298 SLOT( selection( QListBoxItem * ) ) ); 304 SLOT( selection( QListBoxItem * ) ) );
299 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 305 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
300 SLOT( cellClicked( QListBoxItem * ) ) ); 306 SLOT( cellClicked( QListBoxItem * ) ) );
301 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 307 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
302 SLOT( selection( QListBoxItem * ) ) ); 308 SLOT( selection( QListBoxItem * ) ) );
303} 309}
304#ifdef DESKTOP_VERSION 310#ifdef DESKTOP_VERSION
305QToolTipGroup *MonthViewCell::toolTipGroup() 311QToolTipGroup *MonthViewCell::toolTipGroup()
306{ 312{
307 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 313 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
308 return mToolTipGroup; 314 return mToolTipGroup;
309} 315}
310#endif 316#endif
311 317
312void MonthViewCell::setDate( const QDate &date ) 318void MonthViewCell::setDate( const QDate &date )
313{ 319{
314// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 320 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
315 mDate = date; 321 mDate = date;
316 322
317 323
318 324
319 //resizeEvent( 0 ); 325 //resizeEvent( 0 );
320} 326}
321 327
322QDate MonthViewCell::date() const 328QDate MonthViewCell::date() const
323{ 329{
324 return mDate; 330 return mDate;
325} 331}
326 332
327void MonthViewCell::setPrimary( bool primary ) 333void MonthViewCell::setPrimary( bool primary )
328{ 334{
329 mPrimary = primary; 335 mPrimary = primary;
330 //setMyPalette(); 336 //setMyPalette();
331} 337}
332void MonthViewCell::setMyPalette() 338void MonthViewCell::setMyPalette()
333{ 339{
334 340
335 if ( mHoliday) { 341 if ( mHoliday) {
336 setPalette( mHolidayPalette ); 342 setPalette( mHolidayPalette );
337 } else { 343 } else {
338 if ( mPrimary ) { 344 if ( mPrimary ) {
339 setPalette( mPrimaryPalette ); 345 setPalette( mPrimaryPalette );
340 } else { 346 } else {
341 setPalette( mNonPrimaryPalette ); 347 setPalette( mNonPrimaryPalette );
342 } 348 }
343 } 349 }
344 QPalette pal = palette(); 350 QPalette pal = palette();
345 351
346 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 352 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
347} 353}
348QPalette MonthViewCell::getPalette () 354QPalette MonthViewCell::getPalette ()
349{ 355{
350 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 356 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
351 return mStandardPalette; 357 return mStandardPalette;
352 if ( mHoliday) { 358 if ( mHoliday) {
353 return mHolidayPalette ; 359 return mHolidayPalette ;
354 } else { 360 } else {
355 if ( mPrimary ) { 361 if ( mPrimary ) {
356 return mPrimaryPalette ; 362 return mPrimaryPalette ;
357 } 363 }
358 } 364 }
359 return mNonPrimaryPalette; 365 return mNonPrimaryPalette;
360} 366}
361bool MonthViewCell::isPrimary() const 367bool MonthViewCell::isPrimary() const
362{ 368{
363 return mPrimary; 369 return mPrimary;
364} 370}
365 371
366void MonthViewCell::setHoliday( bool holiday ) 372void MonthViewCell::setHoliday( bool holiday )
367{ 373{
368 mHoliday = holiday; 374 mHoliday = holiday;
369 //setMyPalette(); 375 //setMyPalette();
370} 376}
371 377
372void MonthViewCell::setHoliday( const QString &holiday ) 378void MonthViewCell::setHoliday( const QString &holiday )
373{ 379{
374 mHolidayString = holiday; 380 mHolidayString = holiday;
375 381
376 if ( !holiday.isEmpty() ) { 382 if ( !holiday.isEmpty() ) {
377 setHoliday( true ); 383 setHoliday( true );
378 } 384 }
379} 385}
380void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 386void MonthViewCell::keyPressEvent ( QKeyEvent * e )
381{ 387{
382 388
383 e->ignore(); 389 e->ignore();
384 390
385} 391}
386void MonthViewCell::clear() 392void MonthViewCell::clear()
387{ 393{
388 mItemList->clear(); 394 mItemList->clear();
389 QApplication::removePostedEvents ( mItemList ); 395 QApplication::removePostedEvents ( mItemList );
390 QApplication::removePostedEvents ( mLabel ); 396 QApplication::removePostedEvents ( mLabel );
391 QApplication::removePostedEvents ( this ); 397 QApplication::removePostedEvents ( this );
392} 398}
393void MonthViewCell::updateCell() 399void MonthViewCell::updateCell()
394{ 400{
395 if ( !mMonthView->isUpdatePossible() ) 401 if ( !mMonthView->isUpdatePossible() )
396 return; 402 return;
397 /* 403 /*
398 if ( !isVisible() ){ 404 if ( !isVisible() ){
399 return; 405 return;
400 } 406 }
401 */ 407 */
402 // qDebug("MonthViewCell::updateCell() "); 408 // qDebug("MonthViewCell::updateCell() ");
403 setPrimary( mDate.month()%2 ); 409 setPrimary( mDate.month()%2 );
404 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 410 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
405 if ( mDate == QDate::currentDate() ) { 411 if ( mDate == QDate::currentDate() ) {
406 mItemList->setLineWidth( 3 ); 412 mItemList->setLineWidth( 3 );
407 } else { 413 } else {
408 mItemList->setLineWidth( 1 ); 414 mItemList->setLineWidth( 1 );
409 } 415 }
410 mItemList->clear(); 416 mItemList->clear();
411 417
412#ifdef DESKTOP_VERSION 418#ifdef DESKTOP_VERSION
413 QToolTip::remove(this); 419 QToolTip::remove(this);
414#endif 420#endif
415 QString tipText(""); 421 QString tipText("");
416 //qApp->processEvents(); 422 //qApp->processEvents();
417 if ( !mHolidayString.isEmpty() ) { 423 if ( !mHolidayString.isEmpty() ) {
418 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 424 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
419 item->setPalette( mHolidayPalette ); 425 item->setPalette( mHolidayPalette );
420 mItemList->insertItem( item ); 426 mItemList->insertItem( item );
421 tipText += mHolidayString+"\n"; 427 tipText += mHolidayString+"\n";
422 } 428 }
423 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 429 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
424 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 430 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
425 Event *event; 431 Event *event;
426 for( event = events.first(); event; event = events.next() ) { // for event 432 for( event = events.first(); event; event = events.next() ) { // for event
427 433
428 if ( !(event->doesRecur() == Recurrence::rNone) ) { 434 if ( !(event->doesRecur() == Recurrence::rNone) ) {
429 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 435 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
430 continue; 436 continue;
431 else 437 else
432 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 438 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
433 continue; 439 continue;
434 } 440 }
435 441
436 if ( event->categories().contains("Holiday") || 442 if ( event->categories().contains("Holiday") ||
437 event->categories().contains(i18n("Holiday"))) { 443 event->categories().contains(i18n("Holiday"))) {
438 setHoliday( true ); 444 setHoliday( true );
439 if ( mDate.dayOfWeek() == 7 ) 445 if ( mDate.dayOfWeek() == 7 )
440 mItemList->setLineWidth( 3 ); 446 mItemList->setLineWidth( 3 );
441 } 447 }
442 QString text; 448 QString text;
443 if (event->isMultiDay()) { 449 if (event->isMultiDay()) {
444 QString prefix = "<->"; 450 QString prefix = "<->";
445 if ( event->doesRecur() ) { 451 if ( event->doesRecur() ) {
446 if ( event->recursOn( mDate) ) 452 if ( event->recursOn( mDate) )
447 prefix ="->" ; 453 prefix ="->" ;
448 else { 454 else {
449 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 455 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
450 if ( event->recursOn( mDate.addDays( -days)) ) 456 if ( event->recursOn( mDate.addDays( -days)) )
451 prefix ="<-" ; 457 prefix ="<-" ;
452 } 458 }
453 459
454 } else { 460 } else {
455 if (mDate == event->dtStart().date()) { 461 if (mDate == event->dtStart().date()) {
456 prefix ="->" ; 462 prefix ="->" ;
@@ -540,483 +546,485 @@ void MonthViewCell::updateCell()
540 if (cat.isEmpty()) { 546 if (cat.isEmpty()) {
541 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 547 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
542 } else { 548 } else {
543 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 549 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
544 } 550 }
545 551
546 } else { 552 } else {
547 if (cat.isEmpty()) { 553 if (cat.isEmpty()) {
548 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 554 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
549 } else { 555 } else {
550 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 556 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
551 } 557 }
552 } 558 }
553 559
554 } else { 560 } else {
555 pal = mStandardPalette ; 561 pal = mStandardPalette ;
556 } 562 }
557 item->setPalette( pal ); 563 item->setPalette( pal );
558 mItemList->insertItem( item ); 564 mItemList->insertItem( item );
559 tipText += text+"\n"; 565 tipText += text+"\n";
560 } 566 }
561#ifdef DESKTOP_VERSION 567#ifdef DESKTOP_VERSION
562 if (tipText != "") 568 if (tipText != "")
563 QToolTip::add(this,tipText,toolTipGroup(),""); 569 QToolTip::add(this,tipText,toolTipGroup(),"");
564#endif 570#endif
565 571
566 //setMyPalette(); 572 //setMyPalette();
567 setMyPalette(); 573 setMyPalette();
568 QString text; 574 QString text;
569 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 575 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
570 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 576 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
571 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 577 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
572 mLabel->resize( mLabelBigSize ); 578 mLabel->resize( mLabelBigSize );
573 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 579 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
574 } else { 580 } else {
575 mLabel->resize( mLabelSize ); 581 mLabel->resize( mLabelSize );
576 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 582 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
577 } 583 }
578 584
579 mLabel->setText( text ); 585 mLabel->setText( text );
580 resizeEvent( 0 ); 586 resizeEvent( 0 );
581 // if ( isVisible()) 587 // if ( isVisible())
582 //qApp->processEvents(); 588 //qApp->processEvents();
583} 589}
584 590
585void MonthViewCell::updateConfig() 591void MonthViewCell::updateConfig()
586{ 592{
587 593
588 setFont( KOPrefs::instance()->mMonthViewFont ); 594 setFont( KOPrefs::instance()->mMonthViewFont );
589 595
590 QFontMetrics fm( font() ); 596 QFontMetrics fm( font() );
591 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 597 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
592 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 598 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
593 mHolidayPalette = mStandardPalette; 599 mHolidayPalette = mStandardPalette;
594 mPrimaryPalette = mStandardPalette; 600 mPrimaryPalette = mStandardPalette;
595 mNonPrimaryPalette = mStandardPalette; 601 mNonPrimaryPalette = mStandardPalette;
596 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 602 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
597 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 603 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
598 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 604 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
599 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 605 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
600 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 606 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
601 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 607 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
602 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 608 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
603 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 609 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
604 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 610 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
605 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 611 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
606 } 612 }
607 updateCell(); 613 updateCell();
608} 614}
609 615
610void MonthViewCell::enableScrollBars( bool enabled ) 616void MonthViewCell::enableScrollBars( bool enabled )
611{ 617{
612 if ( enabled ) { 618 if ( enabled ) {
613 mItemList->setVScrollBarMode(QScrollView::Auto); 619 mItemList->setVScrollBarMode(QScrollView::Auto);
614 mItemList->setHScrollBarMode(QScrollView::Auto); 620 mItemList->setHScrollBarMode(QScrollView::Auto);
615 } else { 621 } else {
616 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 622 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
617 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 623 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
618 } 624 }
619} 625}
620 626
621Incidence *MonthViewCell::selectedIncidence() 627Incidence *MonthViewCell::selectedIncidence()
622{ 628{
623 int index = mItemList->currentItem(); 629 int index = mItemList->currentItem();
624 if ( index < 0 ) return 0; 630 if ( index < 0 ) return 0;
625 631
626 MonthViewItem *item = 632 MonthViewItem *item =
627 static_cast<MonthViewItem *>( mItemList->item( index ) ); 633 static_cast<MonthViewItem *>( mItemList->item( index ) );
628 634
629 if ( !item ) return 0; 635 if ( !item ) return 0;
630 636
631 return item->incidence(); 637 return item->incidence();
632} 638}
633 639
634QDate MonthViewCell::selectedIncidenceDate() 640QDate MonthViewCell::selectedIncidenceDate()
635{ 641{
636 QDate qd; 642 QDate qd;
637 int index = mItemList->currentItem(); 643 int index = mItemList->currentItem();
638 if ( index < 0 ) return qd; 644 if ( index < 0 ) return qd;
639 645
640 MonthViewItem *item = 646 MonthViewItem *item =
641 static_cast<MonthViewItem *>( mItemList->item( index ) ); 647 static_cast<MonthViewItem *>( mItemList->item( index ) );
642 648
643 if ( !item ) return qd; 649 if ( !item ) return qd;
644 650
645 return item->incidenceDate(); 651 return item->incidenceDate();
646} 652}
647 653
648void MonthViewCell::deselect() 654void MonthViewCell::deselect()
649{ 655{
650 mItemList->clearSelection(); 656 mItemList->clearSelection();
651 enableScrollBars( false ); 657 enableScrollBars( false );
652 // updateCell(); 658 // updateCell();
653} 659}
654void MonthViewCell::select() 660void MonthViewCell::select()
655{ 661{
656 ;// updateCell(); 662 ;// updateCell();
657} 663}
658 664
659void MonthViewCell::resizeEvent ( QResizeEvent * ) 665void MonthViewCell::resizeEvent ( QResizeEvent * )
660{ 666{
661 if ( !mMonthView->isUpdatePossible() ) 667 if ( !mMonthView->isUpdatePossible() )
662 return; 668 return;
663#ifndef DESKTOP_VERSION 669#ifndef DESKTOP_VERSION
664 if ( !isVisible() ){ 670 if ( !isVisible() ){
665 return; 671 return;
666 } 672 }
667#endif 673#endif
668 int size = height() - mLabel->height(); 674 int size = height() - mLabel->height();
669 if ( size > 0 ) 675 if ( size > 0 )
670 mItemList->verticalScrollBar()->setMaximumHeight( size ); 676 mItemList->verticalScrollBar()->setMaximumHeight( size );
671 size = width() - mLabel->width(); 677 size = width() - mLabel->width();
672 if ( size > 0 ) 678 if ( size > 0 )
673 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 679 mItemList->horizontalScrollBar()->setMaximumWidth( size );
674 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 680 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
675 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 681 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
676} 682}
677 683
678void MonthViewCell::defaultAction( QListBoxItem *item ) 684void MonthViewCell::defaultAction( QListBoxItem *item )
679{ 685{
680 if ( !item ) return; 686 if ( !item ) return;
681 687
682 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 688 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
683 Incidence *incidence = eventItem->incidence(); 689 Incidence *incidence = eventItem->incidence();
684 if ( incidence ) mMonthView->defaultAction( incidence ); 690 if ( incidence ) mMonthView->defaultAction( incidence );
685} 691}
686void MonthViewCell::showDay() 692void MonthViewCell::showDay()
687{ 693{
688 emit showDaySignal( date() ); 694 emit showDaySignal( date() );
689} 695}
690void MonthViewCell::newEvent() 696void MonthViewCell::newEvent()
691{ 697{
692 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 698 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
693 emit newEventSignal( dt ); 699 emit newEventSignal( dt );
694} 700}
695void MonthViewCell::cellClicked( QListBoxItem *item ) 701void MonthViewCell::cellClicked( QListBoxItem *item )
696{ 702{
697 static QListBoxItem * lastClicked = 0; 703 static QListBoxItem * lastClicked = 0;
698 if ( item == 0 ) { 704 if ( item == 0 ) {
699 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 705 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
700 emit newEventSignal( dt ); 706 emit newEventSignal( dt );
701 return; 707 return;
702 } 708 }
703 /* 709 /*
704 if ( lastClicked ) 710 if ( lastClicked )
705 if ( ! item ) { 711 if ( ! item ) {
706 if ( lastClicked->listBox() != item->listBox() ) 712 if ( lastClicked->listBox() != item->listBox() )
707 lastClicked->listBox()->clearSelection(); 713 lastClicked->listBox()->clearSelection();
708 } 714 }
709 */ 715 */
710 716
711 mMonthView->setSelectedCell( this ); 717 mMonthView->setSelectedCell( this );
712 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); 718 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
713 select(); 719 select();
714} 720}
715 721
716void MonthViewCell::contextMenu( QListBoxItem *item ) 722void MonthViewCell::contextMenu( QListBoxItem *item )
717{ 723{
718 if ( !item ) return; 724 if ( !item ) return;
719 725
720 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 726 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
721 Incidence *incidence = eventItem->incidence(); 727 Incidence *incidence = eventItem->incidence();
722 if ( incidence ) mMonthView->showContextMenu( incidence ); 728 if ( incidence ) mMonthView->showContextMenu( incidence );
723} 729}
724 730
725void MonthViewCell::selection( QListBoxItem *item ) 731void MonthViewCell::selection( QListBoxItem *item )
726{ 732{
727 if ( !item ) return; 733 if ( !item ) return;
728 734
729 mMonthView->setSelectedCell( this ); 735 mMonthView->setSelectedCell( this );
730} 736}
731 737
732 738
733// ******************************************************************************* 739// *******************************************************************************
734// ******************************************************************************* 740// *******************************************************************************
735// ******************************************************************************* 741// *******************************************************************************
736 742
737 743
738KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 744KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
739 : KOEventView( calendar, parent, name ), 745 : KOEventView( calendar, parent, name ),
740 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 746 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
741 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 747 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
742{ 748{
743 749
744 updatePossible = false; 750 updatePossible = false;
745 mCells.setAutoDelete( true ); 751 mCells.setAutoDelete( true );
746 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 752 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
747 // mDayLayout = new QGridLayout( this ); 753 // mDayLayout = new QGridLayout( this );
748 // create the day of the week labels (Sun, Mon, etc) and add them to 754 // create the day of the week labels (Sun, Mon, etc) and add them to
749 // the layout. 755 // the layout.
750 mDayLabels.resize( mDaysPerWeek ); 756 mDayLabels.resize( mDaysPerWeek );
751 QFont bfont = font(); 757 QFont bfont = font();
752 if ( QApplication::desktop()->width() < 650 ) { 758 if ( QApplication::desktop()->width() < 650 ) {
753 bfont.setPointSize( bfont.pointSize() - 2 ); 759 bfont.setPointSize( bfont.pointSize() - 2 );
754 } 760 }
755 bfont.setBold( true ); 761 bfont.setBold( true );
756 int i; 762 int i;
757 763
758 for( i = 0; i < mDaysPerWeek; i++ ) { 764 for( i = 0; i < mDaysPerWeek; i++ ) {
759 QLabel *label = new QLabel( this ); 765 QLabel *label = new QLabel( this );
760 label->setFont(bfont); 766 label->setFont(bfont);
761 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 767 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
762 label->setLineWidth(1); 768 label->setLineWidth(1);
763 label->setAlignment(AlignCenter); 769 label->setAlignment(AlignCenter);
764 mDayLabels.insert( i, label ); 770 mDayLabels.insert( i, label );
765 }
766
767 bfont.setBold( false );
768 mWeekLabels.resize( mNumWeeks+1 );
769 for( i = 0; i < mNumWeeks+1; i++ ) {
770 KOWeekButton *label = new KOWeekButton( this );
771 label->setFont(bfont);
772 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
773 label->setFlat(true);
774 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
775 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
776 //label->setLineWidth(1);
777 //label->setAlignment(AlignCenter);
778 mWeekLabels.insert( i, label );
779 }
780 mWeekLabels[mNumWeeks]->setText( i18n("W"));
781 int row, col;
782 mCells.resize( mNumCells );
783 for( row = 0; row < mNumWeeks; ++row ) {
784 for( col = 0; col < mDaysPerWeek; ++col ) {
785 MonthViewCell *cell = new MonthViewCell( this );
786 mCells.insert( row * mDaysPerWeek + col, cell );
787
788 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
789 SLOT( defaultAction( Incidence * ) ) );
790 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
791 SIGNAL( newEventSignal( QDateTime ) ) );
792 connect( cell, SIGNAL( showDaySignal( QDate ) ),
793 SIGNAL( showDaySignal( QDate ) ) );
794 } 771 }
795 }
796 772
797 mContextMenu = eventPopup(); 773 bfont.setBold( false );
798 // updateConfig(); //useless here 774 mWeekLabels.resize( mNumWeeks+1 );
775 for( i = 0; i < mNumWeeks+1; i++ ) {
776 KOWeekButton *label = new KOWeekButton( this );
777 label->setFont(bfont);
778 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
779 label->setFlat(true);
780 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
781 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
782 //label->setLineWidth(1);
783 //label->setAlignment(AlignCenter);
784 mWeekLabels.insert( i, label );
785 }
786 mWeekLabels[mNumWeeks]->setText( i18n("W"));
787 int row, col;
788 mCells.resize( mNumCells );
789 for( row = 0; row < mNumWeeks; ++row ) {
790 for( col = 0; col < mDaysPerWeek; ++col ) {
791 MonthViewCell *cell = new MonthViewCell( this );
792 mCells.insert( row * mDaysPerWeek + col, cell );
793
794 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
795 SLOT( defaultAction( Incidence * ) ) );
796 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
797 SIGNAL( newEventSignal( QDateTime ) ) );
798 connect( cell, SIGNAL( showDaySignal( QDate ) ),
799 SIGNAL( showDaySignal( QDate ) ) );
800 }
801 }
799 802
800 emit incidenceSelected( 0 ); 803 mContextMenu = eventPopup();
804 // updateConfig(); //useless here
805
806 emit incidenceSelected( 0 );
801} 807}
802 808
803KOMonthView::~KOMonthView() 809KOMonthView::~KOMonthView()
804{ 810{
805 delete mContextMenu; 811 delete mContextMenu;
806} 812}
807 813
808int KOMonthView::maxDatesHint() 814int KOMonthView::maxDatesHint()
809{ 815{
810 return mNumCells; 816 return mNumCells;
811} 817}
812 818
813int KOMonthView::currentDateCount() 819int KOMonthView::currentDateCount()
814{ 820{
815 return mNumCells; 821 return mNumCells;
816} 822}
817 823
818QPtrList<Incidence> KOMonthView::selectedIncidences() 824QPtrList<Incidence> KOMonthView::selectedIncidences()
819{ 825{
820 QPtrList<Incidence> selected; 826 QPtrList<Incidence> selected;
821 827
822 if ( mSelectedCell ) { 828 if ( mSelectedCell ) {
823 Incidence *incidence = mSelectedCell->selectedIncidence(); 829 Incidence *incidence = mSelectedCell->selectedIncidence();
824 if ( incidence ) selected.append( incidence ); 830 if ( incidence ) selected.append( incidence );
825 } 831 }
826 832
827 return selected; 833 return selected;
828} 834}
829 835
830DateList KOMonthView::selectedDates() 836DateList KOMonthView::selectedDates()
831{ 837{
832 DateList selected; 838 DateList selected;
833 839
834 if ( mSelectedCell ) { 840 if ( mSelectedCell ) {
835 QDate qd = mSelectedCell->selectedIncidenceDate(); 841 QDate qd = mSelectedCell->selectedIncidenceDate();
836 if ( qd.isValid() ) selected.append( qd ); 842 if ( qd.isValid() ) selected.append( qd );
837 } 843 }
838 844
839 return selected; 845 return selected;
840} 846}
841 847
842void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 848void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
843 const QDate &td) 849 const QDate &td)
844{ 850{
845#ifndef KORG_NOPRINTER 851#ifndef KORG_NOPRINTER
846 calPrinter->preview(CalPrinter::Month, fd, td); 852 calPrinter->preview(CalPrinter::Month, fd, td);
847#endif 853#endif
848} 854}
849 855
850void KOMonthView::updateConfig() 856void KOMonthView::updateConfig()
851{ 857{
852 858
853 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 859 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
854 860
855 QFontMetrics fontmetric(mDayLabels[0]->font()); 861 QFontMetrics fontmetric(mDayLabels[0]->font());
856 mWidthLongDayLabel = 0; 862 mWidthLongDayLabel = 0;
857 863
858 for (int i = 0; i < 7; i++) { 864 for (int i = 0; i < 7; i++) {
859 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 865 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
860 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 866 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
861 } 867 }
862 bool temp = mShowSatSunComp ; 868 bool temp = mShowSatSunComp ;
863 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 869 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
864 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 870 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
865 computeLayout(); 871 computeLayout();
866 updateDayLabels(); 872 updateDayLabels();
867 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 873 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
868 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 874 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
869 //resizeEvent( 0 ); 875 //resizeEvent( 0 );
870 for (uint i = 0; i < mCells.count(); ++i) { 876 for (uint i = 0; i < mCells.count(); ++i) {
871 mCells[i]->updateConfig(); 877 mCells[i]->updateConfig();
872 } 878 }
873#ifdef DESKTOP_VERSION 879#ifdef DESKTOP_VERSION
874 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 880 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
875#endif 881#endif
876} 882}
877 883
878void KOMonthView::updateDayLabels() 884void KOMonthView::updateDayLabels()
879{ 885{
880 886
881 for (int i = 0; i < 7; i++) { 887 for (int i = 0; i < 7; i++) {
882 if (mWeekStartsMonday) { 888 if (mWeekStartsMonday) {
883 bool show = mShortDayLabels; 889 bool show = mShortDayLabels;
884 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 890 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
885 show = true; 891 show = true;
886 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 892 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
887 } else { 893 } else {
888 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 894 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
889 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 895 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
890 896
897 }
891 } 898 }
892 }
893} 899}
894 900
895void KOMonthView::showDates(const QDate &start, const QDate &) 901void KOMonthView::showDates(const QDate &start, const QDate &)
896{ 902{
897// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 903 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
898 904
899 905
900 mStartDate = start; 906 mStartDate = start;
901 907
902 int startWeekDay = mWeekStartsMonday ? 1 : 7; 908 int startWeekDay = mWeekStartsMonday ? 1 : 7;
903 909
904 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 910 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
905 mStartDate = mStartDate.addDays( -1 ); 911 mStartDate = mStartDate.addDays( -1 );
906 } 912 }
907 913
908 bool primary = false; 914 bool primary = false;
909 uint i; 915 uint i;
910 for( i = 0; i < mCells.size(); ++i ) { 916 for( i = 0; i < mCells.size(); ++i ) {
911 QDate date = mStartDate.addDays( i ); 917 QDate date = mStartDate.addDays( i );
912 mCells[i]->setDate( date ); 918 mCells[i]->setDate( date );
913 919
914#ifndef KORG_NOPLUGINS 920#ifndef KORG_NOPLUGINS
915 // add holiday, if present 921 // add holiday, if present
916 QString hstring(KOCore::self()->holiday(date)); 922 QString hstring(KOCore::self()->holiday(date));
917 mCells[i]->setHoliday( hstring ); 923 mCells[i]->setHoliday( hstring );
918#endif 924#endif
919 925
920 } 926 }
921 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 927 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
922 for( i = 0; i < 6; ++i ) { 928 for( i = 0; i < 6; ++i ) {
923 int wno; 929 int wno;
924 // remember, according to ISO 8601, the first week of the year is the 930 // remember, according to ISO 8601, the first week of the year is the
925 // first week that contains a thursday. Thus we must subtract off 4, 931 // first week that contains a thursday. Thus we must subtract off 4,
926 // not just 1. 932 // not just 1.
927 int dayOfYear = date.dayOfYear(); 933 int dayOfYear = date.dayOfYear();
928 if (dayOfYear % 7 != 0) 934 if (dayOfYear % 7 != 0)
929 wno = dayOfYear / 7 + 1; 935 wno = dayOfYear / 7 + 1;
930 else 936 else
931 wno =dayOfYear / 7; 937 wno =dayOfYear / 7;
932 mWeekLabels[i]->setWeekNum( wno ); 938 mWeekLabels[i]->setWeekNum( wno );
933 date = date.addDays( 7 ); 939 date = date.addDays( 7 );
934 } 940 }
935 updateView(); 941 updateView();
936} 942}
937 943
938void KOMonthView::showEvents(QPtrList<Event>) 944void KOMonthView::showEvents(QPtrList<Event>)
939{ 945{
940 qDebug("KOMonthView::selectEvents is not implemented yet. "); 946 qDebug("KOMonthView::selectEvents is not implemented yet. ");
941} 947}
942 948
943void KOMonthView::changeEventDisplay(Event *, int) 949void KOMonthView::changeEventDisplay(Event *, int)
944{ 950{
945 // this should be re-written to be much more efficient, but this 951 // this should be re-written to be much more efficient, but this
946 // quick-and-dirty-hack gets the job done for right now. 952 // quick-and-dirty-hack gets the job done for right now.
947 updateView(); 953 updateView();
948} 954}
949 955
950void KOMonthView::updateView() 956void KOMonthView::updateView()
951{ 957{
958
952 if ( !updatePossible ) 959 if ( !updatePossible )
953 return; 960 return;
954 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 961 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
955 int i; 962 int i;
956 for( i = 0; i < mCells.count(); ++i ) { 963 for( i = 0; i < mCells.count(); ++i ) {
957 mCells[i]->updateCell(); 964 mCells[i]->updateCell();
958 } 965 }
959 966
960 //qDebug("KOMonthView::updateView() "); 967 //qDebug("KOMonthView::updateView() ");
961 processSelectionChange(); 968 processSelectionChange();
962 // qDebug("---------------------------------------------------------------------+ "); 969 // qDebug("---------------------------------------------------------------------+ ");
970 setFocus();
963} 971}
964 972
965void KOMonthView::resizeEvent(QResizeEvent * e) 973void KOMonthView::resizeEvent(QResizeEvent * e)
966{ 974{
967 computeLayout(); 975 computeLayout();
968} 976}
969void KOMonthView::computeLayout() 977void KOMonthView::computeLayout()
970{ 978{
971 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 979 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
972 // note this only changes the text if the requested size crosses the 980 // note this only changes the text if the requested size crosses the
973 // threshold between big enough to support the full name and not big 981 // threshold between big enough to support the full name and not big
974 // enough. 982 // enough.
975 983
976 int daysToShow = 7; 984 int daysToShow = 7;
977 bool combinedSatSun = false; 985 bool combinedSatSun = false;
978 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 986 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
979 daysToShow = 6; 987 daysToShow = 6;
980 combinedSatSun = true; 988 combinedSatSun = true;
981 } 989 }
982 int tWid = topLevelWidget()->size().width(); 990 int tWid = topLevelWidget()->size().width();
983 int tHei = topLevelWidget()->size().height(); 991 int tHei = topLevelWidget()->size().height();
984 992
985 int wid = size().width();//e 993 int wid = size().width();//e
986 int hei = size().height()-1; 994 int hei = size().height()-1;
987 995
988 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 996 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
989 return; 997 return;
990 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 998 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
991 QFontMetrics fm ( mWeekLabels[0]->font() ); 999 QFontMetrics fm ( mWeekLabels[0]->font() );
992 int weeklabelwid = fm.width( "888" ); 1000 int weeklabelwid = fm.width( "888" );
993 wid -= weeklabelwid; 1001 wid -= weeklabelwid;
994 1002
995 int colWid = wid / daysToShow; 1003 int colWid = wid / daysToShow;
996 int lastCol = wid - ( colWid*6 ); 1004 int lastCol = wid - ( colWid*6 );
997 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1005 int dayLabelHei = mDayLabels[0]->sizeHint().height();
998 int cellHei = (hei - dayLabelHei) /6; 1006 int cellHei = (hei - dayLabelHei) /6;
999 int colModulo = wid % daysToShow; 1007 int colModulo = wid % daysToShow;
1000 int rowModulo = (hei- dayLabelHei) % 6; 1008 int rowModulo = (hei- dayLabelHei) % 6;
1001 //qDebug("rowmod %d ", rowModulo); 1009 //qDebug("rowmod %d ", rowModulo);
1002 int i; 1010 int i;
1003 int x,y,w,h; 1011 int x,y,w,h;
1004 x= 0; 1012 x= 0;
1005 y= 0; 1013 y= 0;
1006 w = colWid; 1014 w = colWid;
1007 h = dayLabelHei ; 1015 h = dayLabelHei ;
1008 for ( i = 0; i < 7; i++) { 1016 for ( i = 0; i < 7; i++) {
1009 if ( i == daysToShow-colModulo ) 1017 if ( i == daysToShow-colModulo )
1010 ++w; 1018 ++w;
1011 if ( combinedSatSun ) { 1019 if ( combinedSatSun ) {
1012 if ( i >= daysToShow-1 ) { 1020 if ( i >= daysToShow-1 ) {
1013 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1021 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1014 x -= w/2 ; 1022 x -= w/2 ;
1015 } 1023 }
1016 else 1024 else
1017 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1025 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1018 } else 1026 } else
1019 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1027 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1020 x += w; 1028 x += w;
1021 } 1029 }
1022 x= 0; 1030 x= 0;
@@ -1028,102 +1036,119 @@ void KOMonthView::computeLayout()
1028 w = colWid; 1036 w = colWid;
1029 if ( ((i) % 7) >= 7-colModulo ) { 1037 if ( ((i) % 7) >= 7-colModulo ) {
1030 ++w; 1038 ++w;
1031 } 1039 }
1032 if ( i == (6-rowModulo)*7) 1040 if ( i == (6-rowModulo)*7)
1033 ++h; 1041 ++h;
1034 if ( combinedSatSun ) { 1042 if ( combinedSatSun ) {
1035 if ( (i)%7 >= daysToShow-1 ) { 1043 if ( (i)%7 >= daysToShow-1 ) {
1036 if ( (i)%7 == daysToShow-1 ) { 1044 if ( (i)%7 == daysToShow-1 ) {
1037 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1045 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1038 x -= w ;y += h/2; 1046 x -= w ;y += h/2;
1039 } else { 1047 } else {
1040 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1048 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1041 y -= h/2; 1049 y -= h/2;
1042 } 1050 }
1043 } else 1051 } else
1044 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1052 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1045 1053
1046 } 1054 }
1047 else 1055 else
1048 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1056 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1049 x += w; 1057 x += w;
1050 if ( x + w/2 > wid ) { 1058 if ( x + w/2 > wid ) {
1051 x = 0; 1059 x = 0;
1052 y += h; 1060 y += h;
1053 } 1061 }
1054 } 1062 }
1055 y= dayLabelHei; 1063 y= dayLabelHei;
1056 h = cellHei ; 1064 h = cellHei ;
1057 for ( i = 0; i < 6; i++) { 1065 for ( i = 0; i < 6; i++) {
1058 if ( i == (6-rowModulo)) 1066 if ( i == (6-rowModulo))
1059 ++h; 1067 ++h;
1060 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1068 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1061 y += h; 1069 y += h;
1062 } 1070 }
1063 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1071 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1064 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1072 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1065 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1073 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1066 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1074 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1067 updateDayLabels(); 1075 updateDayLabels();
1068 bool forceUpdate = !updatePossible; 1076 bool forceUpdate = !updatePossible;
1069 updatePossible = true; 1077 updatePossible = true;
1070 if ( forceUpdate ) 1078 if ( forceUpdate )
1071 updateView(); 1079 updateView();
1072} 1080}
1073 1081
1074void KOMonthView::showContextMenu( Incidence *incidence ) 1082void KOMonthView::showContextMenu( Incidence *incidence )
1075{ 1083{
1076 mContextMenu->showIncidencePopup(incidence); 1084 mContextMenu->showIncidencePopup(incidence);
1077 /* 1085 /*
1078 if( incidence && incidence->type() == "Event" ) { 1086 if( incidence && incidence->type() == "Event" ) {
1079 Event *event = static_cast<Event *>(incidence); 1087 Event *event = static_cast<Event *>(incidence);
1080 mContextMenu->showEventPopup(event); 1088 mContextMenu->showEventPopup(event);
1081 } else { 1089 } else {
1082 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1090 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1083 } 1091 }
1084 */ 1092 */
1085} 1093}
1086MonthViewCell * KOMonthView::selectedCell( ) 1094MonthViewCell * KOMonthView::selectedCell( )
1087{ 1095{
1088 return mSelectedCell; 1096 return mSelectedCell;
1089} 1097}
1090void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1098void KOMonthView::setSelectedCell( MonthViewCell *cell )
1091{ 1099{
1092 // qDebug("KOMonthView::setSelectedCell "); 1100 // qDebug("KOMonthView::setSelectedCell ");
1093 if ( mSelectedCell && mSelectedCell != cell ) { 1101 if ( mSelectedCell && mSelectedCell != cell ) {
1094 MonthViewCell * mvc = mSelectedCell; 1102 MonthViewCell * mvc = mSelectedCell;
1095 mSelectedCell = cell; 1103 mSelectedCell = cell;
1096 mvc->deselect(); 1104 mvc->deselect();
1097 } else 1105 } else
1098 mSelectedCell = cell; 1106 mSelectedCell = cell;
1099 // if ( mSelectedCell ) 1107 // if ( mSelectedCell )
1100// mSelectedCell->select(); 1108 // mSelectedCell->select();
1101 if ( !mSelectedCell ) 1109 if ( !mSelectedCell )
1102 emit incidenceSelected( 0 ); 1110 emit incidenceSelected( 0 );
1103 else 1111 else
1104 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1112 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1105} 1113}
1106 1114
1107void KOMonthView::processSelectionChange() 1115void KOMonthView::processSelectionChange()
1108{ 1116{
1109 QPtrList<Incidence> incidences = selectedIncidences(); 1117 QPtrList<Incidence> incidences = selectedIncidences();
1110 if (incidences.count() > 0) { 1118 if (incidences.count() > 0) {
1111 emit incidenceSelected( incidences.first() ); 1119 emit incidenceSelected( incidences.first() );
1112 } else { 1120 } else {
1113 emit incidenceSelected( 0 ); 1121 emit incidenceSelected( 0 );
1114 } 1122 }
1115} 1123}
1116 1124
1117void KOMonthView::clearSelection() 1125void KOMonthView::clearSelection()
1118{ 1126{
1119 if ( mSelectedCell ) { 1127 if ( mSelectedCell ) {
1120 mSelectedCell->deselect(); 1128 mSelectedCell->deselect();
1121 mSelectedCell = 0; 1129 mSelectedCell = 0;
1122 } 1130 }
1123} 1131}
1124void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1132void KOMonthView::keyPressEvent ( QKeyEvent * e )
1125{ 1133{
1126 1134 switch(e->key()) {
1127 e->ignore(); 1135 break;
1128 1136 case Key_Up:
1137 {
1138 emit prevMonth();
1139 setFocus();
1140 }
1141 e->accept();
1142 break;
1143 case Key_Down:
1144 {
1145 emit nextMonth();
1146 setFocus();
1147 }
1148 e->accept();
1149 break;
1150 default:
1151 e->ignore();
1152 break;
1153 }
1129} 1154}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index a965bf3..50903b3 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -192,81 +192,83 @@ class MonthViewCell : public QWidget
192 QPalette getPalette (); 192 QPalette getPalette ();
193 void keyPressEvent ( QKeyEvent * ) ; 193 void keyPressEvent ( QKeyEvent * ) ;
194 194
195}; 195};
196 196
197 197
198class KOMonthView: public KOEventView 198class KOMonthView: public KOEventView
199{ 199{
200 Q_OBJECT 200 Q_OBJECT
201 public: 201 public:
202 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 202 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
203 ~KOMonthView(); 203 ~KOMonthView();
204 204
205 /** Returns maximum number of days supported by the komonthview */ 205 /** Returns maximum number of days supported by the komonthview */
206 virtual int maxDatesHint(); 206 virtual int maxDatesHint();
207 207
208 /** Returns number of currently shown dates. */ 208 /** Returns number of currently shown dates. */
209 virtual int currentDateCount(); 209 virtual int currentDateCount();
210 210
211 /** returns the currently selected events */ 211 /** returns the currently selected events */
212 virtual QPtrList<Incidence> selectedIncidences(); 212 virtual QPtrList<Incidence> selectedIncidences();
213 213
214 /** returns dates of the currently selected events */ 214 /** returns dates of the currently selected events */
215 virtual DateList selectedDates(); 215 virtual DateList selectedDates();
216 216
217 virtual void printPreview(CalPrinter *calPrinter, 217 virtual void printPreview(CalPrinter *calPrinter,
218 const QDate &, const QDate &); 218 const QDate &, const QDate &);
219 bool isMonthView() { return true; } 219 bool isMonthView() { return true; }
220 bool isUpdatePossible() { return updatePossible; } 220 bool isUpdatePossible() { return updatePossible; }
221 221
222 MonthViewCell * selectedCell(); 222 MonthViewCell * selectedCell();
223 public slots: 223 public slots:
224 virtual void updateView(); 224 virtual void updateView();
225 virtual void updateConfig(); 225 virtual void updateConfig();
226 virtual void showDates(const QDate &start, const QDate &end); 226 virtual void showDates(const QDate &start, const QDate &end);
227 virtual void showEvents(QPtrList<Event> eventList); 227 virtual void showEvents(QPtrList<Event> eventList);
228 228
229 void changeEventDisplay(Event *, int); 229 void changeEventDisplay(Event *, int);
230 230
231 void clearSelection(); 231 void clearSelection();
232 232
233 void showContextMenu( Incidence * ); 233 void showContextMenu( Incidence * );
234 234
235 void setSelectedCell( MonthViewCell * ); 235 void setSelectedCell( MonthViewCell * );
236 236
237 protected slots: 237 protected slots:
238 void processSelectionChange(); 238 void processSelectionChange();
239 signals: 239 signals:
240 void nextMonth();
241 void prevMonth();
240 void selectWeekNum ( int ); 242 void selectWeekNum ( int );
241 void showDaySignal( QDate ); 243 void showDaySignal( QDate );
242 protected: 244 protected:
243 void resizeEvent(QResizeEvent *); 245 void resizeEvent(QResizeEvent *);
244 void viewChanged(); 246 void viewChanged();
245 void updateDayLabels(); 247 void updateDayLabels();
246 248
247 private: 249 private:
248 bool updatePossible; 250 bool updatePossible;
249 int mDaysPerWeek; 251 int mDaysPerWeek;
250 int mNumWeeks; 252 int mNumWeeks;
251 int mNumCells; 253 int mNumCells;
252 bool mWeekStartsMonday; 254 bool mWeekStartsMonday;
253 bool mShowSatSunComp; 255 bool mShowSatSunComp;
254 void computeLayout(); 256 void computeLayout();
255 257
256 QPtrVector<MonthViewCell> mCells; 258 QPtrVector<MonthViewCell> mCells;
257 QPtrVector<QLabel> mDayLabels; 259 QPtrVector<QLabel> mDayLabels;
258 QPtrVector<KOWeekButton> mWeekLabels; 260 QPtrVector<KOWeekButton> mWeekLabels;
259 261
260 bool mShortDayLabels; 262 bool mShortDayLabels;
261 int mWidthLongDayLabel; 263 int mWidthLongDayLabel;
262 264
263 QDate mStartDate; 265 QDate mStartDate;
264 266
265 MonthViewCell *mSelectedCell; 267 MonthViewCell *mSelectedCell;
266 268
267 KOEventPopupMenu *mContextMenu; 269 KOEventPopupMenu *mContextMenu;
268 void keyPressEvent ( QKeyEvent * ) ; 270 void keyPressEvent ( QKeyEvent * ) ;
269 271
270}; 272};
271 273
272#endif 274#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 94c459b..e8d5ab1 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -412,96 +412,100 @@ void KOViewManager::showNextXView()
412 globalFlagBlockAgenda = 1; 412 globalFlagBlockAgenda = 1;
413 if ( mCurrentAgendaView != 3 ) 413 if ( mCurrentAgendaView != 3 )
414 mCurrentAgendaView = -1; 414 mCurrentAgendaView = -1;
415 showAgendaView(KOPrefs::instance()->mFullViewMonth); 415 showAgendaView(KOPrefs::instance()->mFullViewMonth);
416 globalFlagBlockAgenda = 2; 416 globalFlagBlockAgenda = 2;
417 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 417 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
418 KOPrefs::instance()->mNextXDays ); 418 KOPrefs::instance()->mNextXDays );
419 mFlagShowNextxDays = true; 419 mFlagShowNextxDays = true;
420 mCurrentAgendaView = 3 ; 420 mCurrentAgendaView = 3 ;
421} 421}
422bool KOViewManager::showsNextDays() 422bool KOViewManager::showsNextDays()
423{ 423{
424 return mFlagShowNextxDays; 424 return mFlagShowNextxDays;
425} 425}
426void KOViewManager::showMonthView() 426void KOViewManager::showMonthView()
427{ 427{
428 if (!mMonthView) { 428 if (!mMonthView) {
429 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 429 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
430 430
431 addView(mMonthView); 431 addView(mMonthView);
432 // mMonthView->show(); 432 // mMonthView->show();
433 // SIGNALS/SLOTS FOR MONTH VIEW 433 // SIGNALS/SLOTS FOR MONTH VIEW
434 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 434 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
435 mMainView, SLOT(newEvent(QDateTime))); 435 mMainView, SLOT(newEvent(QDateTime)));
436 436
437 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 437 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
438 mMainView, SLOT(showIncidence(Incidence *))); 438 mMainView, SLOT(showIncidence(Incidence *)));
439 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 439 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
440 mMainView, SLOT(editIncidence(Incidence *))); 440 mMainView, SLOT(editIncidence(Incidence *)));
441 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 441 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
442 mMainView, SLOT(deleteIncidence(Incidence *))); 442 mMainView, SLOT(deleteIncidence(Incidence *)));
443 443
444 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 444 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
445 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 445 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
446 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 446 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
447 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 447 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
448 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 448 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
449 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 449 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
450 450
451 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 451 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
452 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 452 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
453 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 453 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
454 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 454 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
455 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 455 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
456 mMainView, SLOT ( selectWeekNum( int ) ) ); 456 mMainView, SLOT ( selectWeekNum( int ) ) );
457 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 457 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
458 mMainView, SLOT ( showDay( QDate ) ) ); 458 mMainView, SLOT ( showDay( QDate ) ) );
459 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 459 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
460 connect( mMonthView, SIGNAL(nextMonth() ),
461 mMainView->navigatorBar(), SIGNAL(goNextMonth() ) );
462 connect( mMonthView, SIGNAL(prevMonth() ),
463 mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) );
460 mMonthView->updateConfig(); 464 mMonthView->updateConfig();
461 } 465 }
462 466
463 globalFlagBlockAgenda = 1; 467 globalFlagBlockAgenda = 1;
464 //mFlagShowNextxDays = false; 468 //mFlagShowNextxDays = false;
465 // if(mMonthView == mCurrentView) return; 469 // if(mMonthView == mCurrentView) return;
466 mMainView->dateNavigator()->selectMonth(); 470 mMainView->dateNavigator()->selectMonth();
467 // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); 471 // DateList tmpList = mMainView->dateNavigator()->selectedDates( );
468 //mMonthView->showDates(tmpList.first(), tmpList.last()); 472 //mMonthView->showDates(tmpList.first(), tmpList.last());
469 473
470 showView(mMonthView, true ); 474 showView(mMonthView, true );
471 475
472} 476}
473 477
474void KOViewManager::showTodoView() 478void KOViewManager::showTodoView()
475{ 479{
476 //mFlagShowNextxDays = false; 480 //mFlagShowNextxDays = false;
477 if ( !mTodoView ) { 481 if ( !mTodoView ) {
478 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 482 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
479 "KOViewManager::TodoView" ); 483 "KOViewManager::TodoView" );
480 484
481 addView( mTodoView ); 485 addView( mTodoView );
482 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 486 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
483 487
484 // SIGNALS/SLOTS FOR TODO VIEW 488 // SIGNALS/SLOTS FOR TODO VIEW
485 connect( mTodoView, SIGNAL( newTodoSignal() ), 489 connect( mTodoView, SIGNAL( newTodoSignal() ),
486 mMainView, SLOT( newTodo() ) ); 490 mMainView, SLOT( newTodo() ) );
487 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 491 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
488 mMainView, SLOT( newSubTodo( Todo *) ) ); 492 mMainView, SLOT( newSubTodo( Todo *) ) );
489 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 493 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
490 mMainView, SLOT( showTodo( Todo * ) ) ); 494 mMainView, SLOT( showTodo( Todo * ) ) );
491 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 495 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
492 mMainView, SLOT( editTodo( Todo * ) ) ); 496 mMainView, SLOT( editTodo( Todo * ) ) );
493 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 497 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
494 mMainView, SLOT( deleteTodo( Todo * ) ) ); 498 mMainView, SLOT( deleteTodo( Todo * ) ) );
495 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 499 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
496 mMainView, SLOT( purgeCompleted() ) ); 500 mMainView, SLOT( purgeCompleted() ) );
497 501
498 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 502 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
499 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 503 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
500 504
501 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 505 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
502 SLOT( updateConfig() ) ); 506 SLOT( updateConfig() ) );
503 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 507 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
504 SLOT( updateTodo( Todo *, int ) ) ); 508 SLOT( updateTodo( Todo *, int ) ) );
505 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 509 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
506 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 510 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
507 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 511 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 145b36c..950d2ec 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1691,97 +1691,97 @@ void MainWindow::configureToolBar( int item )
1691 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1691 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1692 KOPrefs *p = KOPrefs::instance(); 1692 KOPrefs *p = KOPrefs::instance();
1693 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1693 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1694 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1694 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1695 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1695 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1696 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1696 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1697 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1697 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1698 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1698 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1699 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1699 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1700 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1700 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1701 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1701 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1702 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1702 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1703 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1703 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1704 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1704 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1705 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1705 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1706 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1706 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1707 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1707 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1708 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1708 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1709 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1709 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1710 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1710 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1711 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1711 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1712 // initActions(); 1712 // initActions();
1713} 1713}
1714 1714
1715void MainWindow::setCaptionToDates() 1715void MainWindow::setCaptionToDates()
1716{ 1716{
1717 QString selDates; 1717 QString selDates;
1718 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1718 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1719 if (mView->startDate() < mView->endDate() ) 1719 if (mView->startDate() < mView->endDate() )
1720 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1720 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1721 else { 1721 else {
1722 QString addString; 1722 QString addString;
1723 if ( mView->startDate() == QDateTime::currentDateTime().date() ) 1723 if ( mView->startDate() == QDateTime::currentDateTime().date() )
1724 addString = i18n("Today"); 1724 addString = i18n("Today");
1725 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) 1725 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) )
1726 addString = i18n("Tomorrow"); 1726 addString = i18n("Tomorrow");
1727 if ( !addString.isEmpty() ) 1727 if ( !addString.isEmpty() )
1728 selDates = addString+", "+selDates ; 1728 selDates = addString+", "+selDates ;
1729 } 1729 }
1730 setCaption( i18n("Dates: ") + selDates ); 1730 setCaption( i18n("Dates: ") + selDates );
1731 1731
1732} 1732}
1733void MainWindow::showConfigureAgenda( ) 1733void MainWindow::showConfigureAgenda( )
1734{ 1734{
1735 int iii; 1735 int iii;
1736 for ( iii = 1;iii<= 10 ;++iii ){ 1736 for ( iii = 1;iii<= 10 ;++iii ){
1737 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 1737 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
1738 } 1738 }
1739 configureAgendaMenu->setItemChecked( KOPrefs::instance()->mHourSize, true ); 1739 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
1740} 1740}
1741void MainWindow::configureAgenda( int item ) 1741void MainWindow::configureAgenda( int item )
1742{ 1742{
1743 if ( KOPrefs::instance()->mHourSize == item ) 1743 if ( KOPrefs::instance()->mHourSize == item )
1744 return; 1744 return;
1745 KOPrefs::instance()->mHourSize=item; 1745 KOPrefs::instance()->mHourSize=item;
1746 mView->viewManager()->agendaView()->updateConfig(); 1746 mView->viewManager()->agendaView()->updateConfig();
1747} 1747}
1748 1748
1749void MainWindow::saveCalendar() 1749void MainWindow::saveCalendar()
1750{ 1750{
1751 QString fn = KOPrefs::instance()->mLastSaveFile; 1751 QString fn = KOPrefs::instance()->mLastSaveFile;
1752 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1752 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1753 1753
1754 if ( fn == "" ) 1754 if ( fn == "" )
1755 return; 1755 return;
1756 QFileInfo info; 1756 QFileInfo info;
1757 info.setFile( fn ); 1757 info.setFile( fn );
1758 QString mes; 1758 QString mes;
1759 bool createbup = true; 1759 bool createbup = true;
1760 if ( info. exists() ) { 1760 if ( info. exists() ) {
1761 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1761 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1762 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1762 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1763 i18n("Overwrite!"), i18n("Cancel"), 0, 1763 i18n("Overwrite!"), i18n("Cancel"), 0,
1764 0, 1 ); 1764 0, 1 );
1765 if ( result != 0 ) { 1765 if ( result != 0 ) {
1766 createbup = false; 1766 createbup = false;
1767 } 1767 }
1768 } 1768 }
1769 if ( createbup ) { 1769 if ( createbup ) {
1770 mView->saveCalendar( fn ); 1770 mView->saveCalendar( fn );
1771 mes = i18n("KO/Pi:Saved %1").arg(fn); 1771 mes = i18n("KO/Pi:Saved %1").arg(fn);
1772 KOPrefs::instance()->mLastSaveFile = fn; 1772 KOPrefs::instance()->mLastSaveFile = fn;
1773 setCaption(mes); 1773 setCaption(mes);
1774 } 1774 }
1775} 1775}
1776void MainWindow::loadCalendar() 1776void MainWindow::loadCalendar()
1777{ 1777{
1778 1778
1779 QString fn = KOPrefs::instance()->mLastLoadFile; 1779 QString fn = KOPrefs::instance()->mLastLoadFile;
1780 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1780 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1781 1781
1782 if ( fn == "" ) 1782 if ( fn == "" )
1783 return; 1783 return;
1784 QFileInfo info; 1784 QFileInfo info;
1785 info.setFile( fn ); 1785 info.setFile( fn );
1786 QString mess; 1786 QString mess;
1787 bool loadbup = true; 1787 bool loadbup = true;