Esempio n. 1
0
    def mousePressEvent(self, e):

        """
		Open the tab on a left click and show the context menu on a right click
		
		Arguments:
		e -- a QMouseEvent
		"""

        if e.button() == QtCore.Qt.LeftButton:
            QtGui.QPushButton.mousePressEvent(self, e)
        elif e.button() == QtCore.Qt.RightButton:
            item = self.container._list.sequence.experiment.items[self.item[0]]
            m = item_context_menu.item_context_menu(
                "Item", self, item, self.container._list.sequence.name, self.container.index
            )
            m.popup(e.globalPos())
Esempio n. 2
0
	def contextMenuEvent(self, e):
	
		"""
		Show a context menu
		
		Arguments:
		e -- the content menu event
		"""
	
		target_item = self.itemAt(e.pos())		
		item_name = str(target_item.text(0))
		parent_item = target_item.parent()
		if parent_item != None:
			parent_name = str(parent_item.text(0))		
		else:
			parent_name = None
		index = None
		if parent_name in self.main_window.experiment.items:
			parent_type = self.main_window.experiment.items[parent_name].item_type

			# If the parent is a sequence, get the position of the item in the
			# sequence, because the name by itself is ambiguous since the name
			# may occur multiple times in one sequence
			if parent_type == "sequence":
				index = 0
				for index in range(parent_item.childCount()):
					child = parent_item.child(index)
					if child == target_item:
						break
					index += 1
		
		if item_name not in self.main_window.experiment.items:
			return
		item = self.main_window.experiment.items[item_name]
		m = item_context_menu.item_context_menu("Item", self, item, parent_name, index)
		m.popup(e.globalPos())