-rw-r--r-- | korganizer/komonthview.cpp | 27 | ||||
-rw-r--r-- | korganizer/komonthview.h | 5 |
2 files changed, 29 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index ab9a4b6..9f7db69 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -62,53 +62,75 @@ QToolTipGroup *MonthViewCell::mToolTipGroup = 0; class KNOWhatsThis :public QWhatsThis { public: KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; protected: virtual QString text( const QPoint& p) { return _wid->getWhatsThisText(p) ; }; private: KNoScrollListBox* _wid; }; KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) : QListBox(parent, name, WRepaintNoErase) { #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mWT = new KNOWhatsThis(this); + resetOnFocusIn = true; } KNoScrollListBox::~KNoScrollListBox() { } + + +void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) +{ + QListBox::focusInEvent ( e ); + QListBoxItem * i = item ( 0 ); + if ( i && resetOnFocusIn ) { + setCurrentItem( i ); + setSelected ( 0, true ); + } + resetOnFocusIn = true; +} +void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) +{ + int i = currentItem (); + if ( i >= 0 ) { + setSelected ( i, false ); + } + QListBox::focusOutEvent ( e ); +} + QString KNoScrollListBox::getWhatsThisText(QPoint p) { QListBoxItem* item = itemAt ( p ); if ( ! item ) { return i18n("Click in the cell\nto add an event!"); } return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), KOPrefs::instance()->mWTshowDetails, KOPrefs::instance()->mWTshowCreated, KOPrefs::instance()->mWTshowChanged); } void KNoScrollListBox::keyPressEvent(QKeyEvent *e) { //qDebug("KNoScrollListBox::keyPressEvent "); switch(e->key()) { case Key_Right: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { e->ignore(); return; } scrollBy(10,0); break; case Key_Left: @@ -131,74 +153,75 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e) setTopItem(currentItem()-numItemsVisible()+1); } else { setTopItem(topItem()-1); } } } break; case Key_Down: if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { e->ignore(); break; } if ( count () ) { setCurrentItem((currentItem()+1)%count()); if(!itemVisible(currentItem())) { if(currentItem() == 0) { setTopItem(0); } else { setTopItem(topItem()+1); } } } break; case Key_I: - QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); + QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 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(); break; default: e->ignore(); break; } } void KNoScrollListBox::oneDown() { - if ( count () ) { + if ( count () ) { + resetOnFocusIn = false; setCurrentItem((currentItem()+1)%count()); if(!itemVisible(currentItem())) { if(currentItem() == 0) { setTopItem(0); } else { setTopItem(topItem()+1); } } } } void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) { switch(e->key()) { case Key_Shift: emit shiftUp(); break; default: break; } } void KNoScrollListBox::mousePressEvent(QMouseEvent *e) { QListBox::mousePressEvent(e); diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 88050fe..e04cdf5 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -66,51 +66,54 @@ private: e->ignore(); } private slots : void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } }; class KNoScrollListBox: public QListBox { Q_OBJECT public: KNoScrollListBox(QWidget *parent=0, const char *name=0); ~KNoScrollListBox(); QString getWhatsThisText(QPoint p) ; signals: void shiftDown(); void shiftUp(); void rightClick(); protected slots: void oneDown(); void keyPressEvent(QKeyEvent *); void keyReleaseEvent(QKeyEvent *); - void mousePressEvent(QMouseEvent *); + void mousePressEvent(QMouseEvent *); + void focusInEvent ( QFocusEvent * ); + void focusOutEvent ( QFocusEvent * ); private: + bool resetOnFocusIn; KNOWhatsThis * mWT; }; class MonthViewItem: public QListBoxItem { public: MonthViewItem( Incidence *, QDate qd, const QString & title ); void recycle( Incidence *incidence, QDate qd, const QString & s); void setRecur(bool on) { mRecur = on; } void setAlarm(bool on) { mAlarm = on; } void setReply(bool on) { mReply = on; } void setMoreInfo(bool on) { mInfo = on; } void setMultiDay(int type) { mMultiday = type; } void setBlockRepaint(bool on) { mblockRepaint = on; } void setPalette(const QPalette &p) { mPalette = p; } QPalette palette() const { return mPalette; } Incidence *incidence() const { return mIncidence; } QDate incidenceDate() { return mDate; } protected: |