diff --git a/kdevplatform/vcs/dvcs/ui/branchmanager.h b/kdevplatform/vcs/dvcs/ui/branchmanager.h
--- a/kdevplatform/vcs/dvcs/ui/branchmanager.h
+++ b/kdevplatform/vcs/dvcs/ui/branchmanager.h
@@ -53,6 +53,8 @@
void mergeBranch();
void diffFromBranch();
void diffJobFinished(KJob* job);
+ void updateBranchFilter();
+ void updateBranchRemoteFilterIcon(bool checked);
private:
QString m_repository;
diff --git a/kdevplatform/vcs/dvcs/ui/branchmanager.cpp b/kdevplatform/vcs/dvcs/ui/branchmanager.cpp
--- a/kdevplatform/vcs/dvcs/ui/branchmanager.cpp
+++ b/kdevplatform/vcs/dvcs/ui/branchmanager.cpp
@@ -73,11 +73,23 @@
m_filterModel->setFilterWildcard(QString());
m_filterModel->sort(0, Qt::AscendingOrder);
+ // Icon to filter branches
+ m_ui->branchFilterEdit->addAction(m_ui->actionRemoteBranches,
+ QLineEdit::ActionPosition::TrailingPosition);
//Changes in filter edit trigger filtering
connect(m_ui->branchFilterEdit,
&QLineEdit::textChanged,
- m_filterModel,
- &QSortFilterProxyModel::setFilterWildcard);
+ this,
+ &BranchManager::updateBranchFilter);
+ connect(m_ui->actionRemoteBranches,
+ &QAction::toggled,
+ this,
+ &BranchManager::updateBranchFilter);
+ // Update icon in filter line edit when clicked
+ connect(m_ui->actionRemoteBranches,
+ &QAction::toggled,
+ this,
+ &BranchManager::updateBranchRemoteFilterIcon);
m_ui->branchView->setModel(m_filterModel);
@@ -105,6 +117,36 @@
delete m_ui;
}
+void BranchManager::updateBranchFilter()
+{
+ QString filter = m_ui->branchFilterEdit->text();
+ // if remote shall be filtered prepend 'does not start with remotes/'
+ if (m_ui->actionRemoteBranches->isChecked()) {
+ if (filter.startsWith(QChar::fromLatin1('^'))) {
+ // if expression starts with ^ we need to remove it. There shall only be one!
+ filter.remove(0,1);
+ filter.prepend(QString::fromLatin1("^(?!remotes\\/)"));
+ } else {
+ // allow for almost arbitrary text between start and user input
+ filter.prepend(QString::fromLatin1("^(?!remotes\\/).*"));
+ }
+ }
+
+ m_filterModel->setFilterRegExp(filter);
+}
+
+void BranchManager::updateBranchRemoteFilterIcon(bool checked)
+{
+ // no idea how to this other than how it is done here https://api.kde.org/frameworks/kwidgetsaddons/html/kpasswordlineedit_8cpp_source.html
+ if (checked) {
+ m_ui->actionRemoteBranches->setIcon(QIcon::fromTheme(QString::fromLatin1("password-show-off")));
+ } else {
+ m_ui->actionRemoteBranches->setIcon(QIcon::fromTheme(QString::fromLatin1("password-show-on")));
+ }
+}
+
+
+
void BranchManager::createBranch()
{
const QModelIndex currentBranchIdx = m_ui->branchView->currentIndex();
diff --git a/kdevplatform/vcs/dvcs/ui/branchmanager.ui b/kdevplatform/vcs/dvcs/ui/branchmanager.ui
--- a/kdevplatform/vcs/dvcs/ui/branchmanager.ui
+++ b/kdevplatform/vcs/dvcs/ui/branchmanager.ui
@@ -148,6 +148,9 @@
-
+
+ <html><head/><body><p>Filter branches using regular expressions.</p><p>See QRegExp for further information.</p></body></html>
+
@@ -166,6 +169,20 @@
+
+
+ true
+
+
+
+
+
+ Show remote branches
+
+
+ <html><head/><body><p>Show remote branches.</p><p>Silently prepends ^(?!remotes\/) to regular expression.</p></body></html>
+
+