spinetoolbox.widgets.open_project_widget
¶
Contains a class for a widget that represents a ‘Open Project Directory’ dialog.
- author
Savolainen (VTT)
- date
1.11.2019
Module Contents¶
Classes¶
A dialog that let’s user select a project to open either by choosing |
|
Custom file system model. |
|
- 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.
- 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. Note, that this is only used when the open project dialog is opened
- Parameters
p (str) – Directory that has been loaded
- 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.
- 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.
- open_project(self, index)[source]¶
Opens project if index contains a valid Spine Toolbox project. Slot for the mouse doubleClicked signal. Prevents showing the ‘Not a valid spine toolbox project’ notification if user just wants to collapse a directory.
- Parameters
index (QModelIndex) – File model index which was double clicked
- 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
Shows the context menu for the QCombobox with a ‘Clear history’ entry.
- Parameters
pos (QPoint) – Mouse position
- class spinetoolbox.widgets.open_project_widget.CustomQFileSystemModel[source]¶
Bases:
PySide2.QtWidgets.QFileSystemModel
Custom file system model.
- 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