Commits

Yuya Nishihara  committed e1c9a4d

manifestdialog: add toolbar button to switch tree/flat view

ManifestWidget will be merged with RevDetailsWidget. This button exists
in order to test flat view until revdetails gains manifest functions.

  • Participants
  • Parent commits 323e196

Comments (0)

Files changed (1)

File tortoisehg/hgqt/manifestdialog.py

         qs.setValue(prefix+'/revpanel.expanded', self.revpanel.is_expanded())
 
     def _initactions(self):
+        flaticon = self.style().standardIcon(QStyle.SP_FileDialogDetailedView)
+        self._flataction = self._toolbar.addAction(flaticon, _('List'))
+        self._flataction.setCheckable(True)
+        self._flataction.triggered.connect(self._setFlat)
+
         self.le = QManifestLineEdit() #QLineEdit()
         if hasattr(self.le, 'setPlaceholderText'): # Qt >= 4.7
             self.le.setPlaceholderText(_('### filter text ###'))
     def _setupmodel(self):
         self._treemodel = ManifestModel(self._repo, self._rev,
                                         statusfilter=self._statusfilter.status(),
+                                        flat=self._flataction.isChecked(),
                                         parent=self)
         self._treemodel.setNameFilter(self.le.text())
 
         self._treemodel.setNameFilter(filtertext)
         self._treeview.enablefilterpalette(filtertext)
 
+    @pyqtSlot(bool)
+    def _setFlat(self, flat):
+        self._treemodel.setFlat(flat)
+        view = self._treeview
+        view.setRootIsDecorated(not flat)
+        if flat:
+            view.setTextElideMode(Qt.ElideLeft)
+        else:
+            view.setTextElideMode(Qt.ElideRight)
+        self._autoexpandtree()
+
     @pyqtSlot()
     def _autoexpandtree(self):
         """expand file tree if the number of the items isn't large"""