Commits

Yuya Nishihara committed 881ece2

purge

Comments (0)

Files changed (3)

repom-nographrectcache-exp.diff

-# HG changeset patch
-# Date 1395675561 -32400
-# Parent 14e80a3cfefcf37a47b6af825a3889ead8f6fbeb
-repomodel: remove useless cache of graph rect (HACK)
-
-diff --git a/tortoisehg/hgqt/repomodel.py b/tortoisehg/hgqt/repomodel.py
---- a/tortoisehg/hgqt/repomodel.py
-+++ b/tortoisehg/hgqt/repomodel.py
-@@ -515,7 +515,7 @@ class HgRepoListModel(QAbstractTableMode
-     _roleoffsets = {
-         Qt.DisplayRole: 0,
-         Qt.ForegroundRole: len(ALLCOLUMNS),
--        GraphRole: len(ALLCOLUMNS) * 2,
-+        GraphRole: -1,  # no cache
-         }
- 
-     def data(self, index, role=Qt.DisplayRole):
-@@ -545,14 +545,13 @@ class HgRepoListModel(QAbstractTableMode
-         graphlen = len(self.graph)
-         cachelen = len(self._cache)
-         if graphlen > cachelen:
--            self._cache.extend([None] * (self._roleoffsets[GraphRole] + 1)
-+            self._cache.extend([None] * (2 * len(ALLCOLUMNS))
-                                for _i in xrange(graphlen - cachelen))
-         data = self._cache[row]
-         offset = self._roleoffsets[role]
--        if role == GraphRole:
--            idx = offset  # row-based
--        else:
--            idx = index.column() + offset
-+        if offset == -1:
-+            return self.rawdata(row, index.column(), role)
-+        idx = index.column() + offset
-         if data[idx] is None:
-             try:
-                 result = self.rawdata(row, index.column(), role)

repom-renderscenedirect-exp.diff

-# HG changeset patch
-# Date 1395675471 -32400
-# Parent b697f74fb1c78b2101e2e4931420f2ac2073ee39
-repomodel: render graph directly by GraphDelegate (HACK)
-
-diff --git a/tortoisehg/hgqt/repomodel.py b/tortoisehg/hgqt/repomodel.py
---- a/tortoisehg/hgqt/repomodel.py
-+++ b/tortoisehg/hgqt/repomodel.py
-@@ -382,23 +382,6 @@ class HgRepoListModel(QAbstractTableMode
-         maxradius = self.rowheight / 2
-         return maxradius * (col + 1)
- 
--    def graphctx(self, row, gnode):
--        w = self.col2x(gnode.cols)
--        h = self.rowheight
--
--        pix = QPixmap(w, h)
--        pix.fill(QColor(0,0,0,0))
--        painter = QPainter(pix)
--        try:
--            painter.setRenderHint(QPainter.Antialiasing)
--            self._graphscene.render(painter,
--                                    QRectF(0, 0, pix.width(), pix.height()),
--                                    QRectF(0, row * h,
--                                           pix.width(), pix.height()))
--        finally:
--            painter.end()
--        return QVariant(pix)
--
-     def _drawgraph(self):
-         endrow = len(self.graph)
-         for row in xrange(self._graphbottomrow, endrow):
-@@ -523,6 +506,9 @@ class HgRepoListModel(QAbstractTableMode
-             brush = fillcolor
-             circle(symbolsize)
- 
-+    def graphScene(self):
-+        return self._graphscene
-+
-     def invalidateCache(self):
-         self._cache = []
-         self._graphscene.clear()
-@@ -598,7 +584,8 @@ class HgRepoListModel(QAbstractTableMode
-             if column == BranchColumn:
-                 return QVariant(QColor(self.namedbranch_color(ctx.branch())))
-         elif role == GraphRole:
--            return self.graphctx(row, gnode)
-+            return QRectF(0, row * self.rowheight,
-+                          self.col2x(gnode.cols), self.rowheight)
-         return nullvariant
- 
-     def flags(self, index):
-diff --git a/tortoisehg/hgqt/repoview.py b/tortoisehg/hgqt/repoview.py
---- a/tortoisehg/hgqt/repoview.py
-+++ b/tortoisehg/hgqt/repoview.py
-@@ -423,20 +423,19 @@ class GraphDelegate(QStyledItemDelegate)
- 
-     def paint(self, painter, option, index):
-         QStyledItemDelegate.paint(self, painter, option, index)
--        graph = index.data(repomodel.GraphRole)
--        if graph:
--            # not grayed-out even if revisions are inactive
--            pix = QPixmap(graph)
--            dest = option.rect
--            src = QRect(0, 0, dest.width(), dest.height())
--            painter.drawPixmap(dest, pix, src)
-+        scene = index.model().graphScene()
-+        rect = index.data(repomodel.GraphRole).toRectF()
-+        painter.save()
-+        try:
-+            painter.setRenderHint(QPainter.Antialiasing)
-+            scene.render(painter, QRectF(option.rect),
-+                         QRectF(rect.topLeft(), QSizeF(option.rect.size())))
-+        finally:
-+            painter.restore()
- 
-     def sizeHint(self, option, index):
--        graph = index.data(repomodel.GraphRole)
--        if graph:
--            return QPixmap(graph).size()
--        else:
--            return QSize(0, 0)
-+        rect = index.data(repomodel.GraphRole).toRectF()
-+        return rect.size().toSize()
- 
- class ColumnSelectDialog(QDialog):
-     def __init__(self, name, model, curcolumns, parent=None):
 graphdele-invalidate.diff
 repom-graphscene-exp.diff
-repom-renderscenedirect-exp.diff
-repom-nographrectcache-exp.diff
 repom-graphreuseline-exp.diff
 repom-symmetrical-hack.diff
 repom-drawscene-trace.diff