changeset 204:d256cc418fa3

* Fix failure to enable Add button when a "Removed" file was selected
author Chris Cannam
date Tue, 04 Jan 2011 15:22:07 +0000
parents c77c4d00a4fe
children 49bf8cc4f6b2 583faa8dadb6
files hgtabwidget.cpp
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgtabwidget.cpp	Tue Jan 04 14:31:30 2011 +0000
+++ b/hgtabwidget.cpp	Tue Jan 04 15:22:07 2011 +0000
@@ -115,10 +115,17 @@
 
 bool HgTabWidget::canAdd() const
 {
-    if (m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
-    if (!m_fileStatusWidget->getSelectedCommittableFiles().empty()) return false;
-    if (!m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
-    return true;
+    QStringList addable = m_fileStatusWidget->getSelectedAddableFiles();
+    if (addable.empty()) return false;
+
+    QStringList removable = m_fileStatusWidget->getSelectedRemovableFiles();
+    if (!removable.empty()) return false;
+
+    QStringList committable = m_fileStatusWidget->getSelectedCommittableFiles();
+    // "Removed" files are both committable and addable; don't return
+    // a false positive if the selection only contains these
+    if (committable == addable || committable.empty()) return true;
+    return false;
 }
 
 bool HgTabWidget::canRemove() const