Commits

Yuya Nishihara committed 8fcc699

graphdelegate: calculate height hint by default implementation

Because now label margins are ensured by LabeledDelegate, GraphDelegate can
simply forward sizeHint request to QStyledItemDelegate.

This also backs out e6d85d7f9f96.

  • Participants
  • Parent commits 751ec7f

Comments (0)

Files changed (1)

tortoisehg/hgqt/repoview.py

 
 class GraphDelegate(QStyledItemDelegate):
 
-    def __init__(self, parent):
+    def __init__(self, parent=None):
         super(GraphDelegate, self).__init__(parent)
-        assert isinstance(parent, QWidget)
-        # assumes 4px as text and decoration margins of other columns
-        fm = parent.fontMetrics()
-        self._rowheight = self._rowheighthint = max(fm.height() + 4, 16)
+        self._rowheight = 16  # updated to the actual height on paint()
 
     def _col2x(self, col):
         maxradius = max(self._rowheight / 2, 1)
             circle(symbolsize)
 
     def sizeHint(self, option, index):
+        size = super(GraphDelegate, self).sizeHint(option, index)
         gnode = index.data(repomodel.GraphNodeRole).toPyObject()
         if gnode:
             # return width for current height assuming that row height
             # is calculated first (mimic width-for-height policy)
-            return QSize(self._col2x(gnode.cols), self._rowheighthint)
+            return QSize(self._col2x(gnode.cols), max(size.height(), 16))
         else:
-            return QSize(0, 0)
+            return size
 
 
 class _LabelsLayout(object):