[qt4] rename actions container of hg-scintilla object

It shall be a "public" property as we need to access it ouside the class implementation.

related to:#107995
authorAlain Leufroy <alain@leufroy.fr>
changesetff85afbaabef
branchdefault
phasedraft
hiddenyes
parent revision#4d568f7fce4d [qt4] move scintilla initialization into to dedicated class
child revision#ac4ddc09c927 [qt4] move scintilla code into dedicated class
files modified by this revision
hgviewlib/qt4/hgfileview.py
hgviewlib/qt4/hgrepoviewer.py
# HG changeset patch
# User Alain Leufroy <alain@leufroy.fr>
# Date 1368240250 -7200
# Sat May 11 04:44:10 2013 +0200
# Node ID ff85afbaabef9aee456bd3b7a125e2816a244c01
# Parent 4d568f7fce4d3eb036d5a30f41d49fcd8923b28c
[qt4] rename actions container of hg-scintilla object

It shall be a "public" property as we need to access it ouside the class implementation.

:related to: #107995

diff --git a/hgviewlib/qt4/hgfileview.py b/hgviewlib/qt4/hgfileview.py
@@ -92,10 +92,11 @@
1 
2  class HgQsci(qsci):
3 
4      def __init__(self, *args, **kwargs):
5          super(HgQsci, self).__init__(*args, **kwargs)
6 +        self.actions = {}
7          self.createActions()
8          self.setFrameStyle(0)
9 
10          self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
11          self.setReadOnly(True)
@@ -142,33 +143,33 @@
12               ("openeditor", self.tr("Open in Editor"), 'openeditor',
13                self.tr("Open file in Editor at the current revision"), None, None),
14          ]
15 
16      def createActions(self):
17 -        self._actions = {}
18 +        self.actions = {}
19          for name, desc, icon, tip, key, cb in self._action_defs():
20              act = QtGui.QAction(desc, self)
21              if icon:
22                  act.setIcon(geticon(icon))
23              if tip:
24                  act.setStatusTip(tip)
25              if key:
26                  act.setShortcut(key)
27              if cb:
28                  act.triggered.connect(cb)
29 -            self._actions[name] = act
30 +            self.actions[name] = act
31              self.addAction(act)
32 -        self._actions['diffmode'].setCheckable(True)
33 -        self._actions['annmode'].setCheckable(True)
34 -        self._actions['show-big-file'].setCheckable(True)
35 +        self.actions['diffmode'].setCheckable(True)
36 +        self.actions['annmode'].setCheckable(True)
37 +        self.actions['show-big-file'].setCheckable(True)
38 
39      def contextMenuEvent(self, event):
40          menu = QtGui.QMenu(self)
41          for act in [None, 'diffmode', 'prev', 'next',
42                      None, 'show-big-file', None, 'openeditor']:
43              if act:
44 -                menu.addAction(self._actions[act])
45 +                menu.addAction(self.actions[act])
46              else:
47                  menu.addSeparator()
48          menu.exec_(event.globalPos())
49 
50 
@@ -237,17 +238,17 @@
51          self.filedata = None
52 
53          self.timer = QtCore.QTimer()
54          self.timer.setSingleShot(False)
55          self.timer.timeout.connect(self.idle_fill_files)
56 -        self.sci._actions['diffmode'].toggled[bool].connect(self.setMode)
57 -        self.sci._actions['annmode'].toggled[bool].connect(self.setAnnotate)
58 -        self.sci._actions['prev'].triggered.connect(self.prevDiff)
59 -        self.sci._actions['next'].triggered.connect(self.nextDiff)
60 -        self.sci._actions['show-big-file'].toggled[bool].connect(self.showBigFile)
61 -        self.sci._actions['openeditor'].triggered.connect(self.openEditor)
62 -        self.sci._actions['diffmode'].setChecked(True)
63 +        self.sci.actions['diffmode'].toggled[bool].connect(self.setMode)
64 +        self.sci.actions['annmode'].toggled[bool].connect(self.setAnnotate)
65 +        self.sci.actions['prev'].triggered.connect(self.prevDiff)
66 +        self.sci.actions['next'].triggered.connect(self.nextDiff)
67 +        self.sci.actions['show-big-file'].toggled[bool].connect(self.showBigFile)
68 +        self.sci.actions['openeditor'].triggered.connect(self.openEditor)
69 +        self.sci.actions['diffmode'].setChecked(True)
70 
71      def resizeEvent(self, event):
72          QtGui.QFrame.resizeEvent(self, event)
73          h = self.sci.horizontalScrollBar().height()
74          self._spacer.setMinimumHeight(h)
@@ -268,13 +269,13 @@
75      def setMode(self, mode):
76          if isinstance(mode, bool):
77              mode = ['file', 'diff'][mode]
78          assert mode in ('diff', 'file')
79 
80 -        self.sci._actions['annmode'].setEnabled(not mode)
81 -        self.sci._actions['next'].setEnabled(not mode)
82 -        self.sci._actions['prev'].setEnabled(not mode)
83 +        self.sci.actions['annmode'].setEnabled(not mode)
84 +        self.sci.actions['next'].setEnabled(not mode)
85 +        self.sci.actions['prev'].setEnabled(not mode)
86          if mode != self._mode:
87              self._mode = mode
88              self.blk.setVisible(self._mode == 'file')
89              self.ann.setVisible(self._mode == 'file' and self._annotate)
90 
@@ -291,11 +292,11 @@
91          self.cfg = HgConfig(self._model.repo.ui)
92          if self._model.graph:
93              is_show_big_file = self._model.graph.maxfilesize < 0
94          else:
95              is_show_big_file = self.cfg.getMaxFileSize()
96 -        self.sci._actions['show-big-file'].setChecked(is_show_big_file)
97 +        self.sci.actions['show-big-file'].setChecked(is_show_big_file)
98          self.sci.clear()
99 
100      def setContext(self, ctx):
101          self._ctx = ctx
102          self._p_rev = None
@@ -376,11 +377,11 @@
103          self.filenamelabel.setText(labeltxt)
104 
105          self.sci.setText(data)
106          if self._find_text:
107              self.highlightSearchString(self._find_text)
108 -        self.sci._actions['prev'].setEnabled(False)
109 +        self.sci.actions['prev'].setEnabled(False)
110          self.updateDiffDecorations()
111          if self._mode == 'file' and self._annotate:
112              if filectx.rev() is None: # XXX hide also for binary files
113                  self.ann.setVisible(False)
114              else:
@@ -446,12 +447,12 @@
115              self.sci.verticalScrollBar().setValue(lo)
116              return not last
117 
118      def nextDiff(self):
119          notlast = self._nextDiff()
120 -        self.sci._actions['next'].setEnabled(self.fileMode() and notlast and self.nDiffs())
121 -        self.sci._actions['prev'].setEnabled(self.fileMode() and self.nDiffs())
122 +        self.sci.actions['next'].setEnabled(self.fileMode() and notlast and self.nDiffs())
123 +        self.sci.actions['prev'].setEnabled(self.fileMode() and self.nDiffs())
124 
125      def _prevDiff(self):
126          if self._mode == 'file':
127              row, column = self.sci.getCursorPosition()
128              for i, (lo, hi) in enumerate(reversed(self._diffs)):
@@ -464,12 +465,12 @@
129              self.sci.verticalScrollBar().setValue(lo)
130              return not first
131 
132      def prevDiff(self):
133          notfirst = self._prevDiff()
134 -        self.sci._actions['prev'].setEnabled(self.fileMode() and notfirst and self.nDiffs())
135 -        self.sci._actions['next'].setEnabled(self.fileMode() and self.nDiffs())
136 +        self.sci.actions['prev'].setEnabled(self.fileMode() and notfirst and self.nDiffs())
137 +        self.sci.actions['next'].setEnabled(self.fileMode() and self.nDiffs())
138 
139 
140 
141      def nextLine(self):
142          x, y = self.sci.getCursorPosition()
@@ -548,11 +549,11 @@
143          self.blk.setUpdatesEnabled(False)
144          for n in range(30): # burst pool
145              if self._diff is None or not self._diff.get_opcodes():
146                  self._diff = None
147                  self.timer.stop()
148 -                self.sci._actions['next'].setEnabled(self.fileMode() and self.nDiffs())
149 +                self.sci.actions['next'].setEnabled(self.fileMode() and self.nDiffs())
150                  break
151 
152              tag, alo, ahi, blo, bhi = self._diff.get_opcodes().pop(0)
153              if tag == 'replace':
154                  self._diffs.append([blo, bhi])
diff --git a/hgviewlib/qt4/hgrepoviewer.py b/hgviewlib/qt4/hgrepoviewer.py
@@ -246,11 +246,11 @@
155 
156          self.startrev_label_action = self.toolBar_treefilters.addWidget(self.startrev_label)
157          self.startrev_entry_action = self.toolBar_treefilters.addWidget(self.startrev_entry)
158 
159          # diff mode toolbar
160 -        actions = self.textview_status.sci._actions
161 +        actions = self.textview_status.sci.actions
162          for action_name in ('diffmode', 'prev', 'next', 'show-big-file',
163                              'openeditor'):
164              self.toolBar_diff.addAction(actions[action_name])
165 
166          # rev mod toolbar