From 6add774cf9841377f32613c7aa23161a823aa1da Mon Sep 17 00:00:00 2001 From: zautrix Date: Tue, 05 Apr 2005 19:42:46 +0000 Subject: fix --- (limited to 'korganizer') diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index e66ddce..4dfb9df 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -96,34 +96,38 @@ KNoScrollListBox::~KNoScrollListBox() void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) { QListBox::focusInEvent ( e ); - QListBoxItem * i = item ( 0 ); - if ( i && resetOnFocusIn ) { - setCurrentItem( i ); - setSelected ( 0, true ); - } - resetOnFocusIn = true; - - if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { - QListBoxItem *fi = firstItem (); - if (fi ) { - int ihei = fi->height( this ); - int hei = numRows () * ihei; - if ( hei < height() - horizontalScrollBar()->height () ) { - setVScrollBarMode(QScrollView::AlwaysOff); - } - else + if ( count() ){ + int ci = currentItem(); + if ( ci < 0 ) ci = 0; + + setCurrentItem( ci ); + setSelected ( ci, true ); + emit highlighted( item ( ci ) ); + + resetOnFocusIn = true; + + if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { + QListBoxItem *fi = firstItem (); + if (fi ) { + int ihei = fi->height( this ); + int hei = numRows () * ihei; + if ( hei < height() - horizontalScrollBar()->height () ) { + setVScrollBarMode(QScrollView::AlwaysOff); + } + else + setVScrollBarMode(QScrollView::Auto); + if ( ihei *3 > height() ) { + setHScrollBarMode(QScrollView::AlwaysOff); + } + else { + setHScrollBarMode(QScrollView::Auto); + } + } else { setVScrollBarMode(QScrollView::Auto); - if ( ihei *3 > height() ) { - setHScrollBarMode(QScrollView::AlwaysOff); - } - else { setHScrollBarMode(QScrollView::Auto); } - } else { - setVScrollBarMode(QScrollView::Auto); - setHScrollBarMode(QScrollView::Auto); - } - } + } + } } void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) { @@ -172,13 +176,17 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) e->ignore(); break; } - if ( count() ) { - setCurrentItem((currentItem()+count()-1)%count()); - if(!itemVisible(currentItem())) { - if((unsigned int) currentItem() == (count()-1)) { - setTopItem(currentItem()-numItemsVisible()+1); - } else { - setTopItem(topItem()-1); + if ( count() ) { + if ( currentItem() == 0 ) { + emit prevCell(); + } else { + setCurrentItem((currentItem()+count()-1)%count()); + if(!itemVisible(currentItem())) { + if((unsigned int) currentItem() == (count()-1)) { + setTopItem(currentItem()-numItemsVisible()+1); + } else { + setTopItem(topItem()-1); + } } } } @@ -188,13 +196,17 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) e->ignore(); break; } - if ( count () ) { - setCurrentItem((currentItem()+1)%count()); - if(!itemVisible(currentItem())) { - if(currentItem() == 0) { - setTopItem(0); - } else { - setTopItem(topItem()+1); + if ( count () ) { + if ( currentItem()+1 == count () ) { + emit nextCell(); + } else { + setCurrentItem((currentItem()+1)%count()); + if(!itemVisible(currentItem())) { + if(currentItem() == 0) { + setTopItem(0); + } else { + setTopItem(topItem()+1); + } } } } @@ -225,14 +237,18 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) void KNoScrollListBox::oneDown() { - if ( count () ) { - resetOnFocusIn = false; - setCurrentItem((currentItem()+1)%count()); - if(!itemVisible(currentItem())) { - if(currentItem() == 0) { - setTopItem(0); - } else { - setTopItem(topItem()+1); + if ( count () ) { + if ( currentItem()+1 == count () ) { + emit nextCell(); + } else { + resetOnFocusIn = false; + setCurrentItem((currentItem()+1)%count()); + if(!itemVisible(currentItem())) { + if(currentItem() == 0) { + setTopItem(0); + } else { + setTopItem(topItem()+1); + } } } } @@ -473,10 +489,11 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) SLOT( contextMenu( QListBoxItem * ) ) ); connect( this, SIGNAL( highlighted( QListBoxItem *) ), SLOT( selection( QListBoxItem * ) ) ); - connect( this, SIGNAL( clicked( QListBoxItem * ) ), - SLOT( cellClicked( QListBoxItem * ) ) ); + + /* connect( this, SIGNAL( clicked( QListBoxItem * ) ), SLOT( selection( QListBoxItem * ) ) ); + */ } #ifdef DESKTOP_VERSION QToolTipGroup *MonthViewCell::toolTipGroup() @@ -989,6 +1006,7 @@ void MonthViewCell::resizeEvent ( QResizeEvent * e ) void MonthViewCell::defaultAction( QListBoxItem *item ) { + if ( !item ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); @@ -1010,22 +1028,13 @@ void MonthViewCell::newEvent() } void MonthViewCell::cellClicked( QListBoxItem *item ) { + qDebug("CELL "); if ( item == 0 ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); return; } - /* - if ( lastClicked ) - if ( ! item ) { - if ( lastClicked->listBox() != item->listBox() ) - lastClicked->listBox()->clearSelection(); - } - */ - - mMonthView->setSelectedCell( this ); - if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); - select(); + } void MonthViewCell::contextMenu( QListBoxItem *item ) @@ -1151,6 +1160,10 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) SIGNAL( newEventSignal( QDateTime ) ) ); connect( cell, SIGNAL( showDaySignal( QDate ) ), SIGNAL( showDaySignal( QDate ) ) ); + connect( cell, SIGNAL( nextCell() ), + SLOT( nextCell() ) ); + connect( cell, SIGNAL( prevCell() ), + SLOT( prevCell() ) ); } } mCellsW.resize( mDaysPerWeek ); @@ -1164,6 +1177,10 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) SIGNAL( newEventSignal( QDateTime ) ) ); connect( cell, SIGNAL( showDaySignal( QDate ) ), SIGNAL( showDaySignal( QDate ) ) ); + connect( cell, SIGNAL( nextCell() ), + SLOT( nextCell() ) ); + connect( cell, SIGNAL( prevCell() ), + SLOT( prevCell() ) ); cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); } @@ -1974,3 +1991,12 @@ void KOMonthView::keyPressEvent ( QKeyEvent * e ) break; } } + +void KOMonthView::nextCell() +{ + bool res = focusNextPrevChild ( true ); +} +void KOMonthView::prevCell() +{ + focusNextPrevChild ( false ); +} diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index e39eeb0..c6b6b5e 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -83,6 +83,8 @@ class KNoScrollListBox: public QListBox void shiftDown(); void shiftUp(); void rightClick(); + void nextCell(); + void prevCell(); protected slots: void oneDown(); @@ -188,7 +190,6 @@ class MonthViewCell : public KNoScrollListBox QStringList mToolTip; void resizeEvent( QResizeEvent * ); - public slots: void showDay(); @@ -256,6 +257,8 @@ class KOMonthView: public KOEventView bool skipResize; NavigatorBar* navigatorBar() { return mNavigatorBar ;} public slots: + void nextCell(); + void prevCell(); virtual void updateView(); virtual void updateConfig(); virtual void showDates(const QDate &start, const QDate &end); -- cgit v0.9.0.2