Commit 8f77f44b authored by Christian Tacke's avatar Christian Tacke Committed by Aleix Pol Gonzalez

DVCS Branch Manager with filtering and sorting proposal

Summary:
The porposal is to utilize QSortFilterProxyModel for sorting and filtering.

When working with on a bigger project with multiple branches some means to find a desired branch for switching or creating a new branch may be considered helpful.
So I added a line edit and a QSortFilterProxyModel to do that for me.

Additionally: new branches are currently appended. Though this makes them easy to find, I think it's counter intuitive and a tad ugly. While the sort mechanism of the Proxy does not help initially, it does upon adding branches.

Drawback: the line edit for filtering may be associated with the "New" button by users. This could make the workflow for that less intuitive.

Test Plan:
Fire up Git->Branches on a git project.

Make sure all branches are there.
Type in the line edit to filter. Only branches that match should be included.
Clearing the line edit should result in all elements to become visible again.
Create New branch, that should be added to list in alphabetical order.

Reviewers: apol

Reviewed By: apol

Subscribers: kfunk, apol, kdevelop-devel

Tags: #vdg, #kdevelop

Differential Revision: https://phabricator.kde.org/D20142
parent bc13f955
......@@ -38,6 +38,7 @@
#include <QDialogButtonBox>
#include <QPushButton>
#include <QVBoxLayout>
#include <QSortFilterProxyModel>
#include <KParts/MainWindow>
using namespace KDevelop;
......@@ -65,7 +66,20 @@ BranchManager::BranchManager(const QString& repository, KDevelop::DistributedVer
m_model = new BranchesListModel(this);
m_model->initialize(m_dvcPlugin, QUrl::fromLocalFile(repository));
m_ui->branchView->setModel(m_model);
// Filter Model
m_filterModel = new QSortFilterProxyModel();
m_filterModel->setSourceModel(m_model);
m_filterModel->setFilterWildcard(QString());
m_filterModel->sort(0, Qt::AscendingOrder);
//Changes in filter edit trigger filtering
connect(m_ui->branchFilterEdit,
&QLineEdit::textChanged,
m_filterModel,
&QSortFilterProxyModel::setFilterWildcard);
m_ui->branchView->setModel(m_filterModel);
QString branchName = m_model->currentBranch();
// apply initial selection
......
......@@ -27,6 +27,8 @@ class KJob;
namespace Ui { class BranchDialogBase; }
class QSortFilterProxyModel;
namespace KDevelop
{
class BranchesListModel;
......@@ -58,6 +60,7 @@ private:
Ui::BranchDialogBase* m_ui;
KDevelop::BranchesListModel* m_model;
QSortFilterProxyModel* m_filterModel;
};
#endif
......@@ -23,7 +23,7 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<item row="0" column="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="newButton">
......@@ -144,12 +144,26 @@
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QListView" name="branchView">
<property name="editTriggers">
<set>QAbstractItemView::EditKeyPressed</set>
</property>
</widget>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0">
<item>
<widget class="QLineEdit" name="branchFilterEdit">
<property name="text">
<string/>
</property>
<property name="placeholderText">
<string>Search...</string>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="branchView">
<property name="editTriggers">
<set>QAbstractItemView::EditKeyPressed</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment