spinetoolbox.spine_db_editor.mvcmodels.tree_item_utility

A tree model for parameter_value lists.

authors
  1. Marin (KTH)

date

28.6.2019

Module Contents

Classes

NonLazyTreeItem

A tree item that fetches their children as they are inserted.

EditableMixin

LastGrayMixin

Paints the last item gray.

AllBoldMixin

Bolds text.

EmptyChildMixin

Guarantess there’s always an empty child.

NonLazyDBItem

An item representing a db.

RootItem

A root item.

EmptyChildRootItem

Guarantess there’s always an empty child.

LeafItem

A tree item that fetches their children as they are inserted.

class spinetoolbox.spine_db_editor.mvcmodels.tree_item_utility.NonLazyTreeItem(model=None)[source]

Bases: spinetoolbox.mvcmodels.minimal_tree_model.TreeItem

A tree item that fetches their children as they are inserted.

Initializes item.

Parameters

model (MinimalTreeModel, NoneType) – The model where the item belongs.

property item_type(self)[source]
property db_mngr(self)[source]
property display_data(self)[source]
property icon_code(self)[source]
property tool_tip(self)[source]
property display_icon(self)[source]
data(self, column, role=Qt.DisplayRole)[source]

Returns data for given column and role.

set_data(self, column, value, role=Qt.DisplayRole)[source]

Sets data for this item.

Parameters
  • column (int) – column index

  • value (object) – a new value

  • role (int) – role of the new value

Returns

True if data was set successfully, False otherwise

Return type

bool

can_fetch_more(self)[source]

Disables lazy loading by returning False.

insert_children(self, position, *children)[source]

Fetches the children as they become parented.

class spinetoolbox.spine_db_editor.mvcmodels.tree_item_utility.EditableMixin[source]
flags(self, column)[source]

Makes items editable.

class spinetoolbox.spine_db_editor.mvcmodels.tree_item_utility.LastGrayMixin[source]

Paints the last item gray.

data(self, column, role=Qt.DisplayRole)[source]
class spinetoolbox.spine_db_editor.mvcmodels.tree_item_utility.AllBoldMixin[source]

Bolds text.

data(self, column, role=Qt.DisplayRole)[source]
class spinetoolbox.spine_db_editor.mvcmodels.tree_item_utility.EmptyChildMixin[source]

Guarantess there’s always an empty child.

abstract empty_child(self)[source]
fetch_more(self)[source]
append_empty_child(self, row)[source]

Appends empty child if the row is the last one.

class spinetoolbox.spine_db_editor.mvcmodels.tree_item_utility.NonLazyDBItem(db_map)[source]

Bases: NonLazyTreeItem

An item representing a db.

Init class.

Args

db_mngr (SpineDBManager) db_map (DiffDatabaseMapping)

property item_type(self)[source]
data(self, column, role=Qt.DisplayRole)[source]

Shows Spine icon for fun.

class spinetoolbox.spine_db_editor.mvcmodels.tree_item_utility.RootItem(model=None)[source]

Bases: AllBoldMixin, NonLazyTreeItem

A root item.

Initializes item.

Parameters

model (MinimalTreeModel, NoneType) – The model where the item belongs.

property item_type(self)[source]
property db_map(self)[source]
class spinetoolbox.spine_db_editor.mvcmodels.tree_item_utility.EmptyChildRootItem(model=None)[source]

Bases: EmptyChildMixin, RootItem

Guarantess there’s always an empty child.

Initializes item.

Parameters

model (MinimalTreeModel, NoneType) – The model where the item belongs.

abstract empty_child(self)[source]
class spinetoolbox.spine_db_editor.mvcmodels.tree_item_utility.LeafItem(identifier=None)[source]

Bases: NonLazyTreeItem

A tree item that fetches their children as they are inserted.

Initializes item.

Parameters

model (MinimalTreeModel, NoneType) – The model where the item belongs.

_make_item_data(self)[source]
property item_type(self)[source]
property db_map(self)[source]
property id(self)[source]
property item_data(self)[source]
property name(self)[source]
abstract add_item_to_db(self, db_item)[source]
abstract update_item_in_db(self, db_item)[source]
header_data(self, column)[source]
data(self, column, role=Qt.DisplayRole)[source]

Returns data for given column and role.

set_data(self, column, value, role=Qt.EditRole)[source]

Sets data for this item.

Parameters
  • column (int) – column index

  • value (object) – a new value

  • role (int) – role of the new value

Returns

True if data was set successfully, False otherwise

Return type

bool

_make_item_to_add(self, value)[source]
_make_item_to_update(self, column, value)[source]
handle_updated_in_db(self)[source]