spinetoolbox.spine_db_editor.widgets.commit_viewer

Contains Database editor’s Commit viewer.

Module Contents

Classes

_DBCommitViewer

Commit viewer's central widget.

_CommitItem

A widget to show commit message, author and data on a QTreeWidget.

_AffectedItemsWidget

A composite widget that contains a table and a label.

CommitViewer

Commit viewer window.

Worker

Worker that fetches affected items.

class spinetoolbox.spine_db_editor.widgets.commit_viewer._DBCommitViewer(db_mngr, db_map, parent=None)[source]

Bases: PySide6.QtWidgets.QWidget

Commit viewer’s central widget.

Parameters
  • db_mngr (SpineDBManager) – database manager

  • db_map (DatabaseMapping) – database mapping

  • parent (QWidget, optional) – parent widget

property splitter: PySide6.QtWidgets.QSplitter[source]
_select_commit(current, previous)[source]

Start a worker thread that fetches affected items for the selected commit.

Parameters
  • current (QTreeWidgetItem) – currently selected commit item

  • previous (QTreeWidgetItem) – previously selected commit item

_launch_new_worker(commit_id)[source]

Starts a new worker thread.

If a thread is already running, it is quite before starting a new one.

Parameters

commit_id (TempId) – commit id

_process_affected_items(item_type, keys, items)[source]

Adds a fetched chunk of affected items to appropriate table view.

Parameters
  • item_type (str) – fethced item type

  • keys (Sequence of str) – item keys

  • items (Sequence of Sequence) – list of items, each item being a list of labels; items must have the same length as keys

_max_affected_items_fetched(item_type, still_available)[source]

Updates the fetch status label.

Parameters
  • item_type (str) – item type

  • still_available (int) – number of items left unfetched

_all_affected_items_fetched(item_type)[source]

Hides the fetch status label.

Parameters

item_type (str) – item type

_finish_work()[source]

Quits the worker thread if it is running.

tear_down()[source]

Tears down the widget.

_set_preferred_item_type(preferred_tab_index)[source]

Sets the preferred item type for affected items.

The tab showing the preferred type is selected automatically as the current tab when/if it gets fetched.

Parameters

preferred_tab_index (int) – index of the preferred tab

class spinetoolbox.spine_db_editor.widgets.commit_viewer._CommitItem(commit, parent=None)[source]

Bases: PySide6.QtWidgets.QWidget

A widget to show commit message, author and data on a QTreeWidget.

Parameters
  • commit (dict) – commit database item

  • parent (QWidget, optional) – parent widget

class spinetoolbox.spine_db_editor.widgets.commit_viewer._AffectedItemsWidget[source]

Bases: PySide6.QtWidgets.QWidget

A composite widget that contains a table and a label.

property table: PySide6.QtWidgets.QTableWidget[source]
property label: PySide6.QtWidgets.QLabel[source]
class spinetoolbox.spine_db_editor.widgets.commit_viewer.CommitViewer(qsettings, db_mngr, *db_maps, parent=None)[source]

Bases: PySide6.QtWidgets.QMainWindow

Commit viewer window.

Parameters
  • qsettings (QSettings) – application settings

  • db_mngr (SpineDBManager) – database manager

  • *db_maps – database mappings to view

  • parent (QWidget, optional) – parent widget

_carry_splitter_state(index)[source]

Ensures that splitters have the same state in all tabs.

Parameters

index (int) – current database tab index

closeEvent(ev)[source]
class spinetoolbox.spine_db_editor.widgets.commit_viewer.Worker(db_mngr, db_map, commit_id)[source]

Bases: PySide6.QtCore.QObject

Worker that fetches affected items.

The items are fetched in chunks which makes it possible to quit the thread mid-execution. There is also a hard limit to how many items are fetched.

Parameters
  • db_mngr (SpineDBManager) – database manager

  • db_map (DatabaseMapping) – database mapping

  • commit_id (TempId) – commit id

SOFT_MAX_IDS = 400[source]
HARD_EXTRA_ID_LIMIT = 100[source]
CHUNK_SIZE = 50[source]
max_ids_reached[source]
all_ids_fetched[source]
chunk_ready[source]
finished[source]
run()[source]

Fetches affected items.

static _parse_value(db_mngr, db_map, item, key)[source]

Converts item field values to something more displayable.

Parameters
  • db_mngr (SpineDBManager) – database manager

  • db_map (DatabaseMapping) – database mapping

  • item (PublicItem) – database item

  • key (str) – value’s key

Returns

displayable presentation of the value

Return type

str