thg-qt-mq / filecontentview.diff

# HG changeset patch
# Parent d7a92323a06a1d48771e19c20e5e00512a9452ce
diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
--- a/tortoisehg/hgqt/fileview.py
+++ b/tortoisehg/hgqt/fileview.py
@@ -116,10 +116,10 @@ class HgFileView(QFrame):
         framelayout.setContentsMargins(0,0,0,0)
         framelayout.setSpacing(0)
 
-        l = QHBoxLayout()
-        l.setContentsMargins(0,0,0,0)
-        l.setSpacing(0)
-        
+        self._contentview = _FileContentView(self)
+        for name in ('escapePressed', 'refreshPressed'):
+            getattr(self._contentview, name).connect(getattr(self, name))
+
         self.topLayout = QVBoxLayout()
 
         self.filenamelabel = w = QLabel()
@@ -136,66 +136,7 @@ class HgFileView(QFrame):
         w.hide()
 
         framelayout.addLayout(self.topLayout)
-        framelayout.addLayout(l, 1)
-
-        self.sci = FileDisplay(self)
-        self.sci.escapePressed.connect(self.escapePressed)
-        self.sci.refreshPressed.connect(self.refreshPressed)
-        self.sci.setFrameStyle(0)
-        l.addWidget(self.sci, 1)
-        #self.sci.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
-        self.sci.setReadOnly(True)
-        self.sci.setUtf8(True)
-
-        self.sci.SendScintilla(qsci.SCI_SETCARETSTYLE, 0)
-
-        self.sci.SendScintilla(qsci.SCI_INDICSETSTYLE, 8, qsci.INDIC_ROUNDBOX)
-        self.sci.SendScintilla(qsci.SCI_INDICSETUNDER, 8, True)
-        self.sci.SendScintilla(qsci.SCI_INDICSETFORE, 8, 0xBBFFFF)
-        self.sci.SendScintilla(qsci.SCI_INDICSETSTYLE, 9, qsci.INDIC_ROUNDBOX)
-        self.sci.SendScintilla(qsci.SCI_INDICSETUNDER, 9, True)
-        self.sci.SendScintilla(qsci.SCI_INDICSETFORE, 9, 0x58A8FF)
-
-        # hide margin 0 (markers)
-        self.sci.SendScintilla(qsci.SCI_SETMARGINTYPEN, 0, 0)
-        self.sci.SendScintilla(qsci.SCI_SETMARGINWIDTHN, 0, 0)
-
-        # define markers for colorize zones of diff
-        self.markerplus = self.sci.markerDefine(qsci.Background)
-        self.sci.SendScintilla(qsci.SCI_MARKERSETBACK, self.markerplus,
-                               0xB0FFA0)
-        self.markerminus = self.sci.markerDefine(qsci.Background)
-        self.sci.SendScintilla(qsci.SCI_MARKERSETBACK, self.markerminus,
-                               0xA0A0FF)
-        self.markertriangle = self.sci.markerDefine(qsci.Background)
-        self.sci.SendScintilla(qsci.SCI_MARKERSETBACK, self.markertriangle,
-                               0xFFA0A0)
-        self.lastrev = None
-        self.sci.mouseMoveEvent = self.mouseMoveEvent
-
-        ll = QVBoxLayout()
-        ll.setContentsMargins(0, 0, 0, 0)
-        ll.setSpacing(0)
-        l.insertLayout(0, ll)
-
-        ll2 = QHBoxLayout()
-        ll2.setContentsMargins(0, 0, 0, 0)
-        ll2.setSpacing(0)
-        ll.addLayout(ll2)
-
-        # used to fill height of the horizontal scroll bar
-        w = QWidget(self)
-        ll.addWidget(w)
-        self._spacer = w
-
-        self.blk = BlockList(self)
-        self.blk.linkScrollBar(self.sci.verticalScrollBar())
-        ll2.addWidget(self.blk)
-        self.blk.setVisible(False)
-
-        self.ann = Annotator(self.sci, self)
-        ll2.addWidget(self.ann)
-        self.ann.setVisible(False)
+        framelayout.addWidget(self._contentview, 1)
 
         self._ctx = None
         self._filename = None
