spinetoolbox.widgets.open_project_widget

Contains a class for a widget that represents a ‘Open Project Directory’ dialog.

author:
  1. Savolainen (VTT)
date:

1.11.2019

Module Contents

Classes

OpenProjectDialog A dialog that let’s user select a project to open either by choosing
CustomQFileSystemModel Custom file system model.
DirValidator
class spinetoolbox.widgets.open_project_widget.OpenProjectDialog(toolbox)[source]

Bases: PySide2.QtWidgets.QDialog

A dialog that let’s user select a project to open either by choosing an old .proj file or by choosing a project directory.

Parameters:toolbox (ToolboxUI) – QMainWindow instance
set_keyboard_shortcuts(self)[source]

Creates keyboard shortcuts for the ‘Root’, ‘Home’, etc. buttons.

connect_signals(self)[source]

Connects signals to slots.

expand_and_resize(self, p)[source]

Expands, resizes, and scrolls the tree view to the current directory when the file model has finished loading the path. Slot for the file model’s directoryLoaded signal. The directoryLoaded signal is emitted only if the directory has not been cached already.

Parameters:p (str) – Directory that has been loaded
combobox_key_press_event(self, e)[source]

Interrupts Enter and Return key presses when QComboBox is in focus. This is needed to prevent showing the ‘Not a valid Spine Toolbox project’ Notifier every time Enter is pressed.

Parameters:e (QKeyEvent) – Received key press event.
validator_state_changed(self)[source]

Changes the combobox border color according to the current state of the validator.

current_index_changed(self, i)[source]

Combobox selection changed. This slot is processed when a new item is selected from the drop-down list. This is not processed when new item txt is QValidotor.Intermediate.

Parameters:i (int) – Selected row in combobox
current_changed(self, current, previous)[source]

Processed when the current item in file system tree view has been changed with keyboard or mouse. Updates the text in combobox.

Parameters:
  • current (QModelIndex) – Currently selected index
  • previous (QModelIndex) – Previously selected index
set_selected_path(self, index)[source]

Sets the text in the combobox as the selected path in the file system tree view.

Parameters:index (QModelIndex) – The index which was mouse clicked.
combobox_text_edited(self, text)[source]

Updates selected path when combobox text is edited. Note: pressing enter in combobox does not trigger this.

selection(self)[source]

Returns the selected path from dialog.

go_root(self, checked=False)[source]

Slot for the ‘Root’ button. Scrolls the treeview to show and select the user’s root directory.

Note: We need to expand and scroll the tree view here after setCurrentIndex just in case the directory has been loaded already.

go_home(self, checked=False)[source]

Slot for the ‘Home’ button. Scrolls the treeview to show and select the user’s home directory.

go_documents(self, checked=False)[source]

Slot for the ‘Documents’ button. Scrolls the treeview to show and select the user’s documents directory.

go_desktop(self, checked=False)[source]

Slot for the ‘Desktop’ button. Scrolls the treeview to show and select the user’s desktop directory.

done(self, r)[source]

Checks that selected path exists and is a valid Spine Toolbox directory when ok button is clicked or when enter is pressed without the combobox being in focus.

Parameters:r (int) –
static update_recents(entry, qsettings)[source]

Adds a new entry to QSettings variable that remembers the five most recent project storages.

Parameters:
  • entry (str) – Abs. path to a directory that most likely contains other Spine Toolbox Projects as well. First entry is also used as the initial path for File->New Project dialog.
  • qsettings (QSettings) – Toolbox qsettings object
static remove_directory_from_recents(p, qsettings)[source]

Removes directory from the recent project storages.

Parameters:
  • p (str) – Full path to a project directory
  • qsettings (QSettings) – Toolbox qsettings object
show_context_menu(self, pos)[source]

Shows the context menu for the QCombobox with a ‘Clear history’ entry.

Parameters:pos (QPoint) – Mouse position
closeEvent(self, event=None)[source]

Handles dialog closing.

Parameters:event (QCloseEvent) – Close event
class spinetoolbox.widgets.open_project_widget.CustomQFileSystemModel[source]

Bases: PySide2.QtWidgets.QFileSystemModel

Custom file system model.

columnCount(self, parent=QModelIndex())[source]

Returns one.

class spinetoolbox.widgets.open_project_widget.DirValidator(parent=None)[source]

Bases: PySide2.QtGui.QValidator

validate(self, txt, pos)[source]

Returns Invalid if input is invalid according to this validator’s rules, Intermediate if it is likely that a little more editing will make the input acceptable and Acceptable if the input is valid.

Parameters:
  • txt (str) – Text to validate
  • pos (int) – Cursor position
Returns:

Invalid, Intermediate, or Acceptable

Return type:

QValidator.State