spinetoolbox.spine_io.io_models
¶
Classes for handling models in PySide2’s model/view framework.
author: |
|
---|---|
date: | 1.6.2019 |
Module Contents¶
-
class
spinetoolbox.spine_io.io_models.
MappingPreviewModel
(parent=None)[source]¶ Bases:
spinetoolbox.mvcmodels.minimal_table_model.MinimalTableModel
A model for highlighting columns, rows, and so on, depending on Mapping specification. Used by ImportPreviewWidget.
-
set_mapping
(self, mapping)[source]¶ Set mapping to display colors from
Parameters: {MappingSpecModel} -- mapping model (mapping) –
-
data_color
(self, index)[source]¶ returns background color for index depending on mapping
Parameters: {PySide2.QtCore.QModelIndex} -- index (index) – Returns: [QColor] – QColor of index
-
-
class
spinetoolbox.spine_io.io_models.
MappingSpecModel
(model, parent=None)[source]¶ Bases:
PySide2.QtCore.QAbstractTableModel
A model to hold a Mapping specification.
-
class
spinetoolbox.spine_io.io_models.
MappingListModel
(mapping_list, parent=None)[source]¶ Bases:
PySide2.QtCore.QAbstractListModel
A model to hold a list of Mappings.
Returns a menu which contains actions for each allowed data type.
Parameters: - parent (QWidget) – a parent widget
- trigger_slot (Slot) – a slot which is connected to QMenu’s ‘triggered’ signal
Returns: a menu
Return type: QMenu
-
class
spinetoolbox.spine_io.io_models.
HeaderWithButton
(orientation, parent=None)[source]¶ Bases:
PySide2.QtWidgets.QHeaderView
Class that reimplements the QHeaderView section paint event to draw a button that is used to display and change the type of that column or row.
Sets the data type of a row or column according to menu action.
-
set_data_types
(self, sections, type_str, update_viewport=True)[source]¶ Sets the data types of given sections (rows, columns).
Parameters: - sections (Iterable or int or NoneType) – row/column index
- type_str (str) – data type name
- update_viewport (bool) – True if the buttons need repaint
-
mouseMoveEvent
(self, mouse_event)[source]¶ Moves the button to the correct section so that interacting with the button works.
-
mousePressEvent
(self, mouse_event)[source]¶ Move the button to the pressed location and show or hide it if button should not be shown.
Sets a buttons geometry depending on the index.
Parameters: - {QWidget} -- QWidget that geometry should be set (button) –
- {int} -- logical_index to set position and geometry to. (index) –
-
_section_resize
(self, i)[source]¶ When a section is resized.
Parameters: {int} -- logical index to section being resized (i) –
-
paintSection
(self, painter, rect, logical_index)[source]¶ Paints a section of the QHeader view.
Works by drawing a pixmap of the button to the left of the original paint rectangle. Then shifts the original rect to the right so these two doesn’t paint over each other.
-
sectionSizeFromContents
(self, logical_index)[source]¶ Add the button width to the section so it displays right.
Parameters: {int} -- logical index of section (logical_index) – Returns: [QSize] – Size of section
-
class
spinetoolbox.spine_io.io_models.
TableViewWithButtonHeader
(parent=None)[source]¶ Bases:
PySide2.QtWidgets.QTableView
Customized table with data type buttons on horizontal and vertical headers
Parameters: parent (QWidget) – a parent widget Returns a new menu for the horizontal header
Returns a new menu for the vertical header.
Opens the context menu of the horizontal header.
Opens the context menu of the vertical header.