29 QInputDialog, |
29 QInputDialog, |
30 QLineEdit, |
30 QLineEdit, |
31 QDialog, |
31 QDialog, |
32 ) |
32 ) |
33 |
33 |
34 from EricWidgets.EricApplication import ericApp |
34 from eric7.EricWidgets.EricApplication import ericApp |
35 from EricWidgets import EricFileDialog, EricMessageBox |
35 from eric7.EricWidgets import EricFileDialog, EricMessageBox |
36 |
36 |
37 from Project.ProjectBrowserModel import ProjectBrowserSimpleDirectoryItem |
37 from eric7.Project.ProjectBrowserModel import ProjectBrowserSimpleDirectoryItem |
38 from .BrowserModel import ( |
38 from .BrowserModel import ( |
39 BrowserModel, |
39 BrowserModel, |
40 BrowserDirectoryItem, |
40 BrowserDirectoryItem, |
41 BrowserFileItem, |
41 BrowserFileItem, |
42 BrowserClassItem, |
42 BrowserClassItem, |
48 BrowserGlobalsItem, |
48 BrowserGlobalsItem, |
49 BrowserItemDirectory, |
49 BrowserItemDirectory, |
50 ) |
50 ) |
51 from .BrowserSortFilterProxyModel import BrowserSortFilterProxyModel |
51 from .BrowserSortFilterProxyModel import BrowserSortFilterProxyModel |
52 |
52 |
53 import UI.PixmapCache |
53 from eric7.EricGui import EricPixmapCache |
54 import Preferences |
54 from eric7 import Preferences, Utilities |
55 import Utilities |
55 from eric7.Utilities import MimeTypes |
56 import Utilities.MimeTypes |
|
57 |
56 |
58 |
57 |
59 class Browser(QTreeView): |
58 class Browser(QTreeView): |
60 """ |
59 """ |
61 Class used to display a file system tree. |
60 Class used to display a file system tree. |
111 @param parent parent widget (QWidget) |
110 @param parent parent widget (QWidget) |
112 """ |
111 """ |
113 super().__init__(parent) |
112 super().__init__(parent) |
114 |
113 |
115 self.setWindowTitle(QCoreApplication.translate("Browser", "File-Browser")) |
114 self.setWindowTitle(QCoreApplication.translate("Browser", "File-Browser")) |
116 self.setWindowIcon(UI.PixmapCache.getIcon("eric")) |
115 self.setWindowIcon(EricPixmapCache.getIcon("eric")) |
117 |
116 |
118 self.__model = BrowserModel() |
117 self.__model = BrowserModel() |
119 self.__sortModel = BrowserSortFilterProxyModel() |
118 self.__sortModel = BrowserSortFilterProxyModel() |
120 self.__sortModel.setSourceModel(self.__model) |
119 self.__sortModel.setSourceModel(self.__model) |
121 self.setModel(self.__sortModel) |
120 self.setModel(self.__sortModel) |
545 elif itm.isPixmapFile(): |
544 elif itm.isPixmapFile(): |
546 self.pixmapFile.emit(itm.fileName()) |
545 self.pixmapFile.emit(itm.fileName()) |
547 elif itm.isEricGraphicsFile(): |
546 elif itm.isEricGraphicsFile(): |
548 self.umlFile.emit(itm.fileName()) |
547 self.umlFile.emit(itm.fileName()) |
549 else: |
548 else: |
550 if Utilities.MimeTypes.isTextFile(itm.fileName()): |
549 if MimeTypes.isTextFile(itm.fileName()): |
551 self.sourceFile[str].emit(itm.fileName()) |
550 self.sourceFile[str].emit(itm.fileName()) |
552 else: |
551 else: |
553 QDesktopServices.openUrl(QUrl(itm.fileName())) |
552 QDesktopServices.openUrl(QUrl(itm.fileName())) |
554 elif isinstance(itm, BrowserClassItem): |
553 elif isinstance(itm, BrowserClassItem): |
555 self.sourceFile[str, int].emit( |
554 self.sourceFile[str, int].emit( |
579 BrowserClassAttributeItem, |
578 BrowserClassAttributeItem, |
580 BrowserImportItem, |
579 BrowserImportItem, |
581 ] |
580 ] |
582 ) |
581 ) |
583 if itmList: |
582 if itmList: |
584 mimetype = Utilities.MimeTypes.mimeType(itmList[0].fileName()) |
583 mimetype = MimeTypes.mimeType(itmList[0].fileName()) |
585 if mimetype is None: |
584 if mimetype is None: |
586 EricMessageBox.warning( |
585 EricMessageBox.warning( |
587 self, |
586 self, |
588 QCoreApplication.translate("Browser", "Show Mime-Type"), |
587 QCoreApplication.translate("Browser", "Show Mime-Type"), |
589 QCoreApplication.translate( |
588 QCoreApplication.translate( |
657 Protected slot to handle the Open in Editor menu action. |
656 Protected slot to handle the Open in Editor menu action. |
658 """ |
657 """ |
659 itmList = self.getSelectedItems([BrowserFileItem]) |
658 itmList = self.getSelectedItems([BrowserFileItem]) |
660 |
659 |
661 for itm in itmList: |
660 for itm in itmList: |
662 if Utilities.MimeTypes.isTextFile(itm.fileName()): |
661 if MimeTypes.isTextFile(itm.fileName()): |
663 self.sourceFile.emit(itm.fileName()) |
662 self.sourceFile.emit(itm.fileName()) |
664 |
663 |
665 def _copyToClipboard(self): |
664 def _copyToClipboard(self): |
666 """ |
665 """ |
667 Protected method to copy the text shown for an entry to the clipboard. |
666 Protected method to copy the text shown for an entry to the clipboard. |
1019 trashMsg = self.tr("Do you really want to move this file to the" " trash?") |
1018 trashMsg = self.tr("Do you really want to move this file to the" " trash?") |
1020 except ImportError: |
1019 except ImportError: |
1021 s2t = os.remove |
1020 s2t = os.remove |
1022 trashMsg = self.tr("Do you really want to delete this file?") |
1021 trashMsg = self.tr("Do you really want to delete this file?") |
1023 |
1022 |
1024 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
1023 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
1025 |
1024 |
1026 dlg = DeleteFilesConfirmationDialog( |
1025 dlg = DeleteFilesConfirmationDialog( |
1027 self.parent(), self.tr("Delete File"), trashMsg, [fn] |
1026 self.parent(), self.tr("Delete File"), trashMsg, [fn] |
1028 ) |
1027 ) |
1029 if dlg.exec() == QDialog.DialogCode.Accepted: |
1028 if dlg.exec() == QDialog.DialogCode.Accepted: |
1055 ) |
1054 ) |
1056 except ImportError: |
1055 except ImportError: |
1057 s2tAvailable = False |
1056 s2tAvailable = False |
1058 trashMsg = self.tr("Do you really want to delete this directory?") |
1057 trashMsg = self.tr("Do you really want to delete this directory?") |
1059 |
1058 |
1060 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
1059 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
1061 |
1060 |
1062 dlg = DeleteFilesConfirmationDialog( |
1061 dlg = DeleteFilesConfirmationDialog( |
1063 self.parent(), self.tr("Delete Directory"), trashMsg, [dn] |
1062 self.parent(), self.tr("Delete Directory"), trashMsg, [dn] |
1064 ) |
1063 ) |
1065 if dlg.exec() == QDialog.DialogCode.Accepted: |
1064 if dlg.exec() == QDialog.DialogCode.Accepted: |
1098 ) |
1097 ) |
1099 except ImportError: |
1098 except ImportError: |
1100 s2t = os.remove |
1099 s2t = os.remove |
1101 trashMsg = self.tr("Do you really want to delete these files?") |
1100 trashMsg = self.tr("Do you really want to delete these files?") |
1102 |
1101 |
1103 from UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
1102 from eric7.UI.DeleteFilesConfirmationDialog import DeleteFilesConfirmationDialog |
1104 |
1103 |
1105 dlg = DeleteFilesConfirmationDialog( |
1104 dlg = DeleteFilesConfirmationDialog( |
1106 self.parent(), self.tr("Delete Files"), trashMsg, sorted(fileNames) |
1105 self.parent(), self.tr("Delete Files"), trashMsg, sorted(fileNames) |
1107 ) |
1106 ) |
1108 if dlg.exec() == QDialog.DialogCode.Accepted: |
1107 if dlg.exec() == QDialog.DialogCode.Accepted: |