Commits

Yuya Nishihara committed 035df0a

mqdock: make sure patch actions catch up changes in model

For example, qpush will update cache of PatchQueueModel and emit dataChanged.
Then, patch actions should be enabled/disabled accordingly.

Comments (0)

Files changed (1)

tortoisehg/hgqt/mq.py

         if self._repoagent:
             newmodel = PatchQueueModel(self._repoagent, self)
             self.queueListWidget.setModel(newmodel)
+            newmodel.dataChanged.connect(self._updatePatchActions)
             selmodel = self.queueListWidget.selectionModel()
             selmodel.currentRowChanged.connect(self.onPatchSelected)
+            self._updatePatchActions()
         else:
             self.queueListWidget.setModel(None)
         if oldmodel:
             model = self.queueListWidget.model()
             self.patchSelected.emit(model.patchName(index))
 
+    @pyqtSlot()
     def _updatePatchActions(self):
         index = self.queueListWidget.currentIndex()
         if index.isValid():
         self.qqueueComboWidget.setEnabled(self.qqueueComboWidget.count() > 1)
         self.qpushAllAct.setEnabled(bool(repo.thgmqunappliedpatches))
         self.qpushAct.setEnabled(bool(repo.thgmqunappliedpatches))
-        self._updatePatchActions()
         self.qpopAct.setEnabled(bool(applied))
         self.qpopAllAct.setEnabled(bool(applied))