317 @return current path |
317 @return current path |
318 @rtype str |
318 @rtype str |
319 """ |
319 """ |
320 return self.text(toNative=toNative) |
320 return self.text(toNative=toNative) |
321 |
321 |
322 def setPath(self, fpath, toNative=True): |
322 def setPath(self, fpath): |
323 """ |
323 """ |
324 Public method to set the current path. |
324 Public method to set the current path. |
325 |
325 |
326 @param fpath path to be set |
326 @param fpath path to be set |
327 @type str |
327 @type str or pathlib.Path |
328 @param toNative flag indicating to convert the path into |
328 """ |
329 a native format |
329 self.setText(str(fpath), toNative=True) |
330 @type bool |
330 |
331 """ |
331 def path(self): |
332 self.setText(fpath, toNative=toNative) |
|
333 |
|
334 def path(self, toNative=True): |
|
335 """ |
332 """ |
336 Public method to get the current path. |
333 Public method to get the current path. |
337 |
334 |
338 @param toNative flag indicating to convert the path into |
|
339 a native format |
|
340 @type bool |
|
341 @return current path |
335 @return current path |
342 @rtype str |
336 @rtype pathlib.Path |
343 """ |
337 """ |
344 return self.text(toNative=toNative) |
338 return self.paths()[0] |
345 |
339 |
346 def paths(self, toNative=True): |
340 def paths(self): |
347 """ |
341 """ |
348 Public method to get the list of entered paths. |
342 Public method to get the list of entered paths. |
349 |
343 |
350 @param toNative flag indicating to convert the path into |
|
351 a native format |
|
352 @type bool |
|
353 @return entered paths |
344 @return entered paths |
354 @rtype list of str |
345 @rtype list of pathlib.Path |
355 """ |
346 """ |
356 if self.__mode in ( |
347 if self.__mode in ( |
357 EricPathPickerModes.OPEN_FILES_MODE, |
348 EricPathPickerModes.OPEN_FILES_MODE, |
358 EricPathPickerModes.OPEN_FILES_AND_DIRS_MODE, |
349 EricPathPickerModes.OPEN_FILES_AND_DIRS_MODE, |
359 ): |
350 ): |
360 return self.path(toNative=toNative).split(";") |
351 return [pathlib.Path(t) for t in self.text().split(";")] |
361 else: |
352 else: |
362 return [self.path(toNative=toNative)] |
353 return [pathlib.Path(self.text)] |
363 |
354 |
364 def firstPath(self, toNative=True): |
355 def firstPath(self): |
365 """ |
356 """ |
366 Public method to get the first path of a list of entered paths. |
357 Public method to get the first path of a list of entered paths. |
367 |
358 |
368 @param toNative flag indicating to convert the path into |
|
369 a native format |
|
370 @type bool |
|
371 @return first path |
359 @return first path |
372 @rtype str |
360 @rtype pathlib.Path |
373 """ |
361 """ |
374 return self.paths(toNative=toNative)[0] |
362 return self.paths()[0] |
375 |
363 |
376 def lastPath(self, toNative=True): |
364 def lastPath(self): |
377 """ |
365 """ |
378 Public method to get the last path of a list of entered paths. |
366 Public method to get the last path of a list of entered paths. |
379 |
367 |
380 @param toNative flag indicating to convert the path into |
|
381 a native format |
|
382 @type bool |
|
383 @return last path |
368 @return last path |
384 @rtype str |
369 @rtype pathlib.Path |
385 """ |
370 """ |
386 return self.paths(toNative=toNative)[-1] |
371 return self.paths()[-1] |
387 |
372 |
388 def setEditorEnabled(self, enable): |
373 def setEditorEnabled(self, enable): |
389 """ |
374 """ |
390 Public method to set the path editor's enabled state. |
375 Public method to set the path editor's enabled state. |
391 |
376 |
408 def setDefaultDirectory(self, directory): |
393 def setDefaultDirectory(self, directory): |
409 """ |
394 """ |
410 Public method to set the default directory. |
395 Public method to set the default directory. |
411 |
396 |
412 @param directory default directory |
397 @param directory default directory |
413 @type str |
398 @type str or pathlib.Path |
414 """ |
399 """ |
415 self.__defaultDirectory = directory |
400 self.__defaultDirectory = str(directory) |
416 |
401 |
417 def defaultDirectory(self): |
402 def defaultDirectory(self): |
418 """ |
403 """ |
419 Public method to get the default directory. |
404 Public method to get the default directory. |
420 |
405 |
421 @return default directory |
406 @return default directory |
422 @rtype str |
407 @rtype str |
423 """ |
408 """ |
424 return self.__defaultDirectory |
409 return self.__defaultDirectory |
|
410 |
|
411 def defaultDirectoryPath(self): |
|
412 """ |
|
413 Public method to get the default directory as a pathlib.Path object. |
|
414 |
|
415 @return default directory |
|
416 @rtype pathlib.Path |
|
417 """ |
|
418 return pathlib.Path(self.__defaultDirectory) |
425 |
419 |
426 def setWindowTitle(self, title): |
420 def setWindowTitle(self, title): |
427 """ |
421 """ |
428 Public method to set the path picker dialog window title. |
422 Public method to set the path picker dialog window title. |
429 |
423 |
646 |
640 |
647 def addItems(self, pathsList): |
641 def addItems(self, pathsList): |
648 """ |
642 """ |
649 Public method to add paths to the current list. |
643 Public method to add paths to the current list. |
650 |
644 |
651 @param pathsList list of paths to add |
645 @param pathsList list of paths |
652 @type list of str |
646 @type list of str or pathlib.Path |
653 """ |
647 """ |
654 self._editor.addItems(pathsList) |
648 self._editor.addItems(str(f) for f in pathsList) |
655 |
649 |
656 def addItem(self, fpath): |
650 def addItem(self, fpath): |
657 """ |
651 """ |
658 Public method to add a paths to the current list. |
652 Public method to add a paths to the current list. |
659 |
653 |
660 @param fpath path to add |
654 @param fpath path to add |
661 @type str |
655 @type str or pathlib.Path |
662 """ |
656 """ |
663 self._editor.addItem(fpath) |
657 self._editor.addItem(str(fpath)) |
664 |
658 |
665 def setPathsList(self, pathsList): |
659 def setPathsList(self, pathsList): |
666 """ |
660 """ |
667 Public method to set the paths list. |
661 Public method to set the paths list. |
668 |
662 |
669 @param pathsList list of paths |
663 @param pathsList list of paths |
670 @type list of str |
664 @type list of str or pathlib.Path |
671 """ |
665 """ |
672 self.clear() |
666 self.clear() |
673 self.addItems(pathsList) |
667 self.addItems(pathsList) |
674 |
668 |
675 def setCurrentIndex(self, index): |
669 def setCurrentIndex(self, index): |
687 |
681 |
688 @param text text of the item to set current |
682 @param text text of the item to set current |
689 @type str |
683 @type str |
690 """ |
684 """ |
691 self._editor.setCurrentText(text) |
685 self._editor.setCurrentText(text) |
|
686 |
|
687 def setCurrentPath(self, fpath): |
|
688 """ |
|
689 Public method to set the current path. |
|
690 |
|
691 @param fpath current path |
|
692 @type pathlib.Path |
|
693 """ |
|
694 self._editor.setCurrentText(str(fpath)) |
692 |
695 |
693 def setInsertPolicy(self, policy): |
696 def setInsertPolicy(self, policy): |
694 """ |
697 """ |
695 Public method to set the insertion policy of the combo box. |
698 Public method to set the insertion policy of the combo box. |
696 |
699 |
742 |
745 |
743 def getPathItems(self): |
746 def getPathItems(self): |
744 """ |
747 """ |
745 Public method to get the list of remembered paths. |
748 Public method to get the list of remembered paths. |
746 |
749 |
747 @return list od remembered paths |
750 @return list of remembered paths |
748 @rtype list of str |
751 @rtype list of str |
749 """ |
752 """ |
750 paths = [] |
753 paths = [] |
751 for index in range(self._editor.count()): |
754 for index in range(self._editor.count()): |
752 paths.append(self._editor.itemText(index)) |
755 paths.append(self._editor.itemText(index)) |
753 return paths |
756 return paths |
|
757 |
|
758 def getPathLibItems(self): |
|
759 """ |
|
760 Public method to get the list of remembered paths. |
|
761 |
|
762 @return list of remembered paths |
|
763 @rtype list of pathlib.Path |
|
764 """ |
|
765 paths = [] |
|
766 for index in range(self._editor.count()): |
|
767 paths.append(pathlib.Path(self._editor.itemText(index))) |
|
768 return paths |