src/eric7/Plugins/ViewManagerPlugins/Listspace/Listspace.py

branch
eric7
changeset 10380
7c14ccd2a0e1
parent 10212
68b6b5127363
child 10394
056d1b2cd3c4
equal deleted inserted replaced
10379:6f27d7bcfe56 10380:7c14ccd2a0e1
5 5
6 """ 6 """
7 Module implementing the listspace viewmanager class. 7 Module implementing the listspace viewmanager class.
8 """ 8 """
9 9
10 import itertools
10 import os 11 import os
11 12
12 from PyQt6.QtCore import QEvent, Qt, pyqtSignal, pyqtSlot 13 from PyQt6.QtCore import QEvent, Qt, pyqtSignal, pyqtSlot
13 from PyQt6.QtWidgets import ( 14 from PyQt6.QtWidgets import (
14 QApplication, 15 QApplication,
289 self.closeOthersMenuAct = self.__menu.addAction( 290 self.closeOthersMenuAct = self.__menu.addAction(
290 EricPixmapCache.getIcon("tabCloseOther"), 291 EricPixmapCache.getIcon("tabCloseOther"),
291 self.tr("Close Others"), 292 self.tr("Close Others"),
292 self.__contextMenuCloseOthers, 293 self.__contextMenuCloseOthers,
293 ) 294 )
295 self.closeAboveMenuAct = self.__menu.addAction(
296 self.tr("Close Editors Above"),
297 self.__contextMenuCloseAbove,
298 )
299 self.closeBelowMenuAct = self.__menu.addAction(
300 self.tr("Close Editors Below"),
301 self.__contextMenuCloseBelow,
302 )
294 self.__menu.addAction(self.tr("Close All"), self.__contextMenuCloseAll) 303 self.__menu.addAction(self.tr("Close All"), self.__contextMenuCloseAll)
295 self.__menu.addSeparator() 304 self.__menu.addSeparator()
296 self.saveMenuAct = self.__menu.addAction( 305 self.saveMenuAct = self.__menu.addAction(
297 EricPixmapCache.getIcon("fileSave"), self.tr("Save"), self.__contextMenuSave 306 EricPixmapCache.getIcon("fileSave"), self.tr("Save"), self.__contextMenuSave
298 ) 307 )
357 else: 366 else:
358 self.openRejectionsMenuAct.setEnabled(False) 367 self.openRejectionsMenuAct.setEnabled(False)
359 self.__startAct.setEnabled(False) 368 self.__startAct.setEnabled(False)
360 369
361 self.closeOthersMenuAct.setEnabled(self.viewlist.count() > 1) 370 self.closeOthersMenuAct.setEnabled(self.viewlist.count() > 1)
371 self.closeAboveMenuAct.setEnabled(row > 0)
372 self.closeBelowMenuAct.setEnabled(row < self.viewlist.count() - 1)
362 373
363 self.__menu.popup(self.viewlist.mapToGlobal(point)) 374 self.__menu.popup(self.viewlist.mapToGlobal(point))
364 375
365 def mainWidget(self): 376 def mainWidget(self):
366 """ 377 """
838 def __contextMenuCloseOthers(self): 849 def __contextMenuCloseOthers(self):
839 """ 850 """
840 Private method to close the other editors. 851 Private method to close the other editors.
841 """ 852 """
842 index = self.contextMenuIndex 853 index = self.contextMenuIndex
843 for i in list(range(self.viewlist.count() - 1, index, -1)) + list( 854 for i in itertools.chain(
855 range(self.viewlist.count() - 1, index, -1),
844 range(index - 1, -1, -1) 856 range(index - 1, -1, -1)
845 ): 857 ):
858 editor = self.editors[i]
859 self.closeEditorWindow(editor)
860
861 def __contextMenuCloseAbove(self):
862 """
863 Private method to close editors above.
864 """
865 index = self.contextMenuIndex
866 for i in range(index - 1, -1, -1):
867 editor = self.editors[i]
868 self.closeEditorWindow(editor)
869
870 def __contextMenuCloseBelow(self):
871 """
872 Private method to close editors below.
873 """
874 index = self.contextMenuIndex
875 for i in range(self.viewlist.count() - 1, index, -1):
846 editor = self.editors[i] 876 editor = self.editors[i]
847 self.closeEditorWindow(editor) 877 self.closeEditorWindow(editor)
848 878
849 def __contextMenuCloseAll(self): 879 def __contextMenuCloseAll(self):
850 """ 880 """

eric ide

mercurial