-rw-r--r-- | korganizer/komonthview.cpp | 53 | ||||
-rw-r--r-- | korganizer/komonthview.h | 8 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 2 |
3 files changed, 47 insertions, 16 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 940d288..ca35a86 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -102,5 +102,5 @@ QString KNoScrollListBox::getWhatsThisText(QPoint p) void KNoScrollListBox::keyPressEvent(QKeyEvent *e) { - + //qDebug("KNoScrollListBox::keyPressEvent "); switch(e->key()) { case Key_Right: @@ -156,4 +156,15 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) e->ignore(); break; + case Key_Return: + case Key_Enter: + { + if ( currentItem() >= 0 ) { + emit doubleClicked( item( currentItem() ) ); + e->accept(); + } else { + e->ignore(); + } + } + break; case Key_Shift: emit shiftDown(); @@ -314,6 +325,6 @@ void MonthViewItem::paint(QPainter *p) } else { int val = td->percentComplete()/20; - p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); - p->drawRect ( x, y-1,7,size+2); + p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); + p->drawRect ( x, y-2,7,size+4); x += size + 3; } @@ -1053,4 +1064,5 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) } mWeekLabels[mNumWeeks]->setText( i18n("W")); + mWeekLabels[0]->setFocusPolicy(WheelFocus); QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); @@ -1068,4 +1080,5 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) } mWeekLabelsW[1]->setText( i18n("W")); + mWeekLabelsW[0]->setFocusPolicy(WheelFocus); @@ -1467,7 +1480,5 @@ void KOMonthView::updateView() (*cells)[i]->repaintfinishUpdateCell(); } - (*cells)[0]->setFocus(); - - + setKeyBFocus(); #else // old code @@ -1487,4 +1498,24 @@ void KOMonthView::updateView() } +void KOMonthView::setKeyBoardFocus() +{ + bool shootAgain = false; + if ( mShowWeekView ) { + shootAgain = !mWeekLabelsW[0]->hasFocus(); + mWeekLabelsW[0]->setFocus(); + } + else { + shootAgain = !mWeekLabels[0]->hasFocus(); + mWeekLabels[0]->setFocus(); + } + if ( shootAgain ) { + QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); + } +} +void KOMonthView::setKeyBFocus() +{ + //qDebug("KOMonthView::setKeyBFocus() "); + QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); +} void KOMonthView::resizeEvent(QResizeEvent * e) { @@ -1503,9 +1534,5 @@ void KOMonthView::slotComputeLayout() computeLayout(); clPending = true; - if ( mShowWeekView ) - mCellsW[0]->setFocus(); - else - mCells[0]->setFocus(); - + setKeyBFocus(); } void KOMonthView::computeLayoutWeek() @@ -1818,9 +1845,7 @@ void KOMonthView::keyPressEvent ( QKeyEvent * e ) { if ( mShowWeekView ) { - mCellsW[0]->setFocus(); emit selectWeekNum ( currentWeek() - 1 ); } else { - mCells[0]->setFocus(); emit prevMonth(); } @@ -1831,9 +1856,7 @@ void KOMonthView::keyPressEvent ( QKeyEvent * e ) { if ( mShowWeekView ) { - mCellsW[0]->setFocus(); emit selectWeekNum ( currentWeek() +1); } else { - mCells[0]->setFocus(); emit nextMonth(); } diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 9e724c7..c1ca3d4 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -62,4 +62,9 @@ class KOWeekButton : public QPushButton private: int mNumber; + void keyPressEvent ( QKeyEvent * e ) + { + e->ignore(); + } + private slots : void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } @@ -164,5 +169,4 @@ class MonthViewCell : public KNoScrollListBox void deselect(); void select(); - #ifdef DESKTOP_VERSION static QToolTipGroup *toolTipGroup(); @@ -258,4 +262,6 @@ class KOMonthView: public KOEventView void setSelectedCell( MonthViewCell * ); void switchView(); + void setKeyBoardFocus(); + void setKeyBFocus(); protected slots: diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 53cd011..548ffd3 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -648,4 +648,5 @@ void KOViewManager::showMonthViewWeek() mMainView->dateNavigator()->selectWeek(); showView(mMonthView, full ); + mMonthView->setKeyBFocus(); } @@ -677,4 +678,5 @@ void KOViewManager::showMonthView() showView(mMonthView, full ); + mMonthView->setKeyBFocus(); } |