eric6/UI/Browser.py

changeset 8143
2c730d5fd177
parent 8114
b7abbf3f82a3
child 8205
4a0f1f896341
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
102 102
103 self.selectedItemsFilter = [BrowserFileItem] 103 self.selectedItemsFilter = [BrowserFileItem]
104 104
105 self._activating = False 105 self._activating = False
106 106
107 self.setContextMenuPolicy(Qt.CustomContextMenu) 107 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
108 self.customContextMenuRequested.connect(self._contextMenuRequested) 108 self.customContextMenuRequested.connect(self._contextMenuRequested)
109 self.activated.connect(self._openItem) 109 self.activated.connect(self._openItem)
110 self.expanded.connect(self._resizeColumns) 110 self.expanded.connect(self._resizeColumns)
111 self.collapsed.connect(self._resizeColumns) 111 self.collapsed.connect(self._resizeColumns)
112 112
165 """ 165 """
166 self.setRootIsDecorated(True) 166 self.setRootIsDecorated(True)
167 self.setAlternatingRowColors(True) 167 self.setAlternatingRowColors(True)
168 168
169 header = self.header() 169 header = self.header()
170 header.setSortIndicator(0, Qt.AscendingOrder) 170 header.setSortIndicator(0, Qt.SortOrder.AscendingOrder)
171 header.setSortIndicatorShown(True) 171 header.setSortIndicatorShown(True)
172 header.setSectionsClickable(True) 172 header.setSectionsClickable(True)
173 173
174 self.setSortingEnabled(True) 174 self.setSortingEnabled(True)
175 175
176 self.setSelectionMode(QAbstractItemView.ExtendedSelection) 176 self.setSelectionMode(
177 self.setSelectionBehavior(QAbstractItemView.SelectRows) 177 QAbstractItemView.SelectionMode.ExtendedSelection)
178 self.setSelectionBehavior(
179 QAbstractItemView.SelectionBehavior.SelectRows)
178 180
179 self.header().setStretchLastSection(True) 181 self.header().setStretchLastSection(True)
180 self.headerSize0 = 0 182 self.headerSize0 = 0
181 self.layoutDisplay() 183 self.layoutDisplay()
182 184
380 index = self.indexAt(coord) 382 index = self.indexAt(coord)
381 383
382 if index.isValid(): 384 if index.isValid():
383 self.setCurrentIndex(index) 385 self.setCurrentIndex(index)
384 flags = QItemSelectionModel.SelectionFlags( 386 flags = QItemSelectionModel.SelectionFlags(
385 QItemSelectionModel.ClearAndSelect | 387 QItemSelectionModel.SelectionFlag.ClearAndSelect |
386 QItemSelectionModel.Rows) 388 QItemSelectionModel.SelectionFlag.Rows)
387 self.selectionModel().select(index, flags) 389 self.selectionModel().select(index, flags)
388 390
389 itm = self.model().item(index) 391 itm = self.model().item(index)
390 coord = self.mapToGlobal(coord) 392 coord = self.mapToGlobal(coord)
391 if isinstance(itm, BrowserFileItem): 393 if isinstance(itm, BrowserFileItem):
860 dname = self.model().item(index).dirName() 862 dname = self.model().item(index).dirName()
861 newName, ok = QInputDialog.getText( 863 newName, ok = QInputDialog.getText(
862 self, 864 self,
863 self.tr("New Directory"), 865 self.tr("New Directory"),
864 self.tr("Name for new directory:"), 866 self.tr("Name for new directory:"),
865 QLineEdit.Normal) 867 QLineEdit.EchoMode.Normal)
866 if ok and bool(newName): 868 if ok and bool(newName):
867 dirpath = os.path.join(dname, newName) 869 dirpath = os.path.join(dname, newName)
868 if os.path.exists(dirpath): 870 if os.path.exists(dirpath):
869 E5MessageBox.warning( 871 E5MessageBox.warning(
870 self, 872 self,
893 dname = self.model().item(index).dirName() 895 dname = self.model().item(index).dirName()
894 fname, ok = QInputDialog.getText( 896 fname, ok = QInputDialog.getText(
895 self, 897 self,
896 self.tr("New File"), 898 self.tr("New File"),
897 self.tr("Name for new file:"), 899 self.tr("Name for new file:"),
898 QLineEdit.Normal) 900 QLineEdit.EchoMode.Normal)
899 if ok and bool(fname): 901 if ok and bool(fname):
900 filepath = os.path.join(dname, fname) 902 filepath = os.path.join(dname, fname)
901 if os.path.exists(filepath): 903 if os.path.exists(filepath):
902 E5MessageBox.warning( 904 E5MessageBox.warning(
903 self, 905 self,
951 dlg = DeleteFilesConfirmationDialog( 953 dlg = DeleteFilesConfirmationDialog(
952 self.parent(), 954 self.parent(),
953 self.tr("Delete File"), 955 self.tr("Delete File"),
954 trashMsg, 956 trashMsg,
955 [fn]) 957 [fn])
956 if dlg.exec() == QDialog.Accepted: 958 if dlg.exec() == QDialog.DialogCode.Accepted:
957 try: 959 try:
958 s2t(fn) 960 s2t(fn)
959 except OSError as err: 961 except OSError as err:
960 E5MessageBox.critical( 962 E5MessageBox.critical(
961 self.ui, 963 self.ui,
988 dlg = DeleteFilesConfirmationDialog( 990 dlg = DeleteFilesConfirmationDialog(
989 self.parent(), 991 self.parent(),
990 self.tr("Delete Directory"), 992 self.tr("Delete Directory"),
991 trashMsg, 993 trashMsg,
992 [dn]) 994 [dn])
993 if dlg.exec() == QDialog.Accepted: 995 if dlg.exec() == QDialog.DialogCode.Accepted:
994 try: 996 try:
995 if s2tAvailable: 997 if s2tAvailable:
996 send2trash(dn) 998 send2trash(dn)
997 else: 999 else:
998 shutil.rmtree(dn, True) 1000 shutil.rmtree(dn, True)
1033 self.parent(), 1035 self.parent(),
1034 self.tr("Delete Files"), 1036 self.tr("Delete Files"),
1035 trashMsg, 1037 trashMsg,
1036 sorted(fileNames) 1038 sorted(fileNames)
1037 ) 1039 )
1038 if dlg.exec() == QDialog.Accepted: 1040 if dlg.exec() == QDialog.DialogCode.Accepted:
1039 for fn in fileNames: 1041 for fn in fileNames:
1040 try: 1042 try:
1041 s2t(fn) 1043 s2t(fn)
1042 except OSError as err: 1044 except OSError as err:
1043 E5MessageBox.critical( 1045 E5MessageBox.critical(

eric ide

mercurial