QScintilla/Editor.py

changeset 2165
f89fc1162ffe
parent 2164
d67b14a3f884
child 2189
5149cec53130
--- a/QScintilla/Editor.py	Sun Oct 28 20:19:15 2012 +0100
+++ b/QScintilla/Editor.py	Mon Oct 29 19:13:00 2012 +0100
@@ -14,7 +14,7 @@
     pyqtSlot, QCryptographicHash, QEvent, QDateTime, QRegExp, Qt
 from PyQt4.QtGui import QCursor, QPrinter, QPrintDialog, QLineEdit, QActionGroup, \
     QDialog, QAbstractPrintDialog, QInputDialog, QApplication, QMenu, QPalette, QFont, \
-    QPixmap
+    QPixmap, QPainter
 from PyQt4.Qsci import QsciScintilla, QsciMacro, QsciStyledText
 
 from E5Gui.E5Application import e5App
@@ -248,12 +248,10 @@
             self.__unifiedMargins = True
         
         # define the margins markers
-        changePixmap = QPixmap(16, 16)
-        changePixmap.fill(Preferences.getEditorColour("OnlineChangeTraceMarkerSaved"))
-        self.__changeMarkerSaved = self.markerDefine(changePixmap)
-        changePixmap = QPixmap(16, 16)
-        changePixmap.fill(Preferences.getEditorColour("OnlineChangeTraceMarkerUnsaved"))
-        self.__changeMarkerUnsaved = self.markerDefine(changePixmap)
+        self.__changeMarkerSaved = self.markerDefine(self.__createChangeMarkerPixmap(
+            "OnlineChangeTraceMarkerSaved"))
+        self.__changeMarkerUnsaved = self.markerDefine(self.__createChangeMarkerPixmap(
+            "OnlineChangeTraceMarkerUnsaved"))
         self.breakpoint = \
             self.markerDefine(UI.PixmapCache.getPixmap("break.png"))
         self.cbreakpoint = \
@@ -2396,7 +2394,23 @@
     ############################################################################
     ## Change tracing methods below
     ############################################################################
-
+    
+    def __createChangeMarkerPixmap(self, key, size=16, width=4):
+        """
+        Private method to create a pixmap for the change markers.
+        
+        @param key key of the color to use (string)
+        @param size size of the pixmap (integer)
+        @param width width of the marker line (integer)
+        @return create pixmap (QPixmap)
+        """
+        pixmap = QPixmap(size, size)
+        pixmap.fill(Qt.transparent)
+        painter = QPainter(pixmap)
+        painter.fillRect(size - 4, 0, 4, size, Preferences.getEditorColour(key))
+        painter.end()
+        return pixmap
+        
     def __initOnlineChangeTrace(self):
         """
         Private slot to initialize the online change trace.
@@ -2469,6 +2483,9 @@
                     self.markerAdd(lineNo, self.__changeMarkerSaved)
                     self.__hasChangeMarkers = True
         
+        if self.__hasChangeMarkers:
+            self.changeMarkersUpdated.emit(self)
+        
     def __deleteAllChangeMarkers(self):
         """
         Private slot to delete all change markers.
@@ -3687,12 +3704,10 @@
         else:
             self.__onlineChangeTraceTimer.stop()
             self.__deleteAllChangeMarkers()
-        changePixmap = QPixmap(16, 16)
-        changePixmap.fill(Preferences.getEditorColour("OnlineChangeTraceMarkerUnsaved"))
-        self.markerDefine(changePixmap, self.__changeMarkerUnsaved)
-        changePixmap = QPixmap(16, 16)
-        changePixmap.fill(Preferences.getEditorColour("OnlineChangeTraceMarkerSaved"))
-        self.markerDefine(changePixmap, self.__changeMarkerSaved)
+        self.markerDefine(self.__createChangeMarkerPixmap(
+            "OnlineChangeTraceMarkerUnsaved"), self.__changeMarkerUnsaved)
+        self.markerDefine(self.__createChangeMarkerPixmap(
+            "OnlineChangeTraceMarkerSaved"), self.__changeMarkerSaved)
         
         # refresh the annotations display
         self.__refreshAnnotations()

eric ide

mercurial