spinetoolbox.widgets.custom_qgraphicsviews
¶
Classes for custom QGraphicsViews for the Design and Graph views.
authors: |
|
---|---|
date: | 6.2.2018 |
Module Contents¶
-
class
spinetoolbox.widgets.custom_qgraphicsviews.
CustomQGraphicsView
(parent)[source]¶ Bases:
PySide2.QtWidgets.QGraphicsView
Super class for Design and Graph QGraphicsViews.
-
parent
¶ Parent widget
Type: QWidget
Init CustomQGraphicsView.
-
keyPressEvent
(self, event)[source]¶ Overridden method. Enable zooming with plus and minus keys (comma resets zoom). Send event downstream to QGraphicsItems if pressed key is not handled here.
Parameters: event (QKeyEvent) – Pressed key
-
enterEvent
(self, event)[source]¶ Overridden method. Do not show the stupid open hand mouse cursor.
Parameters: event (QEvent) – event
-
mousePressEvent
(self, event)[source]¶ Set rubber band selection mode if Control pressed. Enable resetting the zoom factor from the middle mouse button.
-
resizeEvent
(self, event)[source]¶ Updates zoom if needed when the view is resized.
Parameters: event (QResizeEvent) – a resize event
-
setScene
(self, scene)[source]¶ Sets a new scene to this view.
Parameters: scene (ShrinkingScene) – a new scene
-
_update_zoom_limits
(self, rect)[source]¶ Updates the minimum zoom limit and the zoom level with which the entire scene fits the view.
Parameters: rect (QRectF) – the scene’s rect
-
-
class
spinetoolbox.widgets.custom_qgraphicsviews.
DesignQGraphicsView
(parent)[source]¶ Bases:
spinetoolbox.widgets.custom_qgraphicsviews.CustomQGraphicsView
QGraphicsView for the Design View.
Parameters: parent (QWidget) – Graph View Form’s (QMainWindow) central widget (self.centralwidget) -
mousePressEvent
(self, event)[source]¶ Manage drawing of links. Handle the case where a link is being drawn and the user doesn’t hit a connector button.
Parameters: event (QGraphicsSceneMouseEvent) – Mouse event
-
mouseMoveEvent
(self, event)[source]¶ Update line end position.
Parameters: event (QGraphicsSceneMouseEvent) – Mouse event
-
init_scene
(self, empty=False)[source]¶ Resize scene and add a link drawer on scene. The scene must be cleared before calling this.
Parameters: empty (boolean) – True when creating a new project
-
add_link
(self, src_connector, dst_connector)[source]¶ Pushes an AddLinkCommand to the toolbox undo stack.
-
make_link
(self, src_connector, dst_connector)[source]¶ Returns a Link between given connectors.
Parameters: - src_connector (ConnectorButton) – Source connector button
- dst_connector (ConnectorButton) – Destination connector button
Returns: Link
-
do_add_link
(self, src_connector, dst_connector)[source]¶ Makes a Link between given source and destination connectors and adds it to the project.
Parameters: - src_connector (ConnectorButton) – Source connector button
- dst_connector (ConnectorButton) – Destination connector button
-
_add_link
(self, link)[source]¶ Adds given Link to the project.
Parameters: link (Link) – the link to add
-
static
_remove_redundant_link
(link)[source]¶ Checks if there’s a link with the same source and destination as the given one, wipes it out and returns it.
Parameters: link (Link) – a new link being added to the project. - Returns
- Link, NoneType
-
take_link
(self, link)[source]¶ Remove link, then start drawing another one from the same source connector.
-
restore_links
(self, connections)[source]¶ Creates Links from the given connections list.
- List of dicts is accepted, e.g.
Parameters: connections (list) – List of connections.
-
draw_links
(self, connector)[source]¶ Draw links when slot button is clicked.
Parameters: connector (ConnectorButton) – Connector button that triggered the drawing
-
notify_destination_items
(self)[source]¶ Notify destination items that they have been connected to a source item.
-
connect_engine_signals
(self, engine)[source]¶ Connects signals needed for icon animations from given engine.
-
-
class
spinetoolbox.widgets.custom_qgraphicsviews.
GraphQGraphicsView
[source]¶ Bases:
spinetoolbox.widgets.custom_qgraphicsviews.CustomQGraphicsView
QGraphicsView for the Graph View.
-
dragLeaveEvent
(self, event)[source]¶ Accept event. Then call the super class method only if drag source is not DragListView.
-
dragEnterEvent
(self, event)[source]¶ Accept event. Then call the super class method only if drag source is not DragListView.
-
dragMoveEvent
(self, event)[source]¶ Accept event. Then call the super class method only if drag source is not DragListView.
-
dropEvent
(self, event)[source]¶ Only accept drops when the source is an instance of DragListView. Capture text from event’s mimedata and emit signal.
-
contextMenuEvent
(self, e)[source]¶ Show context menu.
Parameters: e (QContextMenuEvent) – Context menu event
-