summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-27 10:15:45 (UTC)
committer zautrix <zautrix>2005-01-27 10:15:45 (UTC)
commit1501a5d8a25e3474fb450d7e0b272feb14821d1c (patch) (unidiff)
tree70a8fcafed89f6dc8225af9908e845c0feecd7d9
parente4beb835276376646307bea74430008c332bd387 (diff)
downloadkdepimpi-1501a5d8a25e3474fb450d7e0b272feb14821d1c.zip
kdepimpi-1501a5d8a25e3474fb450d7e0b272feb14821d1c.tar.gz
kdepimpi-1501a5d8a25e3474fb450d7e0b272feb14821d1c.tar.bz2
fix
Diffstat (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,18 +1,18 @@
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*/
@@ -57,3 +57,3 @@
57#ifdef DESKTOP_VERSION 57#ifdef DESKTOP_VERSION
58 QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 58QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
59#endif 59#endif
@@ -66,6 +66,6 @@ public:
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:
@@ -99,3 +99,3 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
99 99
100 switch(e->key()) { 100 switch(e->key()) {
101 case Key_Right: 101 case Key_Right:
@@ -107,6 +107,6 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
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();
@@ -114,33 +114,39 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
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}
@@ -149,9 +155,9 @@ void 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}
@@ -160,7 +166,7 @@ void 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}
@@ -168,13 +174,13 @@ void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
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}
@@ -184,5 +190,5 @@ void MonthViewItem::paint(QPainter *p)
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
@@ -190,45 +196,45 @@ void MonthViewItem::paint(QPainter *p)
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
@@ -238,3 +244,3 @@ int MonthViewItem::height(const QListBox *lb) const
238{ 244{
239 return lb->fontMetrics().lineSpacing()+1; 245 return lb->fontMetrics().lineSpacing()+1;
240} 246}
@@ -244,19 +250,19 @@ int MonthViewItem::width(const QListBox *lb) const
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}
@@ -265,39 +271,39 @@ int MonthViewItem::width(const QListBox *lb) const
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}
@@ -306,4 +312,4 @@ QToolTipGroup *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}
@@ -313,4 +319,4 @@ void 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
@@ -318,3 +324,3 @@ void MonthViewCell::setDate( const QDate &date )
318 324
319 //resizeEvent( 0 ); 325 //resizeEvent( 0 );
320} 326}
@@ -323,3 +329,3 @@ QDate MonthViewCell::date() const
323{ 329{
324 return mDate; 330 return mDate;
325} 331}
@@ -362,3 +368,3 @@ bool MonthViewCell::isPrimary() const
362{ 368{
363 return mPrimary; 369 return mPrimary;
364} 370}
@@ -367,4 +373,4 @@ void MonthViewCell::setHoliday( bool holiday )
367{ 373{
368 mHoliday = holiday; 374 mHoliday = holiday;
369 //setMyPalette(); 375 //setMyPalette();
370} 376}
@@ -373,7 +379,7 @@ void 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}
@@ -382,3 +388,3 @@ void MonthViewCell::keyPressEvent ( QKeyEvent * e )
382 388
383 e->ignore(); 389 e->ignore();
384 390
@@ -398,4 +404,4 @@ void MonthViewCell::updateCell()
398 if ( !isVisible() ){ 404 if ( !isVisible() ){
399 return; 405 return;
400 } 406 }
401 */ 407 */
@@ -407,3 +413,3 @@ void MonthViewCell::updateCell()
407 } else { 413 } else {
408 mItemList->setLineWidth( 1 ); 414 mItemList->setLineWidth( 1 );
409 } 415 }
@@ -587,22 +593,22 @@ void MonthViewCell::updateConfig()
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}
@@ -611,9 +617,9 @@ void 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}
@@ -622,11 +628,11 @@ Incidence *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}
@@ -635,12 +641,12 @@ QDate 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}
@@ -649,5 +655,5 @@ void MonthViewCell::deselect()
649{ 655{
650 mItemList->clearSelection(); 656 mItemList->clearSelection();
651 enableScrollBars( false ); 657 enableScrollBars( false );
652 // updateCell(); 658 // updateCell();
653} 659}
@@ -679,7 +685,7 @@ void 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}
@@ -702,13 +708,13 @@ void MonthViewCell::cellClicked( QListBoxItem *item )
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}
@@ -717,7 +723,7 @@ void 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}
@@ -726,5 +732,5 @@ void 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}
@@ -743,59 +749,59 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
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}
@@ -804,3 +810,3 @@ KOMonthView::~KOMonthView()
804{ 810{
805 delete mContextMenu; 811 delete mContextMenu;
806} 812}
@@ -809,3 +815,3 @@ int KOMonthView::maxDatesHint()
809{ 815{
810 return mNumCells; 816 return mNumCells;
811} 817}
@@ -814,3 +820,3 @@ int KOMonthView::currentDateCount()
814{ 820{
815 return mNumCells; 821 return mNumCells;
816} 822}
@@ -819,10 +825,10 @@ QPtrList<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}
@@ -831,10 +837,10 @@ DateList 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}
@@ -845,3 +851,3 @@ void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
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
@@ -852,24 +858,24 @@ void KOMonthView::updateConfig()
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
@@ -880,14 +886,14 @@ void KOMonthView::updateDayLabels()
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}
@@ -896,41 +902,41 @@ void 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}
@@ -944,5 +950,5 @@ void 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}
@@ -950,3 +956,4 @@ void KOMonthView::changeEventDisplay(Event *, int)
950void KOMonthView::updateView() 956void KOMonthView::updateView()
951{ 957{
958
952 if ( !updatePossible ) 959 if ( !updatePossible )
@@ -955,9 +962,10 @@ void KOMonthView::updateView()
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}
@@ -970,6 +978,6 @@ void 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
@@ -1075,11 +1083,11 @@ void 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}
@@ -1098,8 +1106,8 @@ void KOMonthView::setSelectedCell( MonthViewCell *cell )
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}
@@ -1108,8 +1116,8 @@ void 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}
@@ -1118,6 +1126,6 @@ void 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}
@@ -1125,5 +1133,22 @@ void 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
@@ -239,2 +239,4 @@ class KOMonthView: public KOEventView
239 signals: 239 signals:
240 void nextMonth();
241 void prevMonth();
240 void selectWeekNum ( int ); 242 void selectWeekNum ( int );
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 94c459b..e8d5ab1 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -459,2 +459,6 @@ void KOViewManager::showMonthView()
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();
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 145b36c..950d2ec 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1738,3 +1738,3 @@ void MainWindow::showConfigureAgenda( )
1738 } 1738 }
1739 configureAgendaMenu->setItemChecked( KOPrefs::instance()->mHourSize, true ); 1739 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
1740} 1740}