spinetoolbox.widgets.custom_qgraphicsscene

Custom QGraphicsScene used in the Design View.

author:
  1. Savolainen (VTT)
date:

13.2.2019

Module Contents

Classes

CustomGraphicsScene A custom QGraphicsScene. It provides signals to notify about items,
DesignGraphicsScene A scene for the Design view.
class spinetoolbox.widgets.custom_qgraphicsscene.CustomGraphicsScene[source]

Bases: PySide2.QtWidgets.QGraphicsScene

A custom QGraphicsScene. It provides signals to notify about items, and a method to center all items in the scene.

At the moment it’s used by DesignGraphicsScene and the GraphViewMixin

item_move_finished[source]

Emitted when an item has finished moving.

item_removed[source]

Emitted when an item has been removed.

center_items(self)[source]

Centers toplevel items in the scene.

class spinetoolbox.widgets.custom_qgraphicsscene.DesignGraphicsScene(parent, toolbox)[source]

Bases: spinetoolbox.widgets.custom_qgraphicsscene.CustomGraphicsScene

A scene for the Design view.

Mainly, it handles drag and drop events of ProjectItemFactoryModel or ProjectItemSpecFactoryModel sources.

Parameters:
  • parent (QObject) – scene’s parent object
  • toolbox (ToolboxUI) – reference to the main window
mouseMoveEvent(self, event)[source]

Moves link drawer.

mousePressEvent(self, event)[source]

Puts link drawer to sleep and log message if it looks like the user doesn’t know what they’re doing.

mouseReleaseEvent(self, event)[source]

Makes link if drawer is released over a valid connector button.

emit_connection_failed(self)[source]
keyPressEvent(self, event)[source]

Puts link drawer to sleep if user presses ESC.

connect_signals(self)[source]

Connect scene signals.

handle_selection_changed(self)[source]

Synchronize selection with the project tree.

set_bg_color(self, color)[source]

Change background color when this is changed in Settings.

Parameters:color (QColor) – Background color
set_bg_choice(self, bg_choice)[source]

Set background choice when this is changed in Settings.

Parameters:bg (str) – “grid”, “tree”, or “solid”
static _is_project_item_drag(source)[source]

Checks whether or not source corresponds to a project item being dragged into the scene.

dragLeaveEvent(self, event)[source]

Accept event.

dragEnterEvent(self, event)[source]

Accept event. Then call the super class method only if drag source is not a ProjectItemFactoryModel or ProjectItemSpecFactoryModel.

dragMoveEvent(self, event)[source]

Accept event. Then call the super class method only if drag source is not a ProjectItemFactoryModel or ProjectItemSpecFactoryModel.

dropEvent(self, event)[source]

Only accept drops when the source is an instance of ProjectItemFactoryModel or ProjectItemSpecFactoryModel. Capture text from event’s mimedata and show the appropriate ‘Add Item form.’

event(self, event)[source]

Accepts GraphicsSceneHelp events without doing anything, to not interfere with our usage of QToolTip.showText in graphics_items.ExclamationIcon.

drawBackground(self, painter, rect)[source]

Reimplemented method to make a custom background.

Parameters:
  • painter (QPainter) – Painter that is used to paint background
  • rect (QRectF) – The exposed (viewport) rectangle in scene coordinates
_draw_solid_bg(self, painter, rect)[source]

Draws solid bg.

_draw_grid_bg(self, painter, rect)[source]

Draws grid bg.

_draw_tree_bg(self, painter, rect)[source]

Draws ‘tree of life’ bg.