eric7/EricWidgets/EricPathPicker.py

Sat, 22 May 2021 19:58:24 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 22 May 2021 19:58:24 +0200
branch
eric7
changeset 8358
144a6b854f70
parent 8356
eric7/E5Gui/EricPathPicker.py@68ec9c3d4de5
child 8366
2a9f5153c438
permissions
-rw-r--r--

Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).

4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7703
diff changeset
3 # Copyright (c) 2015 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a path picker widget.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
8265
0090cfa83159 Converted enum names to use all uppercase letters (except for E5PathPickerModes to keep plug-ins using this compatible with previous eric releases).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8257
diff changeset
10 import enum
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 import os
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
13 from PyQt6.QtCore import pyqtSignal, Qt, QFileInfo, QCoreApplication, QDir
8350
74a3b2a6a944 Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
14 from PyQt6.QtWidgets import (
74a3b2a6a944 Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
15 QWidget, QHBoxLayout, QToolButton, QSizePolicy, QLineEdit, QComboBox
74a3b2a6a944 Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
16 )
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
18 from . import EricFileDialog
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
19 from .EricCompleters import EricFileCompleter, EricDirCompleter
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import UI.PixmapCache
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
24 class EricPathPickerModes(enum.Enum):
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 Class implementing the path picker modes.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
8327
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
28 OPEN_FILE_MODE = 0
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
29 OPEN_FILES_MODE = 1
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
30 SAVE_FILE_MODE = 2
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
31 SAVE_FILE_ENSURE_EXTENSION_MODE = 3
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
32 SAVE_FILE_OVERWRITE_MODE = 4
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
33 DIRECTORY_MODE = 5
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
34 DIRECTORY_SHOW_FILES_MODE = 6
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
35 CUSTOM_MODE = 99
666c2b81cbb7 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8322
diff changeset
36 NO_MODE = 100
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
39 class EricPathPickerBase(QWidget):
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
41 Class implementing the base of a path picker widget consisting of a
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
42 line edit or combo box and a tool button to open a file dialog.
4575
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4573
diff changeset
43
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4573
diff changeset
44 @signal textChanged(path) emitted when the entered path has changed
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
45 (line edit based widget)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
46 @signal editTextChanged(path) emitted when the entered path has changed
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
47 (combo box based widget)
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
48 @signal pathSelected(path) emitted after a path has been selected via the
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
49 file dialog
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
50 @signal aboutToShowPathPickerDialog emitted before the file dialog is shown
4597
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
51 @signal pickerButtonClicked emitted when the picker button was pressed and
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
52 the widget mode is custom
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
54 DefaultMode = EricPathPickerModes.NO_MODE
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
4575
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4573
diff changeset
56 textChanged = pyqtSignal(str)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
57 editTextChanged = pyqtSignal(str)
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
58 pathSelected = pyqtSignal(str)
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
59 aboutToShowPathPickerDialog = pyqtSignal()
4597
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
60 pickerButtonClicked = pyqtSignal()
4575
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4573
diff changeset
61
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
62 def __init__(self, parent=None, useLineEdit=True):
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 Constructor
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 @param parent reference to the parent widget
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @type QWidget
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
68 @param useLineEdit flag indicating the use of a line edit
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
69 @type bool
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
71 super().__init__(parent)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
72
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
73 self.__lineEditKind = useLineEdit
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
75 self.__mode = EricPathPicker.DefaultMode
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__editorEnabled = True
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
78 self._completer = None
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 self.__filters = ""
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.__defaultDirectory = ""
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.__windowTitle = ""
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82
8319
ea11a3948f40 Continued porting eric to PyQt6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
83 self.__layout = QHBoxLayout(self)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 self.__layout.setSpacing(0)
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 self.__layout.setContentsMargins(0, 0, 0, 0)
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 self.setLayout(self.__layout)
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
88 if useLineEdit:
8351
7d13e08ddb3f Removed for writing old style XML files and renamed E5XML to EricXML.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8350
diff changeset
89 self._editor = QLineEdit(self)
7d13e08ddb3f Removed for writing old style XML files and renamed E5XML to EricXML.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8350
diff changeset
90 self._editor.setPlaceholderText(QCoreApplication.translate(
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
91 "EricPathPickerBase", "Enter Path Name"))
8350
74a3b2a6a944 Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
92 self._editor.setClearButtonEnabled(True)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
93 else:
8350
74a3b2a6a944 Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
94 self._editor = QComboBox(self)
74a3b2a6a944 Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
95 self._editor.setEditable(True)
74a3b2a6a944 Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
96 self._editor.lineEdit().setPlaceholderText(
74a3b2a6a944 Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
97 QCoreApplication.translate(
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
98 "EricPathPickerBase", "Enter Path Name"))
8350
74a3b2a6a944 Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
99 self._editor.lineEdit().setClearButtonEnabled(True)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 self.__button = QToolButton(self)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
102 self.__button.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly)
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
103 self.__button.setIcon(UI.PixmapCache.getIcon("open"))
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
105 self.__layout.addWidget(self._editor)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.__layout.addWidget(self.__button)
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 self.__button.clicked.connect(self.__showPathPickerDialog)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
109 if useLineEdit:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
110 self._editor.textEdited.connect(self.__pathEdited)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
111 self._editor.textChanged.connect(self.textChanged)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
112 else:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
113 self._editor.editTextChanged.connect(self.editTextChanged)
4589
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
114
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
115 self.setFocusProxy(self._editor)
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
116 self.setFocusPolicy(Qt.FocusPolicy.StrongFocus)
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
117 self.setSizePolicy(QSizePolicy.Policy.Expanding,
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
118 QSizePolicy.Policy.Preferred)
4599
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
119
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
120 self.__button.setEnabled(self.__mode != EricPathPickerModes.NO_MODE)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121
4599
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
122 def __pathEdited(self, path):
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
123 """
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
124 Private slot handling editing of the path.
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
125
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
126 @param path current text of the path line edit
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
127 @type str
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
128 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
129 if self._completer and not self._completer.popup().isVisible():
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
130 self._completer.setRootPath(QDir.toNativeSeparators(path))
4599
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
131
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 def setMode(self, mode):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 Public method to set the path picker mode.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 @param mode picker mode
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
137 @type EricPathPickerModes
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
138 @exception ValueError raised to indicate a bad parameter value
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
140 if mode not in EricPathPickerModes:
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
141 raise ValueError("Bad value for 'mode' parameter.")
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 oldMode = self.__mode
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 self.__mode = mode
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
146 if mode != oldMode or (self.__lineEditKind and not self._completer):
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
147 if self.__lineEditKind and self._completer:
4599
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
148 # Remove current completer
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
149 self._editor.setCompleter(None)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
150 self._completer = None
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
152 if mode != EricPathPickerModes.NO_MODE:
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
153 if self.__lineEditKind:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
154 # Set a new completer
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
155 if mode == EricPathPickerModes.DIRECTORY_MODE:
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
156 self._completer = EricDirCompleter(self._editor)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
157 else:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
158 self._completer = EricFileCompleter(self._editor)
4594
1071d7ec6976 Fixed an issue setting an initial completer if the initial mode was the default mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4593
diff changeset
159
1071d7ec6976 Fixed an issue setting an initial completer if the initial mode was the default mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4593
diff changeset
160 # set inactive text
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
161 if mode == EricPathPickerModes.OPEN_FILES_MODE:
8350
74a3b2a6a944 Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
162 self._editor.setPlaceholderText(
4594
1071d7ec6976 Fixed an issue setting an initial completer if the initial mode was the default mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4593
diff changeset
163 self.tr("Enter Path Names separated by ';'"))
1071d7ec6976 Fixed an issue setting an initial completer if the initial mode was the default mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4593
diff changeset
164 else:
8350
74a3b2a6a944 Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8327
diff changeset
165 self._editor.setPlaceholderText(
4594
1071d7ec6976 Fixed an issue setting an initial completer if the initial mode was the default mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4593
diff changeset
166 self.tr("Enter Path Name"))
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
167 self.__button.setEnabled(self.__mode != EricPathPickerModes.NO_MODE)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 def mode(self):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 Public method to get the path picker mode.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 @return path picker mode
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
174 @rtype EricPathPickerModes
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 return self.__mode
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177
4589
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
178 def setPickerEnabled(self, enable):
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
179 """
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
180 Public method to set the enabled state of the file dialog button.
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
181
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
182 @param enable flag indicating the enabled state
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
183 @type bool
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
184 """
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
185 self.__button.setEnabled(enable)
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
186
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
187 def isPickerEnabled(self):
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
188 """
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
189 Public method to get the file dialog button enabled state.
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
190
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
191 @return flag indicating the enabled state
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
192 @rtype bool
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
193 """
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
194 return self.__button.isEnabled()
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
195
4575
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4573
diff changeset
196 def clear(self):
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4573
diff changeset
197 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
198 Public method to clear the current path or list of paths.
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
199 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
200 self._editor.clear()
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
201
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
202 def clearEditText(self):
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
203 """
4575
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4573
diff changeset
204 Public method to clear the current path.
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4573
diff changeset
205 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
206 if not self.__lineEditKind:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
207 self._editor.clearEditText()
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
208
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
209 def _setEditorText(self, text):
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
210 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
211 Protected method to set the text of the editor.
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
212
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
213 @param text text to set
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
214 @type str
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
215 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
216 if self.__lineEditKind:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
217 self._editor.setText(text)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
218 else:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
219 self._editor.setEditText(text)
5525
1771a7f9065c Added capability to remember previously used entries in the project debugger properties dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
220 if text and self._editor.findText(text) == -1:
1771a7f9065c Added capability to remember previously used entries in the project debugger properties dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
221 self._editor.insertItem(0, text)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
222
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
223 def _editorText(self):
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
224 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
225 Protected method to get the text of the editor.
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
226
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
227 @return text of the editor
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
228 @rtype str
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
229 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
230 if self.__lineEditKind:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
231 return self._editor.text()
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
232 else:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
233 return self._editor.currentText()
4575
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4573
diff changeset
234
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
235 def setText(self, path, toNative=True):
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
236 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 Public method to set the current path.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 @param path path to be set
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 @type str
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
241 @param toNative flag indicating to convert the path into
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
242 a native format
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
243 @type bool
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
245 if self.__mode == EricPathPickerModes.OPEN_FILES_MODE:
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
246 self._setEditorText(path)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 else:
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
248 if toNative:
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
249 path = QDir.toNativeSeparators(path)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
250 self._setEditorText(path)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
251 if self._completer:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
252 self._completer.setRootPath(path)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
254 def text(self, toNative=True):
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 Public method to get the current path.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
258 @param toNative flag indicating to convert the path into
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
259 a native format
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
260 @type bool
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 @return current path
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 @rtype str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
264 if self.__mode == EricPathPickerModes.OPEN_FILES_MODE:
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
265 if toNative:
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
266 return ";".join(
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
267 [QDir.toNativeSeparators(path)
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
268 for path in self._editorText().split(";")])
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
269 else:
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
270 return self._editorText()
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 else:
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
272 if toNative:
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
273 return os.path.expanduser(
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
274 QDir.toNativeSeparators(self._editorText()))
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
275 else:
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
276 return os.path.expanduser(self._editorText())
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
277
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
278 def setEditText(self, path, toNative=True):
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
279 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
280 Public method to set the current path.
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
281
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
282 @param path path to be set
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
283 @type str
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
284 @param toNative flag indicating to convert the path into
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
285 a native format
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
286 @type bool
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
287 """
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
288 self.setText(path, toNative=toNative)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
289
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
290 def currentText(self, toNative=True):
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
291 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
292 Public method to get the current path.
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
293
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
294 @param toNative flag indicating to convert the path into
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
295 a native format
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
296 @type bool
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
297 @return current path
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
298 @rtype str
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
299 """
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
300 return self.text(toNative=toNative)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
302 def setPath(self, path, toNative=True):
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 Public method to set the current path.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 @param path path to be set
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 @type str
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
308 @param toNative flag indicating to convert the path into
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
309 a native format
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
310 @type bool
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 """
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
312 self.setText(path, toNative=toNative)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
314 def path(self, toNative=True):
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 Public method to get the current path.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
318 @param toNative flag indicating to convert the path into
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
319 a native format
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
320 @type bool
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
321 @return current path
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322 @rtype str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 """
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
324 return self.text(toNative=toNative)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
326 def paths(self, toNative=True):
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
327 """
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
328 Public method to get the list of entered paths.
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
329
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
330 @param toNative flag indicating to convert the path into
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
331 a native format
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
332 @type bool
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
333 @return entered paths
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
334 @rtype list of str
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
335 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
336 if self.__mode == EricPathPickerModes.OPEN_FILES_MODE:
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
337 return self.path(toNative=toNative).split(";")
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
338 else:
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
339 return [self.path(toNative=toNative)]
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
340
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
341 def firstPath(self, toNative=True):
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
342 """
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
343 Public method to get the first path of a list of entered paths.
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
344
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
345 @param toNative flag indicating to convert the path into
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
346 a native format
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
347 @type bool
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
348 @return first path
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
349 @rtype str
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
350 """
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
351 return self.paths(toNative=toNative)[0]
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
352
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
353 def lastPath(self, toNative=True):
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
354 """
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
355 Public method to get the last path of a list of entered paths.
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
356
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
357 @param toNative flag indicating to convert the path into
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
358 a native format
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
359 @type bool
4620
49d9c6b58678 Fixed an issue in the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4613
diff changeset
360 @return last path
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
361 @rtype str
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
362 """
4700
dfdcc542198f Little enhancement to the path picker widget to allow to disable the conversion of path separators.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
363 return self.paths(toNative=toNative)[-1]
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
364
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 def setEditorEnabled(self, enable):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
366 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367 Public method to set the path editor's enabled state.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 @param enable flag indicating the enable state
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 @type bool
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
372 if enable != self._editorEnabled:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
373 self._editorEnabled = enable
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
374 self._editor.setEnabled(enable)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376 def editorEnabled(self):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 Public method to get the path editor's enabled state.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 @return flag indicating the enabled state
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 @rtype bool
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
383 return self._editorEnabled
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 def setDefaultDirectory(self, directory):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 Public method to set the default directory.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 @param directory default directory
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 @type str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
391 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
392 self.__defaultDirectory = directory
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 def defaultDirectory(self):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 Public method to get the default directory.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 @return default directory
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 @rtype str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 return self.__defaultDirectory
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
402
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403 def setWindowTitle(self, title):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
404 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
405 Public method to set the path picker dialog window title.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
407 @param title window title
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 @type str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 self.__windowTitle = title
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
412 def windowTitle(self):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
413 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
414 Public method to get the path picker dialog's window title.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416 @return window title
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 @rtype str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 return self.__windowTitle
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 def setFilters(self, filters):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 Public method to set the filters for the path picker dialog.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
425 Note: Multiple filters must be separated by ';;'.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
427 @param filters string containing the file filters
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 @type str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
429 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
430 self.__filters = filters
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
432 def filters(self):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
433 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
434 Public methods to get the filter string.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 @return filter string
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 @rtype str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 return self.__filters
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
441 def setNameFilters(self, filters):
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
442 """
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
443 Public method to set the name filters for the completer.
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
444
4601
0017e7cb67ae Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4599
diff changeset
445 @param filters list of file name filters
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
446 @type list of str
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
447 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
448 if self._completer:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
449 self._completer.model().setNameFilters(filters)
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
450
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 def setButtonToolTip(self, tooltip):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 Public method to set the tool button tool tip.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 @param tooltip text to be set as a tool tip
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 @type str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 self.__button.setToolTip(tooltip)
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 def buttonToolTip(self):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462 Public method to get the tool button tool tip.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 @return tool tip text
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 @rtype str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 return self.__button.toolTip()
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469 def setEditorToolTip(self, tooltip):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 Public method to set the editor tool tip.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473 @param tooltip text to be set as a tool tip
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 @type str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
475 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
476 self._editor.setToolTip(tooltip)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 def editorToolTip(self):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 Public method to get the editor tool tip.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 @return tool tip text
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 @rtype str
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
485 return self._editor.toolTip()
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 def __showPathPickerDialog(self):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 Private slot to show the path picker dialog.
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 """
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
491 if self.__mode == EricPathPickerModes.NO_MODE:
4594
1071d7ec6976 Fixed an issue setting an initial completer if the initial mode was the default mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4593
diff changeset
492 return
1071d7ec6976 Fixed an issue setting an initial completer if the initial mode was the default mode.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4593
diff changeset
493
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
494 if self.__mode == EricPathPickerModes.CUSTOM_MODE:
4597
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
495 self.pickerButtonClicked.emit()
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
496 return
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
497
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
498 self.aboutToShowPathPickerDialog.emit()
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
499
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 windowTitle = self.__windowTitle
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 if not windowTitle:
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
502 if self.__mode == EricPathPickerModes.OPEN_FILE_MODE:
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 windowTitle = self.tr("Choose a file to open")
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
504 elif self.__mode == EricPathPickerModes.OPEN_FILES_MODE:
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 windowTitle = self.tr("Choose files to open")
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
506 elif self.__mode in [
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
507 EricPathPickerModes.SAVE_FILE_MODE,
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
508 EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE,
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
509 EricPathPickerModes.SAVE_FILE_OVERWRITE_MODE]:
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 windowTitle = self.tr("Choose a file to save")
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
511 elif self.__mode == EricPathPickerModes.DIRECTORY_MODE:
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 windowTitle = self.tr("Choose a directory")
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
514 directory = self._editorText()
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
515 if not directory and self.__defaultDirectory:
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
516 directory = self.__defaultDirectory
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
517 directory = (
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
518 os.path.expanduser(directory.split(";")[0])
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
519 if self.__mode == EricPathPickerModes.OPEN_FILES_MODE else
8257
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
520 os.path.expanduser(directory)
28146736bbfc Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8218
diff changeset
521 )
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
522 if not os.path.isabs(directory) and self.__defaultDirectory:
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
523 directory = os.path.join(self.__defaultDirectory, directory)
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
524 directory = QDir.fromNativeSeparators(directory)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
526 if self.__mode == EricPathPickerModes.OPEN_FILE_MODE:
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
527 path = EricFileDialog.getOpenFileName(
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 self,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 windowTitle,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 directory,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 self.__filters)
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
532 path = QDir.toNativeSeparators(path)
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
533 elif self.__mode == EricPathPickerModes.OPEN_FILES_MODE:
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
534 paths = EricFileDialog.getOpenFileNames(
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 self,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 windowTitle,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 directory,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 self.__filters)
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
539 path = ";".join([QDir.toNativeSeparators(path)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 for path in paths])
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
541 elif self.__mode == EricPathPickerModes.SAVE_FILE_MODE:
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
542 path = EricFileDialog.getSaveFileName(
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543 self,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544 windowTitle,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 directory,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 self.__filters,
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
547 EricFileDialog.DontConfirmOverwrite)
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
548 path = QDir.toNativeSeparators(path)
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
549 elif self.__mode == EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE:
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
550 path, selectedFilter = EricFileDialog.getSaveFileNameAndFilter(
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
551 self,
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
552 windowTitle,
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
553 directory,
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
554 self.__filters,
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
555 None,
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
556 EricFileDialog.DontConfirmOverwrite)
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
557 path = QDir.toNativeSeparators(path)
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
558 if path:
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
559 ext = QFileInfo(path).suffix()
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
560 if not ext:
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
561 ex = selectedFilter.split("(*")[1].split(")")[0]
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
562 if ex:
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
563 path += ex
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
564 elif self.__mode == EricPathPickerModes.SAVE_FILE_OVERWRITE_MODE:
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
565 path = EricFileDialog.getSaveFileName(
5036
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4700
diff changeset
566 self,
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4700
diff changeset
567 windowTitle,
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4700
diff changeset
568 directory,
318e879a37fa Added an improved "Print to PDF" to the new web browser for Qt 5.7+.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4700
diff changeset
569 self.__filters)
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
570 path = QDir.toNativeSeparators(path)
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
571 elif self.__mode == EricPathPickerModes.DIRECTORY_MODE:
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
572 path = EricFileDialog.getExistingDirectory(
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 self,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
574 windowTitle,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 directory,
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
576 EricFileDialog.ShowDirsOnly)
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
577 path = QDir.toNativeSeparators(path)
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
578 while path.endswith(os.sep):
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
579 path = path[:-1]
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
580 elif self.__mode == EricPathPickerModes.DIRECTORY_SHOW_FILES_MODE:
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
581 path = EricFileDialog.getExistingDirectory(
5070
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
582 self,
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
583 windowTitle,
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
584 directory,
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
585 EricFileDialog.DontUseNativeDialog)
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
586 path = QDir.toNativeSeparators(path)
5070
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
587 while path.endswith(os.sep):
4e4651e88674 Added capability to set the path to the Qt tools manually (because they are not included in the PyQt5 wheels).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5036
diff changeset
588 path = path[:-1]
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 if path:
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
591 self._setEditorText(path)
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
592 self.pathSelected.emit(path)
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
593
5238
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
594 def setReadOnly(self, readOnly):
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
595 """
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
596 Public method to set the path picker to read only mode.
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
597
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
598 @param readOnly flag indicating read only mode
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
599 @type bool
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
600 """
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
601 try:
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
602 self._editor.setReadOnly(readOnly)
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
603 except AttributeError:
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
604 self._editor.setEditable(not readOnly)
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
605 self.setPickerEnabled(not readOnly)
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
606
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
607 def isReadOnly(self):
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
608 """
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
609 Public method to check the path picker for read only mode.
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
610
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
611 @return flg indicating read only mode
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
612 @rtype bool
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
613 """
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
614 try:
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
615 return self._editor.isReadOnly()
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
616 except AttributeError:
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
617 return not self._editor.isEditable()
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
618
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
619 ##################################################################
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
620 ## Methods below emulate some of the QComboBox API
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
621 ##################################################################
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
622
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
623 def addItems(self, pathsList):
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
624 """
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
625 Public method to add paths to the current list.
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
626
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
627 @param pathsList list of paths to add
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
628 @type list of str
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
629 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
630 self._editor.addItems(pathsList)
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
631
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
632 def addItem(self, path):
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
633 """
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
634 Public method to add a paths to the current list.
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
635
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
636 @param path path to add
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
637 @type str
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
638 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
639 self._editor.addItem(path)
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
640
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
641 def setPathsList(self, pathsList):
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
642 """
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
643 Public method to set the paths list.
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
644
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
645 @param pathsList list of paths
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
646 @type list of str
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
647 """
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
648 self.clear()
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
649 self.addItems(pathsList)
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
650
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
651 def setCurrentIndex(self, index):
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
652 """
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
653 Public slot to set the current index.
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
654
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
655 @param index index of the item to set current
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
656 @type int
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
657 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
658 self._editor.setCurrentIndex(index)
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
659
4589
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
660 def setInsertPolicy(self, policy):
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
661 """
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
662 Public method to set the insertion policy of the combo box.
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
663
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
664 @param policy insertion policy
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
665 @type QComboBox.InsertPolicy
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
666 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
667 self._editor.setInsertPolicy(policy)
4589
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
668
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
669 def setSizeAdjustPolicy(self, policy):
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
670 """
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
671 Public method to set the size adjust policy of the combo box.
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
672
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
673 @param policy size adjust policy
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
674 @type QComboBox.SizeAdjustPolicy
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
675 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
676 self._editor.setSizeAdjustPolicy(policy)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
677
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
678
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
679 class EricPathPicker(EricPathPickerBase):
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
680 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
681 Class implementing a path picker widget consisting of a line edit and a
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
682 tool button to open a file dialog.
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
683 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
684 def __init__(self, parent=None):
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
685 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
686 Constructor
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
687
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
688 @param parent reference to the parent widget
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
689 @type QWidget
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
690 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
691 super().__init__(parent, useLineEdit=True)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
692
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
693
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8351
diff changeset
694 class EricComboPathPicker(EricPathPickerBase):
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
695 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
696 Class implementing a path picker widget consisting of a combobox and a
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
697 tool button to open a file dialog.
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
698 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
699 def __init__(self, parent=None):
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
700 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
701 Constructor
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
702
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
703 @param parent reference to the parent widget
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
704 @type QWidget
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
705 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
706 super().__init__(parent, useLineEdit=False)
5372
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
707
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
708 def getPathItems(self):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
709 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
710 Public method to get the list of remembered paths.
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
711
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
712 @return list od remembered paths
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
713 @rtype list of str
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
714 """
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
715 paths = []
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
716 for index in range(self._editor.count()):
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
717 paths.append(self._editor.itemText(index))
7ba8d3d61fdd Added the capability to edit the history lists to the start dialogs of the debugger.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5238
diff changeset
718 return paths

eric ide

mercurial