From 8e5edbec9e712c18ef231a2768c022da424fae68 Mon Sep 17 00:00:00 2001 From: Robert Loehning <robert.loehning@nokia.com> Date: Thu, 26 Aug 2010 20:34:04 +0200 Subject: [PATCH] VCS[git]: Allow diff with current or remote branch --- src/plugins/git/branchdialog.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp index 0dc421495a1..ae883675cb3 100644 --- a/src/plugins/git/branchdialog.cpp +++ b/src/plugins/git/branchdialog.cpp @@ -160,16 +160,15 @@ void BranchDialog::slotEnableButtons(const QItemSelection &selected) } // We can switch to or delete branches that are not current. - const bool hasRepository = !m_repository.isEmpty(); const int selectedLocalRow = selectedLocalBranchIndex(); - const int currentLocalBranch = m_localModel->currentBranch(); - - const bool hasSelection = selectedLocalRow != -1 && !m_localModel->isNewBranchRow(selectedLocalRow); - const bool currentIsNotSelected = hasSelection && selectedLocalRow != currentLocalBranch; + const bool hasRepository = !m_repository.isEmpty(); + const bool hasLocalSelection = selectedLocalRow != -1 && !m_localModel->isNewBranchRow(selectedLocalRow); + const bool otherLocalSelected = hasLocalSelection && selectedLocalRow != m_localModel->currentBranch(); + const bool branchSelected = hasLocalSelection || selectedRemoteBranchIndex() != -1; - m_checkoutButton->setEnabled(currentIsNotSelected); - m_diffButton->setEnabled(currentIsNotSelected); - m_deleteButton->setEnabled(currentIsNotSelected); + m_checkoutButton->setEnabled(otherLocalSelected); + m_diffButton->setEnabled(branchSelected); + m_deleteButton->setEnabled(otherLocalSelected); m_refreshButton->setEnabled(hasRepository); // Also disable <New Branch> entry of list view m_ui->localBranchListView->setEnabled(hasRepository); @@ -249,10 +248,14 @@ void BranchDialog::slotLocalBranchActivated() void BranchDialog::slotDiffSelected() { - const int idx = selectedLocalBranchIndex(); - if (idx == -1) + int idx = selectedLocalBranchIndex(); + if (idx != -1) { + gitClient()->diffBranch(m_repository, QStringList(), m_localModel->branchName(idx)); return; - gitClient()->diffBranch(m_repository, QStringList(), m_localModel->branchName(idx)); + } + idx = selectedRemoteBranchIndex(); + if (idx != -1) + gitClient()->diffBranch(m_repository, QStringList(), m_remoteModel->branchName(idx)); } /* Ask to stash away changes and then close dialog and do an asynchronous -- GitLab