4 # |
4 # |
5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to select files and directories simultaneously. |
7 Module implementing a dialog to select files and directories simultaneously. |
8 """ |
8 """ |
|
9 |
|
10 import pathlib |
9 |
11 |
10 from PyQt6.QtCore import pyqtSlot, QItemSelection |
12 from PyQt6.QtCore import pyqtSlot, QItemSelection |
11 from PyQt6.QtGui import QFileSystemModel |
13 from PyQt6.QtGui import QFileSystemModel |
12 from PyQt6.QtWidgets import QFileDialog, QPushButton, QLineEdit, QTreeView |
14 from PyQt6.QtWidgets import QFileDialog, QPushButton, QLineEdit, QTreeView |
13 |
15 |
141 dlg = EricDirFileDialog(parent, caption, directory, filterStr) |
143 dlg = EricDirFileDialog(parent, caption, directory, filterStr) |
142 dlg.setOptions(options) |
144 dlg.setOptions(options) |
143 dlg.exec() |
145 dlg.exec() |
144 |
146 |
145 return dlg.__selectedFilesFolders |
147 return dlg.__selectedFilesFolders |
|
148 |
|
149 @staticmethod |
|
150 def getOpenFileAndDirPaths( |
|
151 parent=None, caption="", directory="", filterStr="", options=None |
|
152 ): |
|
153 """ |
|
154 Static method to get the paths of files and directories for opening it. |
|
155 |
|
156 @param parent parent widget of the dialog |
|
157 @type QWidget |
|
158 @param caption window title of the dialog |
|
159 @type str |
|
160 @param directory working directory of the dialog |
|
161 @type str or pathlib.Path |
|
162 @param filterStr filter string for the dialog |
|
163 @type str |
|
164 @param options various options for the dialog |
|
165 @type QFileDialog.Options |
|
166 @return paths of the selected files and folders |
|
167 @rtype list of pathlib.Path |
|
168 """ |
|
169 if options is None: |
|
170 options = QFileDialog.Option(0) |
|
171 options |= QFileDialog.Option.DontUseNativeDialog |
|
172 dlg = EricDirFileDialog(parent, caption, str(directory), filterStr) |
|
173 dlg.setOptions(options) |
|
174 dlg.exec() |
|
175 |
|
176 return [pathlib.Path(p) for p in dlg.__selectedFilesFolders] |