@@ -512,6 +453,80 @@ class HgFileView(QFrame):
         self.sci.setUpdatesEnabled(True)
         self.blk.setUpdatesEnabled(True)
 
+    def __getattr__(self, name):
+        print 'FIXME: forward %s to contentview' % name
+        return getattr(self._contentview, name)
+
+class _FileContentView(QWidget):
+    escapePressed = pyqtSignal()
+    refreshPressed = pyqtSignal()
+
+    def __init__(self, parent=None):
+        super(_FileContentView, self).__init__(parent)
+        l = QHBoxLayout()
+        l.setContentsMargins(0,0,0,0)
+        l.setSpacing(0)
+        self.setLayout(l)
+
+        self.sci = FileDisplay(self)
+        self.sci.escapePressed.connect(self.escapePressed)
+        self.sci.refreshPressed.connect(self.refreshPressed)
+        self.sci.setFrameStyle(0)
+        l.addWidget(self.sci, 1)
+        #self.sci.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
+        self.sci.setReadOnly(True)
+        self.sci.setUtf8(True)
+
+        self.sci.SendScintilla(qsci.SCI_SETCARETSTYLE, 0)
+
+        self.sci.SendScintilla(qsci.SCI_INDICSETSTYLE, 8, qsci.INDIC_ROUNDBOX)
+        self.sci.SendScintilla(qsci.SCI_INDICSETUNDER, 8, True)
+        self.sci.SendScintilla(qsci.SCI_INDICSETFORE, 8, 0xBBFFFF)
+        self.sci.SendScintilla(qsci.SCI_INDICSETSTYLE, 9, qsci.INDIC_ROUNDBOX)
+        self.sci.SendScintilla(qsci.SCI_INDICSETUNDER, 9, True)
+        self.sci.SendScintilla(qsci.SCI_INDICSETFORE, 9, 0x58A8FF)
+
+        # hide margin 0 (markers)
+        self.sci.SendScintilla(qsci.SCI_SETMARGINTYPEN, 0, 0)
+        self.sci.SendScintilla(qsci.SCI_SETMARGINWIDTHN, 0, 0)
+
+        # define markers for colorize zones of diff
+        self.markerplus = self.sci.markerDefine(qsci.Background)
+        self.sci.SendScintilla(qsci.SCI_MARKERSETBACK, self.markerplus,
+                               0xB0FFA0)
+        self.markerminus = self.sci.markerDefine(qsci.Background)
+        self.sci.SendScintilla(qsci.SCI_MARKERSETBACK, self.markerminus,
+                               0xA0A0FF)
+        self.markertriangle = self.sci.markerDefine(qsci.Background)
+        self.sci.SendScintilla(qsci.SCI_MARKERSETBACK, self.markertriangle,
+                               0xFFA0A0)
+        self.lastrev = None
+        self.sci.mouseMoveEvent = self.mouseMoveEvent
+
+        ll = QVBoxLayout()
+        ll.setContentsMargins(0, 0, 0, 0)
+        ll.setSpacing(0)
+        l.insertLayout(0, ll)
+
+        ll2 = QHBoxLayout()
+        ll2.setContentsMargins(0, 0, 0, 0)
+        ll2.setSpacing(0)
+        ll.addLayout(ll2)
+
+        # used to fill height of the horizontal scroll bar
+        w = QWidget(self)
+        ll.addWidget(w)
+        self._spacer = w
+
+        self.blk = BlockList(self)
+        self.blk.linkScrollBar(self.sci.verticalScrollBar())
+        ll2.addWidget(self.blk)
+        self.blk.setVisible(False)
+
+        self.ann = Annotator(self.sci, self)
+        ll2.addWidget(self.ann)
+        self.ann.setVisible(False)
+
 
 class FileData(object):
     def __init__(self, ctx, ctx2, wfile, status=None):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.