E5Gui/E5MapWidget.py

changeset 6278
13fd8759f981
parent 6048
82ad8ec9548c
child 6279
7c44be92f8a4
diff -r e22952cec018 -r 13fd8759f981 E5Gui/E5MapWidget.py
--- a/E5Gui/E5MapWidget.py	Sun May 06 15:23:02 2018 +0200
+++ b/E5Gui/E5MapWidget.py	Mon May 07 19:32:49 2018 +0200
@@ -37,6 +37,7 @@
         
         self._master = None
         self.__enabled = False
+        self.__rightSide = True
         
         if parent is not None and isinstance(parent, QAbstractScrollArea):
             self.setMaster(parent)
@@ -62,7 +63,10 @@
                 width = self.__width
             else:
                 width = 0
-            self._master.setViewportMargins(0, 0, width, 0)
+            if self.__rightSide:
+                self._master.setViewportMargins(0, 0, width, 0)
+            else:
+                self._master.setViewportMargins(width, 0, 0, 0)
     
     def setMaster(self, master):
         """
@@ -95,6 +99,31 @@
         """
         return self.__width
     
+    def setMapPosition(self, onRight):
+        """
+        Public method to set, whether the map should be shown to the right or
+        left of the master widget.
+        
+        @param onRight flag indicating to show the map on the right side of
+            the master widget
+        @type bool
+        """
+        if onRight != self.__rightSide:
+            self.__rightSide = onRight
+            self.__updateMasterViewportWidth()
+            self.update()
+    
+    def isOnRightSide(self):
+        """
+        Public method to test, if the map is shown on the right side of the
+        master widget.
+        
+        @return flag indicating that the map is to the right of the master
+            widget
+        @type bool
+        """
+        return self.__rightSide
+    
     def setLineDimensions(self, border, height):
         """
         Public method to set the line (indicator) dimensions.
@@ -245,8 +274,13 @@
             left, top, right, bottom = self._master.getContentsMargins()
             if right > vsbw:
                 vsbw = 0
-            self.setGeometry(QRect(cr.right() - self.__width - vsbw, cr.top(),
-                                   self.__width, cr.height()))
+            if self.__rightSide:
+                self.setGeometry(
+                    QRect(cr.right() - self.__width - vsbw, cr.top(),
+                          self.__width, cr.height()))
+            else:
+                self.setGeometry(
+                    QRect(0, cr.top(), self.__width, cr.height()))
             self.update()
     
     def scaleFactor(self, slider=False):

eric ide

mercurial