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

List:       kde-core-devel
Subject:    [PATCH] qcombobox bug workaround
From:       Nick Shaforostoff <shaforostoff () gmail ! com>
Date:       2009-02-24 2:08:54
Message-ID: 758e8e2d0902231808w9578808sece65861e78ff19d () mail ! gmail ! com
[Download RAW message or body]

Hi. I recently upgraded Qt to 4.5 to find out that trivial bug I
reported ages ago still isn't fixed.

QComboBox doesn't keep it's view() selection in sync with itself.
So when user selects item by pressing arrow keys or via
search-as-you-type w/o opening the view(),
the view() doesn't have its currentIndex() updated.

attached small patch fixes this issue on a KComboBox level.

ok to commit it?

["make-it-smart.patch" (application/octet-stream)]

Index: kcombobox.h
===================================================================
--- kcombobox.h	(revision 930199)
+++ kcombobox.h	(working copy)
@@ -516,6 +516,7 @@
 
 private Q_SLOTS:
     void lineEditDeleted();
+    void reflectCurrentIndexChangeInView(int);
 
 private:
     /**
Index: kcombobox.cpp
===================================================================
--- kcombobox.cpp	(revision 930199)
+++ kcombobox.cpp	(working copy)
@@ -80,6 +80,9 @@
     // Enable context menu by default if widget
     // is editable.
     setContextMenuEnabled( true );
+
+    //workaround for Qt bug
+    connect(this,SIGNAL(currentIndexChanged(int)),SLOT(reflectCurrentIndexChangeInView(int)));
 }
 
 
@@ -387,6 +390,12 @@
         setDelegate( 0L );
 }
 
+void KComboBox::reflectCurrentIndexChangeInView(int row)
+{
+    if (row!=-1)
+        view()->setCurrentIndex(model()->index(row,modelColumn()));
+}
+
 void KComboBox::setEditable(bool editable)
 {
     if (editable) {


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

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