[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    Re: [Kde-pim] PATCH: KDateEdit
From:       David Jarvie <lists () astrojar ! org ! uk>
Date:       2002-11-17 14:24:28
[Download RAW message or body]

On Sunday 17 Nov 2002 9:00 am, Cornelius Schumacher wrote:
> On Saturday 16 November 2002 21:37, David Jarvie wrote:
> > Once KDateEdit arrow has been clicked to display the date picker
> > popup, it currently remains showing the pressed state, and never
> > reverts to the unpressed state. In some styles, this is very
> > noticeable to the user, and is at odds with the behaviour of a normal
> > combo box. Here is a patch to make it revert to the unpressed state
> > after being clicked. I would like to see this go into KDE 3.1 if
> > there is still time.
> >
> > Please review so that I can commit it.
>
> This doesn't look right. listBox() can return 0, this will cause a crash
> with your patch. In addition to that passing a key_enter event when the
> enter key isn't pressed might cause problems. Is there no cleaner way
> to set the state of the arrow widget?

QComboBox needs to receive the 'selected' signal from its list box (assuming 
that it is using the default of a list box rather than a popup menu) in order 
to set its appearance back to 'not pressed'. The only way I can see to send 
such a signal is either by emulating an Enter key press on one of its items, 
or by emulating a double click on one of its items. The basic problem is that 
QComboBox provides a virtual popup() method, but no virtual methods to 
indicate that the popup has been done. If anyone has any other suggestions on 
how to do this, I would welcome them.

Remember that the list box is never actually seen or otherwise used - the date 
picker appears instead. So I don't think that an Enter should cause any 
problems.

I have added a test for listBox() being non-null in the revised patch below:

-- 
David Jarvie


Index: kdateedit.cpp
===================================================================
RCS file: /home/kde/kdepim/libkdepim/kdateedit.cpp,v
retrieving revision 1.15
diff -u -r1.15 kdateedit.cpp
--- kdateedit.cpp       2002/11/13 16:27:41     1.15
+++ kdateedit.cpp       2002/11/17 14:24:04
@@ -24,6 +24,7 @@

 #include <qevent.h>
 #include <qlineedit.h>
+#include <qlistbox.h>

 #include <kdatepicker.h>
 #include <knotifyclient.h>
@@ -158,6 +159,15 @@
   }

   mDateFrame->show();
+
+  // The combo box is now shown pressed. Make it show not pressed again
+  // by causing its (invisible) list box to emit a 'selected' signal.
+  QListBox *lb = listBox();
+  if (lb) {
+    lb->setCurrentItem(0);
+    QKeyEvent* keyEvent = new QKeyEvent(QEvent::KeyPress, Qt::Key_Enter, 0, 
0);
+    QApplication::postEvent(lb, keyEvent);
+  }
 }

 void KDateEdit::dateSelected(QDate newDate)
_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic