E5Gui/E5PathPicker.py

changeset 4589
b648ccbdbef9
parent 4581
76999ca7bbf1
child 4593
cc745fa6c914
equal deleted inserted replaced
4586:9221c0c5c66f 4589:b648ccbdbef9
35 OpenFileMode = 0 35 OpenFileMode = 0
36 OpenFilesMode = 1 36 OpenFilesMode = 1
37 SaveFileMode = 2 37 SaveFileMode = 2
38 DirectoryMode = 3 38 DirectoryMode = 3
39 39
40 # TODO: Refactor the classes using a base class with common functions
40 41
41 class E5PathPicker(QWidget): 42 class E5PathPicker(QWidget):
42 """ 43 """
43 Class implementing a path picker widget consisting of a line edit and a 44 Class implementing a path picker widget consisting of a line edit and a
44 tool button to open a file dialog. 45 tool button to open a file dialog.
85 self.__layout.addWidget(self.__editor) 86 self.__layout.addWidget(self.__editor)
86 self.__layout.addWidget(self.__button) 87 self.__layout.addWidget(self.__button)
87 88
88 self.__button.clicked.connect(self.__showPathPickerDialog) 89 self.__button.clicked.connect(self.__showPathPickerDialog)
89 self.__editor.textChanged.connect(self.textChanged) 90 self.__editor.textChanged.connect(self.textChanged)
91
92 self.setFocusProxy(self.__editor)
90 93
91 def setMode(self, mode): 94 def setMode(self, mode):
92 """ 95 """
93 Public method to set the path picker mode. 96 Public method to set the path picker mode.
94 97
125 128
126 @return path picker mode 129 @return path picker mode
127 @rtype E5PathPickerModes 130 @rtype E5PathPickerModes
128 """ 131 """
129 return self.__mode 132 return self.__mode
133
134 def setPickerEnabled(self, enable):
135 """
136 Public method to set the enabled state of the file dialog button.
137
138 @param enable flag indicating the enabled state
139 @type bool
140 """
141 self.__button.setEnabled(enable)
142
143 def isPickerEnabled(self):
144 """
145 Public method to get the file dialog button enabled state.
146
147 @return flag indicating the enabled state
148 @rtype bool
149 """
150 return self.__button.isEnabled()
130 151
131 def clear(self): 152 def clear(self):
132 """ 153 """
133 Public method to clear the current path. 154 Public method to clear the current path.
134 """ 155 """
440 self.__layout.addWidget(self.__editor) 461 self.__layout.addWidget(self.__editor)
441 self.__layout.addWidget(self.__button) 462 self.__layout.addWidget(self.__button)
442 463
443 self.__button.clicked.connect(self.__showPathPickerDialog) 464 self.__button.clicked.connect(self.__showPathPickerDialog)
444 self.__editor.editTextChanged.connect(self.editTextChanged) 465 self.__editor.editTextChanged.connect(self.editTextChanged)
466
467 self.setFocusProxy(self.__editor)
445 468
446 def setMode(self, mode): 469 def setMode(self, mode):
447 """ 470 """
448 Public method to set the path picker mode. 471 Public method to set the path picker mode.
449 472
481 @return path picker mode 504 @return path picker mode
482 @rtype E5PathPickerModes 505 @rtype E5PathPickerModes
483 """ 506 """
484 return self.__mode 507 return self.__mode
485 508
509 def setPickerEnabled(self, enable):
510 """
511 Public method to set the enabled state of the file dialog button.
512
513 @param enable flag indicating the enabled state
514 @type bool
515 """
516 self.__button.setEnabled(enable)
517
518 def isPickerEnabled(self):
519 """
520 Public method to get the file dialog button enabled state.
521
522 @return flag indicating the enabled state
523 @rtype bool
524 """
525 return self.__button.isEnabled()
526
486 def clear(self): 527 def clear(self):
487 """ 528 """
488 Public method to clear the list of paths. 529 Public method to clear the list of paths.
489 """ 530 """
490 self.__editor.clear() 531 self.__editor.clear()
722 763
723 @return tool tip text 764 @return tool tip text
724 @rtype str 765 @rtype str
725 """ 766 """
726 return self.__editor.toolTip() 767 return self.__editor.toolTip()
768
769 def setInsertPolicy(self, policy):
770 """
771 Public method to set the insertion policy of the combo box.
772
773 @param policy insertion policy
774 @type QComboBox.InsertPolicy
775 """
776 self.__editor.setInsertPolicy(policy)
777
778 def setSizeAdjustPolicy(self, policy):
779 """
780 Public method to set the size adjust policy of the combo box.
781
782 @param policy size adjust policy
783 @type QComboBox.SizeAdjustPolicy
784 """
785 self.__editor.setSizeAdjustPolicy(policy)
727 786
728 def __showPathPickerDialog(self): 787 def __showPathPickerDialog(self):
729 """ 788 """
730 Private slot to show the path picker dialog. 789 Private slot to show the path picker dialog.
731 """ 790 """

eric ide

mercurial