Commits

Yuya Nishihara committed 9d4b833

ref

Comments (0)

Files changed (3)

repom-dataroles.diff

 # HG changeset patch
 # Date 1395562004 -32400
-# Parent 5d322799240999d7499387e7d84200efba748169
+# Parent 6796124de2aafc62ce73da4cbe4ffdf987dff4a4
 
 diff --git a/tortoisehg/hgqt/repomodel.py b/tortoisehg/hgqt/repomodel.py
 --- a/tortoisehg/hgqt/repomodel.py
 +++ b/tortoisehg/hgqt/repomodel.py
-@@ -77,6 +77,8 @@ UNAPPLIED_PATCH_COLOR = '#999999'
+@@ -77,6 +77,7 @@ UNAPPLIED_PATCH_COLOR = '#999999'
  HIDDENREV_COLOR = '#666666'
  
  GraphRole = Qt.UserRole + 0
 +GraphNodeRole = Qt.UserRole + 1
-+RawContextRole = Qt.UserRole + 2
  
  def get_color(n, ignore=()):
      """
-@@ -509,6 +511,8 @@ class HgRepoListModel(QAbstractTableMode
-         Qt.DisplayRole: 0,
-         Qt.ForegroundRole: len(ALLCOLUMNS),
-         GraphRole: len(ALLCOLUMNS) * 2,
-+        GraphNodeRole: -1,  # no cache
-+        RawContextRole: len(ALLCOLUMNS) * 2 + 1,
-         }
+@@ -395,7 +396,8 @@ class HgRepoListModel(QAbstractTableMode
+         maxradius = self.rowheight / 2
+         return maxradius * (col + 1)
  
-     def data(self, index, role=Qt.DisplayRole):
-@@ -538,14 +542,16 @@ 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] * (self._roleoffsets[RawContextRole] + 1)
-                                for _i in xrange(graphlen - cachelen))
-         data = self._cache[row]
-         offset = self._roleoffsets[role]
--        if role == GraphRole:
-+        if role in (GraphRole, GraphNodeRole, RawContextRole):
-             idx = offset  # row-based
-         else:
-             idx = index.column() + offset
-+        if idx < 0:
-+            return self.rawdata(index, role)
-         if data[idx] is None:
-             try:
-                 result = self.rawdata(index, role)
-@@ -578,6 +584,10 @@ class HgRepoListModel(QAbstractTableMode
-                 return QVariant(QColor(self.namedbranch_color(ctx.branch())))
+-    def graphctx(self, index, ctx, gnode):
++    def graphctx(self, index):
++        gnode = index.data(GraphNodeRole).toPyObject()
+         w = self.col2x(gnode.cols)
+         h = self.rowheight
+ 
+@@ -403,12 +405,12 @@ class HgRepoListModel(QAbstractTableMode
+         pix.fill(QColor(0,0,0,0))
+         painter = QPainter(pix)
+         try:
+-            self._drawgraphctx(painter, index, ctx, gnode)
++            self._drawgraphctx(painter, index, gnode)
+         finally:
+             painter.end()
+         return QVariant(pix)
+ 
+-    def _drawgraphctx(self, painter, index, ctx, gnode):
++    def _drawgraphctx(self, painter, index, gnode):
+         h = self.rowheight
+         dot_y = h / 2
+ 
+@@ -550,6 +552,8 @@ class HgRepoListModel(QAbstractTableMode
+         if (role == Qt.FontRole
+             and index.column() in (NodeColumn, ConvertedColumn)):
+             return QFont("Monospace")
++        if role == GraphNodeRole:
++            return self.graph[index.row()]
+         if (role, index.column()) not in self._cacheindexmap:
+             return nullvariant
+         # repo may be changed while reading in case of postpull=rebase for
+@@ -613,7 +617,7 @@ class HgRepoListModel(QAbstractTableMode
+                 font.setBold(True)
+                 return font
          elif role == GraphRole:
-             return self.graphctx(index, ctx, gnode)
-+        elif role == GraphNodeRole:
-+            return gnode
-+        elif role == RawContextRole:
-+            return ctx
+-            return self.graphctx(index, ctx, gnode)
++            return self.graphctx(index)
          return nullvariant
  
      def flags(self, index):

repom-graphlookup.diff

-# HG changeset patch
-# Date 1395564445 -32400
-# Parent 7246661c09266c8d89541442b8a476912418e150
-
-diff --git a/tortoisehg/hgqt/repomodel.py b/tortoisehg/hgqt/repomodel.py
---- a/tortoisehg/hgqt/repomodel.py
-+++ b/tortoisehg/hgqt/repomodel.py
-@@ -373,7 +373,11 @@ class HgRepoListModel(QAbstractTableMode
-     def col2x(self, col):
-         return 2 * self.dotradius * col + self.dotradius/2 + 8
- 
--    def graphctx(self, index, ctx, gnode):
-+    def graphctx(self, index):
-+        gnode = index.data(GraphNodeRole).toPyObject()
-+        ctx = index.data(RawContextRole).toPyObject()
-+        if gnode is None or ctx is None:
-+            return
-         w = self.col2x(gnode.cols) + 10
-         h = self.rowheight
- 
-@@ -582,7 +586,7 @@ class HgRepoListModel(QAbstractTableMode
-             if column in (GraphColumn, BranchColumn):
-                 return QVariant(QColor(self.namedbranch_color(ctx.branch())))
-         elif role == GraphRole:
--            return self.graphctx(index, ctx, gnode)
-+            return self.graphctx(index)
-         elif role == GraphNodeRole:
-             return gnode
-         elif role == RawContextRole:
 repom-nographrevset.diff
 repom-graphcolor.diff
 repom-dataroles.diff
-repom-graphlookup.diff
 graphdele-split.diff
 graphdele-portrenderer.diff
 repom-nographrole.diff