[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [zanshin] src: allow setting a due date via mousewheel
From: Matthias Kretz <kretz () kde ! org>
Date: 2012-02-03 15:30:28
Message-ID: 20120203153028.BDFA3A60C6 () git ! kde ! org
[Download RAW message or body]
Git commit 3d876f8d6dbe138378026d9f3ee7a07ef0b4135a by Matthias Kretz.
Committed on 01/02/2012 at 23:51.
Pushed by mkretz into branch 'master'.
allow setting a due date via mousewheel
Setting the due date with the mouse is easier now (for me). Double-click
the cell and use the mousewheel to select the date. The mousewheel thus
does the same as the up/down cursor keys.
M +22 -0 src/kdateedit.cpp
M +1 -0 src/kdateedit.h
http://commits.kde.org/zanshin/3d876f8d6dbe138378026d9f3ee7a07ef0b4135a
diff --git a/src/kdateedit.cpp b/src/kdateedit.cpp
index 41f942b..440c9b5 100644
--- a/src/kdateedit.cpp
+++ b/src/kdateedit.cpp
@@ -278,6 +278,28 @@ void KDateEdit::focusOutEvent( QFocusEvent *e )
QComboBox::focusOutEvent( e );
}
+void KDateEdit::wheelEvent( QWheelEvent *e )
+{
+ if ( mReadOnly || e->delta() == 0 ) {
+ return;
+ }
+ QDate date = parseDate();
+ if ( !date.isValid() ) {
+ return;
+ }
+ // QWheelEvent::delta reports +/-120 per step on most mice, but according to the documentation some
+ // mice may send smaller deltas. We're just interested in the direction, though...
+ date = date.addDays( e->delta() > 0 ? 1 : -1 );
+ if ( assignDate( date ) ) {
+ e->accept();
+ updateView();
+ emit dateChanged( date );
+ emit dateEntered( date );
+ return;
+ }
+ QComboBox::wheelEvent( e );
+}
+
void KDateEdit::keyPressEvent(QKeyEvent* e)
{
QDate date;
diff --git a/src/kdateedit.h b/src/kdateedit.h
index 7a805a5..eb337ea 100644
--- a/src/kdateedit.h
+++ b/src/kdateedit.h
@@ -116,6 +116,7 @@ class KDateEdit : public QComboBox
virtual bool eventFilter( QObject *, QEvent * );
virtual void mousePressEvent( QMouseEvent * );
virtual void focusOutEvent( QFocusEvent * );
+ virtual void wheelEvent( QWheelEvent * );
virtual void keyPressEvent( QKeyEvent * );
/**
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic