def mousePressEvent(self, e):

		"""
		desc:
			Initiates a drag event after a mouse press.

		arguments:
			e:
				desc:	A mouse event.
				type:	QMouseEvent
		"""

		if e.buttons() != QtCore.Qt.LeftButton:
			return
		name = u'new_%s' % self.item
		data = {
			u'type'				: u'item-snippet',
			u'main-item-name'	: name,
			u'items'			: [{
				u'item-type'	: self.item,
				u'item-name'	: name,
				u'script'		: u''
				}]
			}
		drag_and_drop.send(self, data)
Exemple #2
0
    def mousePressEvent(self, e):
        """
		desc:
			Initiates a drag event after a mouse press.

		arguments:
			e:
				desc:	A mouse event.
				type:	QMouseEvent
		"""

        if e.buttons() != QtCore.Qt.LeftButton:
            return
        name = u'new_%s' % self.item
        data = {
            u'type':
            u'item-snippet',
            u'main-item-name':
            name,
            u'items': [{
                u'item-type': self.item,
                u'item-name': name,
                u'script': u''
            }]
        }
        drag_and_drop.send(self, data)
Exemple #3
0
	def start_drag(self):

		"""
		desc:
			Starts a pending drag operation (if any).
		"""

		if self.pending_drag_data == None:
			return
		drag_and_drop.send(self, self.pending_drag_data)
		self.pending_drag_data = None
Exemple #4
0
    def start_drag(self):
        """
		desc:
			Starts a pending drag operation (if any).
		"""

        if self.pending_drag_data is None:
            return
        drag_and_drop.send(self, self.pending_drag_data)
        self.end_drag()
        self.pending_drag_data = None
	def mousePressEvent(self, e):

		"""
		desc:
			Processes mouse-press events. Mouse presses can have a number of
			effects.

			- All selected elements are deselected unless Control is pressed
			- Left clicks:
				- If the pointer tool is selected, clicking an element selects
				  it.
				- If an element tool is selected, clicking gives the element
				  tool the opporunity (to start a) drawing operation.
			- Right clicks:
				- If an element is selected, a context menu is shown.

		arguments:
			e:
				type:	QMouseEvent
		"""

		# When control is not pressed, we deselect all currently selected
		# elements first
		if not QtCore.Qt.ControlModifier & e.modifiers():
			for element in self.sketchpad.elements:
				element.select(False)
		element = self.element_at(e.scenePos())
		if QtCore.Qt.RightButton & e.button() and element is not None:
			# The right buttons pops up a context menu.
			element.show_context_menu(e.screenPos())
		if QtCore.Qt.LeftButton & e.button():
			# The left button selects and drags.
			if self.selected_element_tool is not None:
				# When in pointer-tool mode, mouse clicks create new elements.
				self.sketchpad.add_element(
					self.selected_element_tool.mouse_press(self.sketchpad,
					self.cursor_pos(e)))
			elif element is None:
				self.sketchpad.select_pointer_tool()
			else:
				element.select()
				self.sketchpad.show_element_settings(element)
				x, y = self.cursor_pos(e, grid=False)
				self.start_move_pos = x, y
				data = {
					u'type'		: u'sketchpad-element-move',
					u'from_x'	: x,
					u'from_y'	: y
					}
				drag_and_drop.send(e.widget(), data)
Exemple #6
0
	def mousePressEvent(self, e):

		"""
		desc:
			Processes mouse-press events. Mouse presses can have a number of
			effects.

			- All selected elements are deselected unless Control is pressed
			- Left clicks:
				- If the pointer tool is selected, clicking an element selects
				  it.
				- If an element tool is selected, clicking gives the element
				  tool the opporunity (to start a) drawing operation.
			- Right clicks:
				- If an element is selected, a context menu is shown.

		arguments:
			e:
				type:	QMouseEvent
		"""

		# When control is not pressed, we deselect all currently selected
		# elements first
		if not QtCore.Qt.ControlModifier & e.modifiers():
			for element in self.sketchpad.elements:
				element.select(False)
		element = self.element_at(e.scenePos())
		if QtCore.Qt.RightButton & e.button() and element is not None:
			# The right buttons pops up a context menu.
			element.show_context_menu(e.screenPos())
		if QtCore.Qt.LeftButton & e.button():
			# The left button selects and drags.
			if self.selected_element_tool is not None:
				# When in pointer-tool mode, mouse clicks create new elements.
				self.sketchpad.add_element(
					self.selected_element_tool.mouse_press(self.sketchpad,
					self.cursor_pos(e)))
			elif element is None:
				self.sketchpad.select_pointer_tool()
			else:
				element.select()
				self.sketchpad.show_element_settings(element)
				x, y = self.cursor_pos(e, grid=False)
				self.start_move_pos = x, y
				data = {
					u'type'		: u'sketchpad-element-move',
					u'from_x'	: x,
					u'from_y'	: y
					}
				drag_and_drop.send(e.widget(), data)
Exemple #7
0
    def start_drag(self, e):
        """
		desc:
			Starts a variable drag operation.

		arguments:
			e:
				type:	QMousePressEvent
		"""

        item = self.ui.table_variables.itemAt(e.pos())
        if item is None:
            return
        row = self.ui.table_variables.row(item)
        var = self.ui.table_variables.item(row, 0).text()
        drag_and_drop.send(self.ui.table_variables, {
            u'type': u'variable',
            u'variable': var
        })
Exemple #8
0
    def mousePressEvent(self, e):
        """
		desc:
			Initiates a drag event after a mouse press.

		arguments:
			e:
				desc:	A mouse event.
				type:	QMouseEvent
		"""

        if e.buttons() != QtCore.Qt.LeftButton:
            return
        data = {
            u'type': u'item-new',
            u'item-type': self.item,
            u'item-name': self.item,
            u'script': u'',
        }
        drag_and_drop.send(self, data)
	def start_drag(self, e):

		"""
		desc:
			Starts a variable drag operation.

		arguments:
			e:
				type:	QMousePressEvent
		"""

		item = self.ui.table_variables.itemAt(e.pos())
		if item is None:
			return
		row = self.ui.table_variables.row(item)
		var = self.ui.table_variables.item(row, 0).text()
		drag_and_drop.send(self.ui.table_variables,
			{
			u'type' : u'variable',
			u'variable' : var}
			)
	def mousePressEvent(self, e):

		"""
		desc:
			Initiates a drag event after a mouse press.

		arguments:
			e:
				desc:	A mouse event.
				type:	QMouseEvent
		"""

		if e.buttons() != QtCore.Qt.LeftButton:
			return
		data = {
			u'type'			: u'item-new',
			u'item-type'	: self.item,
			u'item-name'	: self.item,
			u'script'		: u'',
			}
		drag_and_drop.send(self, data)