From ce24dfa378cca1f09d944fe1d50ae1f73ac0df7f Mon Sep 17 00:00:00 2001 From: Robert Loehning <robert.loehning@nokia.com> Date: Wed, 25 Aug 2010 18:12:03 +0200 Subject: [PATCH] VCS[git]: Ensure that only one branch is selected at a time --- src/plugins/git/branchdialog.cpp | 13 ++++++++++--- src/plugins/git/branchdialog.h | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp index f1978ecafa6..0dc421495a1 100644 --- a/src/plugins/git/branchdialog.cpp +++ b/src/plugins/git/branchdialog.cpp @@ -107,10 +107,10 @@ BranchDialog::BranchDialog(QWidget *parent) : connect(m_ui->localBranchListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(slotEnableButtons())); + this, SLOT(slotEnableButtons(QItemSelection))); connect(m_ui->remoteBranchListView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - this, SLOT(slotEnableButtons())); + this, SLOT(slotEnableButtons(QItemSelection))); slotEnableButtons(); } @@ -150,8 +150,15 @@ int BranchDialog::selectedRemoteBranchIndex() const return selectedRow(m_ui->remoteBranchListView); } -void BranchDialog::slotEnableButtons() +void BranchDialog::slotEnableButtons(const QItemSelection &selected) { + if (!selected.indexes().isEmpty()) { + if (selected.indexes().at(0).model() == m_localModel) + m_ui->remoteBranchListView->clearSelection(); + else + m_ui->localBranchListView->clearSelection(); + } + // We can switch to or delete branches that are not current. const bool hasRepository = !m_repository.isEmpty(); const int selectedLocalRow = selectedLocalBranchIndex(); diff --git a/src/plugins/git/branchdialog.h b/src/plugins/git/branchdialog.h index ac85c4c25a6..bf21a746e34 100644 --- a/src/plugins/git/branchdialog.h +++ b/src/plugins/git/branchdialog.h @@ -31,6 +31,7 @@ #define BRANCHDIALOG_H #include <QtGui/QDialog> +#include <QtGui/QItemSelection> QT_BEGIN_NAMESPACE class QPushButton; @@ -64,7 +65,7 @@ public slots: void refresh(const QString &repository, bool force); private slots: - void slotEnableButtons(); + void slotEnableButtons(const QItemSelection &selected = QItemSelection()); void slotCheckoutSelectedBranch(); void slotDeleteSelectedBranch(); void slotDiffSelected(); -- GitLab