Fixed some issues introduced by the recent addition. eric7

Thu, 23 Sep 2021 19:49:56 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 23 Sep 2021 19:49:56 +0200
branch
eric7
changeset 8626
fa4ec5a82698
parent 8625
d52ae1294878
child 8627
ca3114b95866

Fixed some issues introduced by the recent addition.

eric7/VCS/StatusWidget.py file | annotate | diff | comparison | revisions
--- a/eric7/VCS/StatusWidget.py	Thu Sep 23 18:26:46 2021 +0200
+++ b/eric7/VCS/StatusWidget.py	Thu Sep 23 19:49:56 2021 +0200
@@ -113,6 +113,7 @@
         self.__statusList.itemSelectionChanged.connect(
             self.__updateEnabledStates)
         self.__statusList.itemDoubleClicked.connect(self.__itemDoubleClicked)
+        self.__statusList.itemChanged.connect(self.__updateEnabledStates)
         self.__layout.addWidget(self.__statusList)
         ###################################################################
         
@@ -345,7 +346,7 @@
         self.__commitButton.setEnabled(commitable)
         self.__addButton.setEnabled(unversioned)
         
-        self.__quickCommitGroup.setEnabled(True)
+        self.__quickCommitGroup.setEnabled(commitable)
     
     @pyqtSlot(dict)
     def __processStatusData(self, data):
@@ -370,8 +371,16 @@
         @param data dictionary containing the status data
         @type dict
         """
-        self.__reset()
+        # step 1: remember all currently checked entries
+        wasUnpopulated = self.__statusList.count() == 0
+        checkedEntries = [itm.text() for itm in self.__getCommitableItems()]
+        selectedEntries = [itm.text()
+                           for itm in self.__statusList.selectedItems()]
         
+        # step 2: clear the list and re-populate it with new data
+        self.__statusList.clear()
+        
+        block = self.__statusList.blockSignals(True)
         for name, status in data.items():
             if status:
                 itm = QListWidgetItem(name, self.__statusList)
@@ -379,16 +388,21 @@
                     itm.setToolTip(self.__statusTexts[status])
                     itm.setIcon(UI.PixmapCache.getIcon(
                         self.__statusIcons[status]))
-                    itm.setData(self.StatusDataRole, status)
+                itm.setData(self.StatusDataRole, status)
                 if status in "AMOR":
                     itm.setFlags(
                         itm.flags() | Qt.ItemFlag.ItemIsUserCheckable)
-                    itm.setCheckState(Qt.CheckState.Checked)
+                    if wasUnpopulated or name in checkedEntries:
+                        itm.setCheckState(Qt.CheckState.Checked)
+                    else:
+                        itm.setCheckState(Qt.CheckState.Unchecked)
                 else:
                     itm.setFlags(
                         itm.flags() & ~Qt.ItemFlag.ItemIsUserCheckable)
+                itm.setSelected(name in selectedEntries)
         
         self.__statusList.sortItems(Qt.SortOrder.AscendingOrder)
+        self.__statusList.blockSignals(block)
         
         self.__updateEnabledStates()
     

eric ide

mercurial