PATCH: mouseWheel support for KDatePicker...

Arni Ingimundarson arning at hrzpub.tu-darmstadt.de
Tue May 7 19:24:51 BST 2002


...in case you are intrested.


Regards,
Arni
-------------- next part --------------
Index: kdatepicker.cpp
===================================================================
RCS file: /cvs/kdelibs/kdeui/kdatepicker.cpp,v
retrieving revision 1.37.2.1
diff -u -r1.37.2.1 kdatepicker.cpp
--- kdatepicker.cpp	2002/04/12 05:37:33	1.37.2.1
+++ kdatepicker.cpp	2002/05/07 18:17:38
@@ -126,6 +126,7 @@
     kdDebug() << "KDatePicker::dateChangedSlot: date changed (" << date.year() << "/" << date.month() << "/" << date.day() << ")." << endl;
     line->setText(KGlobal::locale()->formatDate(date, true));
     selectMonth->setText(KGlobal::locale()->monthName(date.month(), false));
+    selectYear->setText(date.toString("yyyy"));
     emit(dateChanged(date));
 }
 
Index: kdatetbl.cpp
===================================================================
RCS file: /cvs/kdelibs/kdeui/kdatetbl.cpp,v
retrieving revision 1.38.2.1
diff -u -r1.38.2.1 kdatetbl.cpp
--- kdatetbl.cpp	2002/04/12 05:50:17	1.38.2.1
+++ kdatetbl.cpp	2002/05/07 18:17:39
@@ -298,6 +298,13 @@
 }
 
 void
+KDateTable::wheelEvent ( QWheelEvent * e )
+{
+    setDate(date.addMonths( -(int)(e->delta()/120)) );
+    e->accept();
+}
+
+void
 KDateTable::contentsMousePressEvent(QMouseEvent *e)
 {
   if(e->type()!=QEvent::MouseButtonPress)
Index: kdatetbl.h
===================================================================
RCS file: /cvs/kdelibs/kdeui/kdatetbl.h,v
retrieving revision 1.27
diff -u -r1.27 kdatetbl.h
--- kdatetbl.h	2002/03/05 23:13:27	1.27
+++ kdatetbl.h	2002/05/07 18:17:39
@@ -257,6 +257,7 @@
      * React on mouse clicks that select a date.
      */
     virtual void contentsMousePressEvent(QMouseEvent *);
+    virtual void wheelEvent( QWheelEvent * e );
     virtual void keyPressEvent( QKeyEvent *e );
     virtual void focusInEvent( QFocusEvent *e );
     virtual void focusOutEvent( QFocusEvent *e );


More information about the kde-core-devel mailing list