spinetoolbox.widgets.custom_qgraphicsscene

Custom QGraphicsScene used in the Design View.

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: PySide6.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.

center_items()[source]

Centers toplevel items in the scene.

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

Bases: CustomGraphicsScene

A scene for the Design view.

Mainly, it handles drag and drop events of ProjectItemDragMixin sources.

Parameters
  • parent (QObject) – scene’s parent object

  • toolbox (ToolboxUI) – reference to the main window

mouseMoveEvent(event)[source]

Moves link drawer.

mousePressEvent(event)[source]

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

mouseReleaseEvent(event)[source]

Makes link if drawer is released over a valid connector button or cancel link drawing on right button.

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

Puts link drawer to sleep if user presses ESC.

connect_signals()[source]

Connect scene signals.

project_item_icons()[source]
handle_selection_changed()[source]

Activates items or links based on currently selected items (or links).

set_bg_color(color)[source]

Change background color when this is changed in Settings.

Parameters

color (QColor) – Background color

set_bg_choice(bg_choice)[source]

Set background choice when this is changed in Settings.

Parameters

bg (str) – “grid”, “tree”, or “solid”

dragLeaveEvent(event)[source]

Accepts event.

dragEnterEvent(event)[source]

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

dragMoveEvent(event)[source]

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

dropEvent(event)[source]

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

event(event)[source]

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

drawBackground(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(painter, rect)[source]

Draws solid bg.

_draw_grid_bg(painter, rect)[source]

Draws grid bg.

_draw_tree_bg(painter, rect)[source]

Draws ‘tree of life’ bg.

Selects current link drawer.

Parameters

drawer_type (LinkType) – selected link drawer’s type