156 self._completer = EricDirCompleter(self._editor) |
157 self._completer = EricDirCompleter(self._editor) |
157 else: |
158 else: |
158 self._completer = EricFileCompleter(self._editor) |
159 self._completer = EricFileCompleter(self._editor) |
159 |
160 |
160 # set inactive text |
161 # set inactive text |
161 if mode == EricPathPickerModes.OPEN_FILES_MODE: |
162 if mode in ( |
|
163 EricPathPickerModes.OPEN_FILES_MODE, |
|
164 EricPathPickerModes.OPEN_FILES_AND_DIRS_MODE, |
|
165 ): |
162 self._editor.setPlaceholderText( |
166 self._editor.setPlaceholderText( |
163 self.tr("Enter Path Names separated by ';'")) |
167 self.tr("Enter Path Names separated by ';'")) |
164 else: |
168 else: |
165 self._editor.setPlaceholderText( |
169 self._editor.setPlaceholderText( |
166 self.tr("Enter Path Name")) |
170 self.tr("Enter Path Name")) |
240 @type str |
244 @type str |
241 @param toNative flag indicating to convert the path into |
245 @param toNative flag indicating to convert the path into |
242 a native format |
246 a native format |
243 @type bool |
247 @type bool |
244 """ |
248 """ |
245 if self.__mode == EricPathPickerModes.OPEN_FILES_MODE: |
249 if self.__mode in ( |
|
250 EricPathPickerModes.OPEN_FILES_MODE, |
|
251 EricPathPickerModes.OPEN_FILES_AND_DIRS_MODE, |
|
252 ): |
246 self._setEditorText(path) |
253 self._setEditorText(path) |
247 else: |
254 else: |
248 if toNative: |
255 if toNative: |
249 path = QDir.toNativeSeparators(path) |
256 path = QDir.toNativeSeparators(path) |
250 self._setEditorText(path) |
257 self._setEditorText(path) |
331 a native format |
341 a native format |
332 @type bool |
342 @type bool |
333 @return entered paths |
343 @return entered paths |
334 @rtype list of str |
344 @rtype list of str |
335 """ |
345 """ |
336 if self.__mode == EricPathPickerModes.OPEN_FILES_MODE: |
346 if self.__mode in ( |
|
347 EricPathPickerModes.OPEN_FILES_MODE, |
|
348 EricPathPickerModes.OPEN_FILES_AND_DIRS_MODE, |
|
349 ): |
337 return self.path(toNative=toNative).split(";") |
350 return self.path(toNative=toNative).split(";") |
338 else: |
351 else: |
339 return [self.path(toNative=toNative)] |
352 return [self.path(toNative=toNative)] |
340 |
353 |
341 def firstPath(self, toNative=True): |
354 def firstPath(self, toNative=True): |
501 if not windowTitle: |
514 if not windowTitle: |
502 if self.__mode == EricPathPickerModes.OPEN_FILE_MODE: |
515 if self.__mode == EricPathPickerModes.OPEN_FILE_MODE: |
503 windowTitle = self.tr("Choose a file to open") |
516 windowTitle = self.tr("Choose a file to open") |
504 elif self.__mode == EricPathPickerModes.OPEN_FILES_MODE: |
517 elif self.__mode == EricPathPickerModes.OPEN_FILES_MODE: |
505 windowTitle = self.tr("Choose files to open") |
518 windowTitle = self.tr("Choose files to open") |
|
519 elif self.__mode == EricPathPickerModes.OPEN_FILES_AND_DIRS_MODE: |
|
520 windowTitle = self.tr("Choose files and directories") |
506 elif self.__mode in [ |
521 elif self.__mode in [ |
507 EricPathPickerModes.SAVE_FILE_MODE, |
522 EricPathPickerModes.SAVE_FILE_MODE, |
508 EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE, |
523 EricPathPickerModes.SAVE_FILE_ENSURE_EXTENSION_MODE, |
509 EricPathPickerModes.SAVE_FILE_OVERWRITE_MODE]: |
524 EricPathPickerModes.SAVE_FILE_OVERWRITE_MODE]: |
510 windowTitle = self.tr("Choose a file to save") |
525 windowTitle = self.tr("Choose a file to save") |
514 directory = self._editorText() |
529 directory = self._editorText() |
515 if not directory and self.__defaultDirectory: |
530 if not directory and self.__defaultDirectory: |
516 directory = self.__defaultDirectory |
531 directory = self.__defaultDirectory |
517 directory = ( |
532 directory = ( |
518 os.path.expanduser(directory.split(";")[0]) |
533 os.path.expanduser(directory.split(";")[0]) |
519 if self.__mode == EricPathPickerModes.OPEN_FILES_MODE else |
534 if self.__mode in ( |
|
535 EricPathPickerModes.OPEN_FILES_MODE, |
|
536 EricPathPickerModes.OPEN_FILES_AND_DIRS_MODE) else |
520 os.path.expanduser(directory) |
537 os.path.expanduser(directory) |
521 ) |
538 ) |
522 if not os.path.isabs(directory) and self.__defaultDirectory: |
539 if not os.path.isabs(directory) and self.__defaultDirectory: |
523 directory = os.path.join(self.__defaultDirectory, directory) |
540 directory = os.path.join(self.__defaultDirectory, directory) |
524 directory = QDir.fromNativeSeparators(directory) |
541 directory = QDir.fromNativeSeparators(directory) |
530 directory, |
547 directory, |
531 self.__filters) |
548 self.__filters) |
532 path = QDir.toNativeSeparators(path) |
549 path = QDir.toNativeSeparators(path) |
533 elif self.__mode == EricPathPickerModes.OPEN_FILES_MODE: |
550 elif self.__mode == EricPathPickerModes.OPEN_FILES_MODE: |
534 paths = EricFileDialog.getOpenFileNames( |
551 paths = EricFileDialog.getOpenFileNames( |
|
552 self, |
|
553 windowTitle, |
|
554 directory, |
|
555 self.__filters) |
|
556 path = ";".join([QDir.toNativeSeparators(path) |
|
557 for path in paths]) |
|
558 elif self.__mode == EricPathPickerModes.OPEN_FILES_AND_DIRS_MODE: |
|
559 paths = EricFileDialog.getOpenFileAndDirNames( |
535 self, |
560 self, |
536 windowTitle, |
561 windowTitle, |
537 directory, |
562 directory, |
538 self.__filters) |
563 self.__filters) |
539 path = ";".join([QDir.toNativeSeparators(path) |
564 path = ";".join([QDir.toNativeSeparators(path) |