E5Gui/E5TextEditSearchWidget.py

changeset 6499
dcff57f91861
parent 6048
82ad8ec9548c
child 6501
d564cd2c9a2d
--- a/E5Gui/E5TextEditSearchWidget.py	Sat Sep 15 16:05:36 2018 +0200
+++ b/E5Gui/E5TextEditSearchWidget.py	Sat Sep 15 19:59:20 2018 +0200
@@ -135,10 +135,7 @@
         
         # place everything together
         self.verticalLayout.addLayout(self.horizontalLayout1)
-        if widthForHeight:
-            self.horizontalLayout1.addLayout(self.horizontalLayout2)
-        else:
-            self.verticalLayout.addLayout(self.horizontalLayout2)
+        self.__addWidthForHeightLayout(widthForHeight)
         self.verticalLayout.addWidget(self.infoLabel)
         
         QMetaObject.connectSlotsByName(self)
@@ -148,6 +145,35 @@
         self.setTabOrder(self.wordCheckBox, self.findPrevButton)
         self.setTabOrder(self.findPrevButton, self.findNextButton)
     
+    def setWidthForHeight(self, widthForHeight):
+        """
+        Public method to set the 'width for height'.
+        
+        @param widthForHeight flag indicating to prefer width
+        @type bool
+        """
+        if self.__widthForHeight:
+            self.horizontalLayout1.takeAt(self.__widthForHeightLayoutIndex)
+        else:
+            self.verticalLayout.takeAt(self.__widthForHeightLayoutIndex)
+        self.__addWidthForHeightLayout(widthForHeight)
+        
+        self.__widthForHeight = widthForHeight
+    
+    def __addWidthForHeightLayout(self, widthForHeight):
+        """
+        Private method to set the middle part of the layout.
+        
+        @param widthForHeight flag indicating to prefer width
+        @type bool
+        """
+        if widthForHeight:
+            self.horizontalLayout1.addLayout(self.horizontalLayout2)
+            self.__widthForHeightLayoutIndex = 2
+        else:
+            self.verticalLayout.insertLayout(1, self.horizontalLayout2)
+            self.__widthForHeightLayoutIndex = 1
+    
     def attachTextEdit(self, textedit, editType="QTextEdit"):
         """
         Public method to attach a QTextEdit widget.

eric ide

mercurial