eric6/E5Gui/E5PathPicker.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

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
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 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
11
7703
1f800f8295ea Third Party packages: removed th no longer needed 'enum' package.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
12 from enum 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
13
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
14 from PyQt5.QtCore import pyqtSignal, Qt, QFileInfo, QCoreApplication, QDir
4601
0017e7cb67ae Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4599
diff changeset
15 from PyQt5.QtWidgets import QWidget, QHBoxLayout, QToolButton, QSizePolicy
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from . import E5FileDialog
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from .E5LineEdit import E5ClearableLineEdit
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from .E5Completers import E5FileCompleter, E5DirCompleter
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
20 from .E5ComboBox import E5ClearableComboBox
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 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
23
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class E5PathPickerModes(Enum):
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 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
28 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 OpenFileMode = 0
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 OpenFilesMode = 1
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 SaveFileMode = 2
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
32 SaveFileEnsureExtensionMode = 3
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
33 SaveFileOverwriteMode = 4
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
34 DirectoryMode = 5
5106
1ecc6c9abca5 Fixed some code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5070
diff changeset
35 DirectoryShowFilesMode = 6
4597
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
36 CustomMode = 99
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
37 NoMode = 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
38
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
40 class E5PathPickerBase(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
41 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
42 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
43 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
44
464a6b049f89 Changed the Python2 debugger and Editor APIs pages to use the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4573
diff changeset
45 @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
46 (line edit based widget)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
47 @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
48 (combo box based widget)
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
49 @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
50 file dialog
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
51 @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
52 @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
53 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
54 """
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
55 DefaultMode = E5PathPickerModes.NoMode
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
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
57 textChanged = pyqtSignal(str)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
58 editTextChanged = pyqtSignal(str)
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
59 pathSelected = pyqtSignal(str)
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
60 aboutToShowPathPickerDialog = pyqtSignal()
4597
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
61 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
62
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
63 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
64 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 Constructor
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 @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
68 @type QWidget
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
69 @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
70 @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
71 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
72 super(E5PathPickerBase, self).__init__(parent)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
73
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
74 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
75
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.__mode = E5PathPicker.DefaultMode
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 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
78
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
79 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
80 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
81 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
82 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
83
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 = QHBoxLayout()
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.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
86 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
87 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
88
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
89 if useLineEdit:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
90 self._editor = E5ClearableLineEdit(
5674
a0ad2dcb27f9 Corrected some translations related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5525
diff changeset
91 self, QCoreApplication.translate(
a0ad2dcb27f9 Corrected some translations related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5525
diff changeset
92 "E5PathPickerBase", "Enter Path Name"))
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
93 else:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
94 self._editor = E5ClearableComboBox(
5679
021e2db1f444 Fixed an issue introduced during the translate fixes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5674
diff changeset
95 self, QCoreApplication.translate(
5674
a0ad2dcb27f9 Corrected some translations related issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5525
diff changeset
96 "E5PathPickerBase", "Enter Path Name"))
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.__button = QToolButton(self)
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 self.__button.setToolButtonStyle(Qt.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
100 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
101
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
102 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
103 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
104
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 self.__button.clicked.connect(self.__showPathPickerDialog)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
106 if useLineEdit:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
107 self._editor.textEdited.connect(self.__pathEdited)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
108 self._editor.textChanged.connect(self.textChanged)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
109 else:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
110 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
111
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
112 self.setFocusProxy(self._editor)
4599
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
113 self.setFocusPolicy(Qt.StrongFocus)
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
114 self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
115
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
116 self.__button.setEnabled(self.__mode != E5PathPickerModes.NoMode)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
4599
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
118 def __pathEdited(self, path):
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
119 """
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
120 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
121
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
122 @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
123 @type str
960d1e63f802 Some little improvements for the path pickers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4597
diff changeset
124 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
125 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
126 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
127
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 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
129 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 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
131
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 @param mode 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
133 @type E5PathPickerModes
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
134 @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
135 """
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
136 if mode not in E5PathPickerModes:
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7533
diff changeset
137 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
138
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139 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
140 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
141
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
142 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
143 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
144 # Remove current completer
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
145 self._editor.setCompleter(None)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
146 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
147
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
148 if mode != E5PathPickerModes.NoMode:
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
149 if self.__lineEditKind:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
150 # Set a new completer
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
151 if mode == E5PathPickerModes.DirectoryMode:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
152 self._completer = E5DirCompleter(self._editor)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
153 else:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
154 self._completer = E5FileCompleter(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
155
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
156 # set inactive text
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
157 if mode == E5PathPickerModes.OpenFilesMode:
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
158 self._editor.setInactiveText(
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 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
160 else:
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
161 self._editor.setInactiveText(
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
162 self.tr("Enter Path Name"))
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.__button.setEnabled(self.__mode != E5PathPickerModes.NoMode)
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165 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
166 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 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
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 @return 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
170 @rtype E5PathPickerModes
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 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
173
4589
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
174 def setPickerEnabled(self, enable):
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
175 """
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
176 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
177
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
178 @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
179 @type bool
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
180 """
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
181 self.__button.setEnabled(enable)
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
182
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
183 def isPickerEnabled(self):
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 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
186
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
187 @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
188 @rtype bool
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
189 """
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
190 return self.__button.isEnabled()
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
191
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
192 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
193 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
194 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
195 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
196 self._editor.clear()
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
197
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
198 def clearEditText(self):
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
199 """
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
200 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
201 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
202 if not self.__lineEditKind:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
203 self._editor.clearEditText()
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
204
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
205 def _setEditorText(self, text):
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
206 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
207 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
208
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
209 @param text text to set
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
210 @type str
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
211 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
212 if self.__lineEditKind:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
213 self._editor.setText(text)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
214 else:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
215 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
216 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
217 self._editor.insertItem(0, text)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
218
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
219 def _editorText(self):
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
220 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
221 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
222
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
223 @return text of the editor
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
224 @rtype str
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
225 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
226 if self.__lineEditKind:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
227 return self._editor.text()
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
228 else:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
229 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
230
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
231 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
232 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 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
234
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 @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
236 @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
237 @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
238 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
239 @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
240 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 if self.__mode == E5PathPickerModes.OpenFilesMode:
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
242 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
243 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
244 if toNative:
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
245 path = QDir.toNativeSeparators(path)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
246 self._setEditorText(path)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
247 if self._completer:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
248 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
249
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
250 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
251 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 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
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 @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
255 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
256 @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
257 @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
258 @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
259 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
260 if self.__mode == E5PathPickerModes.OpenFilesMode:
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
261 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
262 return ";".join(
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
263 [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
264 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
265 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
266 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
267 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
268 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
269 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
270 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
271 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
272 return os.path.expanduser(self._editorText())
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
273
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
274 def setEditText(self, path, toNative=True):
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
275 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
276 Public method to set the current path.
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
277
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
278 @param path path to be set
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
279 @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
280 @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
281 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
282 @type bool
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
283 """
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 self.setText(path, toNative=toNative)
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
285
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
286 def currentText(self, toNative=True):
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
287 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
288 Public method to get the current path.
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 @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
291 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
292 @type bool
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
293 @return current path
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
294 @rtype str
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
295 """
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
296 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
297
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
298 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
299 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 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
301
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 @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
303 @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
304 @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
305 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
306 @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
307 """
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 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
309
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
310 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
311 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 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
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 @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
315 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
316 @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
317 @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
318 @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
319 """
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
320 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
321
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
322 def paths(self, toNative=True):
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
323 """
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
324 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
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 @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
327 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
328 @type bool
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
329 @return entered paths
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
330 @rtype list of str
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
331 """
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
332 if self.__mode == E5PathPickerModes.OpenFilesMode:
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
333 return self.path(toNative=toNative).split(";")
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
334 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
335 return [self.path(toNative=toNative)]
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
336
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 def firstPath(self, toNative=True):
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
338 """
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
339 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
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 @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
342 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
343 @type bool
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
344 @return first path
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
345 @rtype str
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
346 """
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
347 return self.paths(toNative=toNative)[0]
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
348
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
349 def lastPath(self, toNative=True):
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
350 """
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
351 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
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 @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
354 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
355 @type bool
4620
49d9c6b58678 Fixed an issue in the path picker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4613
diff changeset
356 @return last path
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
357 @rtype str
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
358 """
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
359 return self.paths(toNative=toNative)[-1]
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
360
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 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
362 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 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
364
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
365 @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
366 @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
367 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
368 if enable != self._editorEnabled:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
369 self._editorEnabled = enable
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
370 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
371
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 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
373 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 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
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 @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
377 @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
378 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
379 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
380
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 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
382 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 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
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 @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
386 @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
387 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 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
389
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 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
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 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
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 @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
395 @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
396 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 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
398
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 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
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 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
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 @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
404 @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
405 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
406 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
407
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 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
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 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
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 @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
413 @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
414 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 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
416
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 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
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 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
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 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
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 @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
424 @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
425 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
426 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
427
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
428 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
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 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
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 @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
433 @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
434 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
435 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
436
4593
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
437 def setNameFilters(self, filters):
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
438 """
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
439 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
440
4601
0017e7cb67ae Fixed a few code style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4599
diff changeset
441 @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
442 @type list of str
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
443 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
444 if self._completer:
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
445 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
446
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 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
448 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
449 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
450
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 @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
452 @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
453 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454 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
455
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 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
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 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
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 @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
461 @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
462 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 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
464
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 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
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 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
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 @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
470 @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
471 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
472 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
473
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
474 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
475 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 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
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 @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
479 @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
480 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
481 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
482
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 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
484 """
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 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
486 """
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
487 if self.__mode == E5PathPickerModes.NoMode:
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
488 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
489
4597
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
490 if self.__mode == E5PathPickerModes.CustomMode:
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
491 self.pickerButtonClicked.emit()
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
492 return
46be8d9c4dd8 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4594
diff changeset
493
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
494 self.aboutToShowPathPickerDialog.emit()
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
495
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 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
497 if not windowTitle:
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 if self.__mode == E5PathPickerModes.OpenFileMode:
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 windowTitle = self.tr("Choose a file to open")
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 elif self.__mode == E5PathPickerModes.OpenFilesMode:
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 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
502 elif self.__mode in [
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
503 E5PathPickerModes.SaveFileMode,
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
504 E5PathPickerModes.SaveFileEnsureExtensionMode,
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
505 E5PathPickerModes.SaveFileOverwriteMode]:
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 windowTitle = self.tr("Choose a file to save")
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
507 elif self.__mode == E5PathPickerModes.DirectoryMode:
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 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
509
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
510 directory = self._editorText()
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
511 if not directory and self.__defaultDirectory:
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
512 directory = self.__defaultDirectory
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
513 if self.__mode == E5PathPickerModes.OpenFilesMode:
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
514 directory = os.path.expanduser(directory.split(";")[0])
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 else:
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
516 directory = os.path.expanduser(directory)
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
517 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
518 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
519 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
520
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 if self.__mode == E5PathPickerModes.OpenFileMode:
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 path = E5FileDialog.getOpenFileName(
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 self,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 windowTitle,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 directory,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 self.__filters)
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
527 path = 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
528 elif self.__mode == E5PathPickerModes.OpenFilesMode:
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 paths = E5FileDialog.getOpenFileNames(
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 self,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 windowTitle,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 directory,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 self.__filters)
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
534 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
535 for path in paths])
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 elif self.__mode == E5PathPickerModes.SaveFileMode:
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 path = E5FileDialog.getSaveFileName(
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,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 windowTitle,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 directory,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 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
542 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
543 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
544 elif self.__mode == E5PathPickerModes.SaveFileEnsureExtensionMode:
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
545 path, selectedFilter = E5FileDialog.getSaveFileNameAndFilter(
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
546 self,
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
547 windowTitle,
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
548 directory,
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
549 self.__filters,
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
550 None,
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
551 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
552 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
553 if path:
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
554 ext = QFileInfo(path).suffix()
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
555 if not ext:
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
556 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
557 if ex:
cc745fa6c914 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4589
diff changeset
558 path += ex
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
559 elif self.__mode == E5PathPickerModes.SaveFileOverwriteMode:
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
560 path = E5FileDialog.getSaveFileName(
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
561 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
562 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
563 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
564 self.__filters)
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
565 path = QDir.toNativeSeparators(path)
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
566 elif self.__mode == E5PathPickerModes.DirectoryMode:
4573
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 path = E5FileDialog.getExistingDirectory(
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 self,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 windowTitle,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570 directory,
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
571 E5FileDialog.Options(E5FileDialog.ShowDirsOnly))
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
572 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
573 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
574 path = path[:-1]
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
575 elif self.__mode == E5PathPickerModes.DirectoryShowFilesMode:
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
576 path = E5FileDialog.getExistingDirectory(
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
577 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
578 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
579 directory,
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
580 E5FileDialog.Options(E5FileDialog.DontUseNativeDialog))
6670
acebf0124108 E5PathPicker: changed code to make it independent from Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
581 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
582 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
583 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
584
365f39d86985 Added a widget to pick a path and changed the first configuration page.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 if path:
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
586 self._setEditorText(path)
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
587 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
588
5238
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
589 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
590 """
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
591 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
592
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
593 @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
594 @type bool
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 try:
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
597 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
598 except AttributeError:
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
599 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
600 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
601
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
602 def isReadOnly(self):
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
603 """
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
604 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
605
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
606 @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
607 @rtype bool
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 try:
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
610 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
611 except AttributeError:
682d0f6a6074 Fixed an issue with the path picker and its usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5106
diff changeset
612 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
613
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
614 ##################################################################
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
615 ## Methods below emulate some of the QComboBox API
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
616 ##################################################################
4581
76999ca7bbf1 Enhanced the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4578
diff changeset
617
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
618 def addItems(self, pathsList):
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
619 """
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
620 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
621
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
622 @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
623 @type list of str
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
624 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
625 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
626
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
627 def addItem(self, path):
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
628 """
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
629 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
630
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
631 @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
632 @type str
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
633 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
634 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
635
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
636 def setPathsList(self, pathsList):
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
637 """
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
638 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
639
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
640 @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
641 @type list of str
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 self.clear()
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
644 self.addItems(pathsList)
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
645
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
646 def setCurrentIndex(self, index):
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 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
649
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
650 @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
651 @type int
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
652 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
653 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
654
4589
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
655 def setInsertPolicy(self, policy):
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
656 """
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
657 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
658
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
659 @param policy insertion policy
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
660 @type QComboBox.InsertPolicy
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
661 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
662 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
663
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
664 def setSizeAdjustPolicy(self, policy):
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
665 """
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
666 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
667
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
668 @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
669 @type QComboBox.SizeAdjustPolicy
b648ccbdbef9 Modified more dialogs to use the path picker widgets.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4581
diff changeset
670 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
671 self._editor.setSizeAdjustPolicy(policy)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
672
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
673
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
674 class E5PathPicker(E5PathPickerBase):
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
675 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
676 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
677 tool button to open a file dialog.
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
678 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
679 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
680 """
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
681 Constructor
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
682
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
683 @param parent reference to the parent widget
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
684 @type QWidget
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
685 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
686 super(E5PathPicker, self).__init__(parent, useLineEdit=True)
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
687
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
688
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
689 class E5ComboPathPicker(E5PathPickerBase):
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
690 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
691 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
692 tool button to open a file dialog.
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
693 """
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
694 def __init__(self, parent=None):
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 Constructor
4578
5d611151cdec Added a path picker using an editable combo box.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4576
diff changeset
697
4613
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
698 @param parent reference to the parent widget
c7951eb9d525 Refactored the path picker code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4601
diff changeset
699 @type QWidget
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 super(E5ComboPathPicker, self).__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
702
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
703 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
704 """
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
705 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
706
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 @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
708 @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
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 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 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
712 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
713 return paths

eric ide

mercurial