[kde-doc-english] [kdevplatform] plugins/reviewboard: Replacing Repositories QComboBox by Filtered QListWidget

David E. Narváez david.narvaez at computer.org
Sun Nov 20 17:38:09 UTC 2011


Git commit 1bec0981ca382ec15f327b3194e8e042462c6b01 by David E. Narváez.
Committed on 20/11/2011 at 18:35.
Pushed by narvaez into branch 'master'.

Replacing Repositories QComboBox by Filtered QListWidget

Eases searching for a project when submitting a patch
GUI: Reviewboard plugin now uses a Filtered QListWidget to show projects

M  +16   -17   plugins/reviewboard/reviewpatch.ui
M  +9    -4    plugins/reviewboard/reviewpatchdialog.cpp

http://commits.kde.org/kdevplatform/1bec0981ca382ec15f327b3194e8e042462c6b01

diff --git a/plugins/reviewboard/reviewpatch.ui b/plugins/reviewboard/reviewpatch.ui
index 809769c..5b2acef 100644
--- a/plugins/reviewboard/reviewpatch.ui
+++ b/plugins/reviewboard/reviewpatch.ui
@@ -94,37 +94,36 @@
      </property>
      <layout class="QVBoxLayout" name="verticalLayout_2">
       <item>
-       <widget class="QComboBox" name="repositories"/>
+       <widget class="KListWidgetSearchLine" name="repositoriesFilter">
+        <property name="clickMessage">
+         <string>Filter repositories</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QListWidget" name="repositories"/>
       </item>
      </layout>
     </widget>
    </item>
-   <item>
-    <spacer name="verticalSpacer">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>20</width>
-       <height>40</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
   </layout>
  </widget>
  <customwidgets>
   <customwidget>
-   <class>KUrlRequester</class>
-   <extends>QFrame</extends>
-   <header>kurlrequester.h</header>
+   <class>KListWidgetSearchLine</class>
+   <extends>QLineEdit</extends>
+   <header>klistwidgetsearchline.h</header>
   </customwidget>
   <customwidget>
    <class>KLineEdit</class>
    <extends>QLineEdit</extends>
    <header>klineedit.h</header>
   </customwidget>
+  <customwidget>
+   <class>KUrlRequester</class>
+   <extends>QFrame</extends>
+   <header>kurlrequester.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
diff --git a/plugins/reviewboard/reviewpatchdialog.cpp b/plugins/reviewboard/reviewpatchdialog.cpp
index c0fb8d3..ea3996a 100644
--- a/plugins/reviewboard/reviewpatchdialog.cpp
+++ b/plugins/reviewboard/reviewpatchdialog.cpp
@@ -29,7 +29,7 @@ ReviewPatchDialog::ReviewPatchDialog(QWidget* parent)
     m_ui=new Ui::ReviewPatch;
     QWidget* w= new QWidget(this);
     m_ui->setupUi(w);
-    m_ui->repositories->setInsertPolicy(QComboBox::InsertAlphabetically);
+    m_ui->repositoriesFilter->setListWidget(m_ui->repositories);
     setMainWidget(w);
     
     connect(m_ui->server, SIGNAL(textChanged(QString)), SLOT(serverChanged()));
@@ -76,14 +76,19 @@ void ReviewPatchDialog::receivedProjects(KJob* job)
     QVariantList repos = pl->repositories();
     foreach(const QVariant& repo, repos) {
         QVariantMap repoMap=repo.toMap();
-        m_ui->repositories->addItem(repoMap["name"].toString(), repoMap["path"].toString());
+        QListWidgetItem *repoItem = new QListWidgetItem();
+
+        repoItem->setText(repoMap["name"].toString());
+        repoItem->setData(Qt::UserRole, repoMap["path"]);
+        m_ui->repositories->addItem(repoItem);
     }
     
+    m_ui->repositories->sortItems(Qt::AscendingOrder);
     m_ui->repositoriesBox->setEnabled(job->error()==0);
 }
 
 QString ReviewPatchDialog::repository() const
 {
-    Q_ASSERT(m_ui->repositories->currentIndex()>=0);
-    return m_ui->repositories->itemData(m_ui->repositories->currentIndex(),Qt::UserRole).toString();
+    Q_ASSERT(m_ui->repositories->currentIndex().isValid());
+    return m_ui->repositories->currentItem()->data(Qt::UserRole).toString();
 }


More information about the kde-doc-english mailing list