spinetoolbox.spine_db_editor.widgets.spine_db_editor

Contains the SpineDBEditor class.

Module Contents

Classes

SpineDBEditorBase

Base class for SpineDBEditor (i.e. Spine database editor).

SpineDBEditor

A widget to visualize Spine dbs.

class spinetoolbox.spine_db_editor.widgets.spine_db_editor.SpineDBEditorBase(db_mngr)[source]

Bases: PySide6.QtWidgets.QMainWindow

Base class for SpineDBEditor (i.e. Spine database editor).

Parameters

db_mngr (SpineDBManager) – The manager to use

property toolbox[source]
property settings_subgroup[source]
property db_names[source]
property first_db_map[source]
property db_url_codenames[source]
msg[source]
msg_error[source]
file_exported[source]

filepath, progress between 0 and 1, True if sqlite file

static is_db_map_editor()[source]

Always returns True as SpineDBEditors are truly database editors.

Unless, of course, the database can one day be opened in read-only mode. In that case this method should return False.

Returns

Always True

Return type

bool

load_db_urls(db_url_codenames, create=False, update_history=True, window=False)[source]
init_add_undo_redo_actions()[source]
load_previous_urls(_=False)[source]
load_next_urls(_=False)[source]
open_db_file(_=False)[source]
add_db_file(_=False)[source]
create_db_file(_=False)[source]
reset_docs()[source]

Resets the layout of the dock widgets for this URL

_make_docks_menu()[source]

Returns a menu with all dock toggle/view actions. Called by self.add_main_menu().

Returns

QMenu

add_main_menu()[source]

Adds a menu with main actions to toolbar.

_browse_commits()[source]
connect_signals()[source]

Connects signals to slots.

vacuum(_checked=False)[source]
update_undo_redo_actions(_)[source]
_replace_undo_redo_actions(new_undo_action, new_redo_action)[source]
_refresh_undo_redo_actions()[source]
update_commit_enabled(_clean=False)[source]
init_models()[source]

Initializes models.

add_message(msg)[source]

Pushes message to notification stack.

Parameters

msg (str) – String to show in the notification

refresh_copy_paste_actions()[source]

Runs when menus are about to show. Enables or disables actions according to selection status.

copy(checked=False)[source]

Copies data to clipboard.

paste(checked=False)[source]

Pastes data from clipboard.

import_data(data)[source]

Imports data to all database mappings open in the editor.

Parameters

data (dict) – data to import

import_file(checked=False)[source]

Imports file.

It supports SQLite, JSON, and Excel.

import_from_json(file_path)[source]
import_from_sqlite(file_path)[source]
import_from_excel(file_path)[source]
show_mass_export_items_dialog(checked=False)[source]

Shows dialog for user to select dbs and items for export.

_store_export_settings(state)[source]

Stores export items dialog settings.

_clean_up_export_items_dialog()[source]

Cleans up export items dialog.

export_session(checked=False)[source]

Exports changes made in the current session.

mass_export_items(db_map_item_types)[source]
duplicate_entity(entity_item)[source]

Duplicates an entity.

Parameters

entity_item (EntityItem) –

duplicate_scenario(db_map, scen_id)[source]

Duplicates a scenario.

Parameters
  • db_map (DiffDatabaseMapping) –

  • scen_id (int) –

export_data(db_map_ids_for_export)[source]

Exports data from given dictionary into a file.

Parameters

db_map_ids_for_export – Dictionary mapping db maps to keyword arguments for spinedb_api.export_data

refresh_session(checked=False)[source]
commit_session(checked=False)[source]

Commits dirty database maps.

rollback_session(checked=False)[source]

Rolls back dirty database maps.

receive_session_committed(db_maps, cookie)[source]
receive_session_rolled_back(db_maps)[source]
receive_session_refreshed(db_maps)[source]
show_mass_remove_items_form(checked=False)[source]

Opens the purge items dialog.

_store_purge_settings(state)[source]

Stores Purge items dialog state.

Parameters

state (dict) – dialog state

_clean_up_purge_items_dialog()[source]

Removes references to purge items dialog.

show_parameter_value_editor(index, plain=False)[source]

Shows the parameter_value editor for the given index of given table view.

receive_error_msg(db_map_error_log)[source]
_update_export_enabled()[source]

Updates export enabled.

_log_items_change(msg)[source]

Enables or disables actions and informs the user about what just happened.

_handle_items_added(item_type, db_map_data)[source]
_handle_items_updated(item_type, db_map_data)[source]
_handle_items_removed(item_type, db_map_data)[source]
restore_ui(view_type, fresh=False)[source]

Restores UI state from previous session.

Parameters
  • view_type (str) – What the selected view type is.

  • fresh (bool) – If true, the view specified with subgroup will be applied, instead of loading the previous window state of the said view.

save_window_state()[source]

Saves window state parameters (size, position, state) via QSettings.

tear_down()[source]

Performs clean up duties.

Returns

True if editor is ready to close, False otherwise

Return type

bool

_prompt_to_commit_changes()[source]

Prompts the user to commit or rollback changes to ‘dirty’ db maps.

Returns

QMessageBox status code

Return type

int

_get_commit_msg(db_names)[source]

Prompts user for commit message.

Parameters

db_names (Iterable of str) – database names

Returns

commit message

Return type

str

_get_rollback_confirmation(db_names)[source]

Prompts user for confirmation before rolling back the session.

Parameters

db_names (Iterable of str) – database names

Returns

True if user confirmed, False otherwise

Return type

bool

_purge_change_notifiers()[source]

Tears down change notifiers.

closeEvent(event)[source]

Handle close window.

Parameters

event (QCloseEvent) – Closing event

static _get_base_dir()[source]
class spinetoolbox.spine_db_editor.widgets.spine_db_editor.SpineDBEditor(db_mngr, db_url_codenames=None)[source]

Bases: spinetoolbox.spine_db_editor.widgets.tabular_view_mixin.TabularViewMixin, spinetoolbox.spine_db_editor.widgets.graph_view_mixin.GraphViewMixin, spinetoolbox.spine_db_editor.widgets.stacked_view_mixin.StackedViewMixin, spinetoolbox.spine_db_editor.widgets.tree_view_mixin.TreeViewMixin, SpineDBEditorBase

A widget to visualize Spine dbs.

Initializes everything.

Parameters

db_mngr (SpineDBManager) – The manager to use

pinned_values_updated[source]
emit_pinned_values_updated()[source]
connect_signals()[source]

Connects signals to slots.

init_models()[source]

Initializes models.

_restart_timer_refresh_tab_order(_visible=False)[source]
_refresh_tab_order()[source]
tabify_and_raise(docks)[source]

Tabifies docks in given list, then raises the first.

Parameters

docks (list) –

restore_dock_widgets()[source]

Docks all floating and or hidden QDockWidgets back to the window.

update_last_view()[source]
begin_style_change()[source]

Begins a style change operation.

end_style_change()[source]

Ends a style change operation.

apply_stacked_style(_checked=None)[source]

Applies the stacked style, inspired in the former tree view.

_finish_stacked_style()[source]
apply_pivot_style(_checked=None)[source]

Applies the pivot style, inspired in the former tabular view.

apply_graph_style(_checked=None)[source]

Applies the graph style, inspired in the former graph view.

static _get_base_dir()[source]