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

DVCS Branch Manager with filtering and sorting proposal

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:
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));
// Filter Model
m_filterModel = new QSortFilterProxyModel();
m_filterModel->sort(0, Qt::AscendingOrder);
//Changes in filter edit trigger filtering
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;
......@@ -23,7 +23,7 @@
<property name="bottomMargin">
<item row="0" column="1">
<item row="0" column="2">
<layout class="QVBoxLayout" name="verticalLayout">
<widget class="QPushButton" name="newButton">
......@@ -144,12 +144,26 @@
<item row="0" column="0">
<widget class="QListView" name="branchView">
<property name="editTriggers">
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0">
<widget class="QLineEdit" name="branchFilterEdit">
<property name="text">
<property name="placeholderText">
<widget class="QListView" name="branchView">
<property name="editTriggers">
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