widgets.custom_editors

Custom editors for model/view programming.

author:
  1. Marin (KTH)
date:

2.9.2018

Module Contents

class widgets.custom_editors.CustomLineEditor[source]

Bases: PySide2.QtWidgets.QLineEdit

A custom QLineEdit to handle data from models.

parent

the widget that wants to edit the data

Type:QWidget
set_data(self, data)[source]
data(self)[source]
keyPressEvent(self, event)[source]

Don’t allow shift key to clear the contents.

class widgets.custom_editors.CustomComboEditor[source]

Bases: PySide2.QtWidgets.QComboBox

A custom QComboBox to handle data from models.

parent

the widget that wants to edit the data

Type:QWidget
data_committed[source]
set_data(self, current_text, items)[source]
data(self)[source]
class widgets.custom_editors.CustomLineEditDelegate(parent)[source]

Bases: PySide2.QtWidgets.QItemDelegate

A delegate for placing a CustomLineEditor on the first row of SearchBarEditor.

parent

search bar editor

Type:SearchBarEditor
text_edited[source]
setModelData(self, editor, model, index)[source]
createEditor(self, parent, option, index)[source]

Create editor and ‘forward’ textEdited signal.

eventFilter(self, editor, event)[source]

Handle all sort of special cases.

class widgets.custom_editors.SearchBarEditor(parent, elder_sibling=None, is_json=False)[source]

Bases: PySide2.QtWidgets.QTableView

A Google-like search bar, implemented as a QTableView with a CustomLineEditDelegate in the first row.

parent

the parent for this widget

Type:QWidget
elder_sibling

another widget which is used to find this widget’s position.

Type:QWidget or NoneType
data_committed[source]
set_data(self, current, all_data)[source]

Populate model and initialize first index.

set_base_size(self, size)[source]
update_geometry(self)[source]

Update geometry. Resize the widget to optimal size, then adjust its position.

refit(self)[source]

Resize to optimal size.

data(self)[source]
_handle_delegate_text_edited(self, text)[source]

Filter model as the first row is being edited.

_proxy_model_filter_accepts_row(self, source_row, source_parent)[source]

Overridden method to always accept first row.

keyPressEvent(self, event)[source]

Set data from current index into first index as the user navigates through the table using the up and down keys.

currentChanged(self, current, previous)[source]
edit_first_index(self)[source]

Edit first index if valid and not already being edited.

mouseMoveEvent(self, event)[source]

Make hovered index the current index.

mousePressEvent(self, event)[source]

Commit data.

class widgets.custom_editors.SearchBarDelegate(parent)[source]

Bases: PySide2.QtWidgets.QItemDelegate

A custom delegate to place a SearchBarEditor on each cell of a MultiSearchBarEditor.

parent

multi search bar editor

Type:MultiSearchBarEditor
data_committed[source]
setModelData(self, editor, model, index)[source]
createEditor(self, parent, option, index)[source]
updateEditorGeometry(self, editor, option, index)[source]
close_editor(self, editor, index, model)[source]
eventFilter(self, editor, event)[source]
class widgets.custom_editors.MultiSearchBarEditor(parent, elder_sibling=None)[source]

Bases: PySide2.QtWidgets.QTableView

A table view made of several Google-like search bars.

set_data(self, header, currents, alls)[source]
data(self)[source]
set_base_size(self, size)[source]
update_geometry(self)[source]

Update geometry.

start_editing(self)[source]

Start editing first item.

class widgets.custom_editors.CheckListEditor(parent, elder_sibling=None)[source]

Bases: PySide2.QtWidgets.QTableView

A check list editor.

keyPressEvent(self, event)[source]

Toggle checked state.

toggle_checked_state(self, index)[source]
mouseMoveEvent(self, event)[source]

Highlight current row.

mousePressEvent(self, event)[source]

Toggle checked state.

set_data(self, item_names, current_item_names)[source]

Set data and update geometry.

data(self)[source]
set_base_size(self, size)[source]
update_geometry(self)[source]

Update geometry.

class widgets.custom_editors.JSONEditor(parent, elder_sibling, popup=False)[source]

Bases: PySide2.QtWidgets.QTabWidget

A double JSON editor, featuring: - A QTextEdit for editing arbitrary json. - A QTableView for editing json array.

data_committed[source]
_view_key_press_event(self, event)[source]

Accept key events on the view to avoid weird behaviour, when trying to navigate outside of its limits.

eventFilter(self, widget, event)[source]

Intercept events to text_edit and table_view to enable consistent behavior.

check_focus(self)[source]

Called when either the text edit or the table view lose focus. Check if the focus is still on this widget (which would mean it was a tab change) otherwise emit signal so this is closed.

_handle_current_changed(self, index)[source]

Update json data on text edit or table view, and set focus.

set_data(self, data, current_index)[source]

Set data on text edit or table view (model) depending on current index.

start_editing(self)[source]

Start editing.

set_base_size(self, size)[source]
update_geometry(self)[source]

Update geometry.

data(self)[source]
class widgets.custom_editors.IconPainterDelegate[source]

Bases: PySide2.QtWidgets.QItemDelegate

A delegate to highlight decorations in a QListWidget.

paint(self, painter, option, index)[source]

Highlight selected items.

class widgets.custom_editors.IconColorEditor(parent)[source]

Bases: PySide2.QtWidgets.QDialog

An editor to let the user select an icon and a color for an object class.

_proxy_model_filter_accepts_row(self, source_row, source_parent)[source]

Overridden method to filter icons according to search terms.

connect_signals(self)[source]

Connect signals to slots.

set_data(self, data)[source]
data(self)[source]
class widgets.custom_editors.NumberParameterInlineEditor(parent)[source]

Bases: PySide2.QtWidgets.QDoubleSpinBox

An editor widget for numeric (datatype double) parameter values.

set_data(self, data)[source]
data(self)[source]