src/eric7/UI/FindFileWidget.py

branch
eric7
changeset 10484
ad7a6d699a0d
parent 10469
3b0ba2aba1fb
child 10486
157f119cd10d
equal deleted inserted replaced
10483:f919fa592ca9 10484:ad7a6d699a0d
947 Private slot to handle the context menu request. 947 Private slot to handle the context menu request.
948 948
949 @param pos position the context menu shall be shown 949 @param pos position the context menu shall be shown
950 @type QPoint 950 @type QPoint
951 """ 951 """
952 menu = QMenu(self) 952 if (
953 953 self.findList.topLevelItemCount()
954 menu.addAction(self.tr("Open"), self.__openFile) 954 and (self.findList.selectedItems() or self.__replaceMode)
955 menu.addAction(self.tr("Copy Path to Clipboard"), self.__copyToClipboard) 955 ):
956 if self.__replaceMode: 956 menu = QMenu(self)
957 menu.addSeparator() 957
958 menu.addAction(self.tr("Select All"), self.__selectAll) 958 if self.findList.selectedItems():
959 menu.addAction(self.tr("Deselect All"), self.__deselectAll) 959 menu.addAction(self.tr("Open"), self.__openFile)
960 960 menu.addAction(
961 menu.exec(QCursor.pos()) 961 self.tr("Copy Path to Clipboard"), self.__copyToClipboard
962 )
963 if self.__replaceMode:
964 menu.addSeparator()
965 menu.addAction(self.tr("Select All"), self.__selectAll)
966 menu.addAction(self.tr("Deselect All"), self.__deselectAll)
967
968 menu.exec(QCursor.pos())
962 969
963 @pyqtSlot() 970 @pyqtSlot()
964 def __openFile(self): 971 def __openFile(self):
965 """ 972 """
966 Private slot to open the currently selected entry. 973 Private slot to open the currently selected entry.
967 """ 974 """
968 itm = self.findList.selectedItems()[0] 975 selectedItems = self.findList.selectedItems()
969 self.on_findList_itemDoubleClicked(itm, 0) 976 if selectedItems:
977 self.on_findList_itemDoubleClicked(selectedItems[0], 0)
970 978
971 @pyqtSlot() 979 @pyqtSlot()
972 def __copyToClipboard(self): 980 def __copyToClipboard(self):
973 """ 981 """
974 Private slot to copy the path of an entry to the clipboard. 982 Private slot to copy the path of an entry to the clipboard.
975 """ 983 """
976 itm = self.findList.selectedItems()[0] 984 selectedItems = self.findList.selectedItems()
977 fn = itm.parent().text(0) if itm.parent() else itm.text(0) 985 if selectedItems:
978 986 itm = selectedItems[0]
979 cb = QApplication.clipboard() 987 fn = itm.parent().text(0) if itm.parent() else itm.text(0)
980 cb.setText(fn) 988
989 cb = QApplication.clipboard()
990 cb.setText(fn)
981 991
982 @pyqtSlot() 992 @pyqtSlot()
983 def __deselectAll(self): 993 def __deselectAll(self):
984 """ 994 """
985 Private slot to deselect all entries. 995 Private slot to deselect all entries.

eric ide

mercurial