AbstractItemModel

class omni.ui.AbstractItemModel

Bases: pybind11_object

The central component of the item widget. It is the application’s dynamic data structure, independent of the user interface, and it directly manages the nested data. It follows closely model-view pattern. It’s abstract, and it defines the standard interface to be able to interoperate with the components of the model-view architecture. It is not supposed to be instantiated directly. Instead, the user should subclass it to create a new model. The item model doesn’t return the data itself. Instead, it returns the value model that can contain any data type and supports callbacks. Thus the client of the model can track the changes in both the item model and any value it holds. From any item, the item model can get both the value model and the nested items. Therefore, the model is flexible to represent anything from color to complicated tree-table construction.

Methods

__init__(self)

Constructs AbstractItemModel.

add_begin_edit_fn(self, arg0)

Adds the function that will be called every time the user starts the editing.

add_end_edit_fn(self, arg0)

Adds the function that will be called every time the user finishes the editing.

add_item_changed_fn(self, arg0)

Adds the function that will be called every time the value changes.

append_child_item(self, parentItem, model)

Creates a new item from the value model and appends it to the list of the children of the given item.

begin_edit(self, item)

Called when the user starts the editing.

can_item_have_children(self[, parentItem])

Returns true if the item can have children.

drop(*args, **kwargs)

Overloaded function.

drop_accepted(*args, **kwargs)

Overloaded function.

end_edit(self, item)

Called when the user finishes the editing.

get_drag_mime_data(self[, item])

Returns Multipurpose Internet Mail Extensions (MIME) for drag and drop.

get_item_children(self[, parentItem])

Returns the vector of items that are nested to the given parent item.

get_item_value_model(self[, item, column_id])

Get the value model associated with this item.

get_item_value_model_count(self[, item])

Returns the number of columns this model item contains.

remove_begin_edit_fn(self, arg0)

Remove the callback by its id.

remove_end_edit_fn(self, arg0)

Remove the callback by its id.

remove_item(self, item)

Removes the item from the model.

remove_item_changed_fn(self, arg0)

Remove the callback by its id.

subscribe_begin_edit_fn(self, arg0)

Adds the function that will be called every time the user starts the editing.

subscribe_end_edit_fn(self, arg0)

Adds the function that will be called every time the user finishes the editing.

subscribe_item_changed_fn(self, arg0)

Adds the function that will be called every time the value changes.

__init__(self: omni.ui._ui.AbstractItemModel) None

Constructs AbstractItemModel.

`kwargsdict`

See below

### Keyword Arguments:

add_begin_edit_fn(self: omni.ui._ui.AbstractItemModel, arg0: Callable[[omni.ui._ui.AbstractItemModel, omni.ui._ui.AbstractItem], None]) int

Adds the function that will be called every time the user starts the editing. The id of the callback that is used to remove the callback.

add_end_edit_fn(self: omni.ui._ui.AbstractItemModel, arg0: Callable[[omni.ui._ui.AbstractItemModel, omni.ui._ui.AbstractItem], None]) int

Adds the function that will be called every time the user finishes the editing. The id of the callback that is used to remove the callback.

add_item_changed_fn(self: omni.ui._ui.AbstractItemModel, arg0: Callable[[omni.ui._ui.AbstractItemModel, omni.ui._ui.AbstractItem], None]) int

Adds the function that will be called every time the value changes. The id of the callback that is used to remove the callback.

append_child_item(self: omni.ui._ui.AbstractItemModel, parentItem: omni.ui._ui.AbstractItem, model: omni.ui._ui.AbstractValueModel) omni.ui._ui.AbstractItem

Creates a new item from the value model and appends it to the list of the children of the given item.

begin_edit(self: omni.ui._ui.AbstractItemModel, item: omni.ui._ui.AbstractItem) None

Called when the user starts the editing. If it’s a field, this method is called when the user activates the field and places the cursor inside.

can_item_have_children(self: omni.ui._ui.AbstractItemModel, parentItem: omni.ui._ui.AbstractItem = None) bool

Returns true if the item can have children. In this way the delegate usually draws +/- icon.

### Arguments:

`id :`

The item to request children from. If it’s null, the children of root will be returned.

drop(*args, **kwargs)

Overloaded function.

  1. drop(self: omni.ui._ui.AbstractItemModel, item_tagget: omni.ui._ui.AbstractItem, item_source: omni.ui._ui.AbstractItem, drop_location: int = -1) -> None

Called when the user droped one item to another. Small explanation why the same default value is declared in multiple places. We use the default value to be compatible with the previous API and especially with Stage 2.0. Thr signature in the old Python API is: def drop(self, target_item, source) drop(self, target_item, source) PyAbstractItemModel::drop AbstractItemModel.drop pybind11::class_<AbstractItemModel>.def(“drop”) AbstractItemModel

  1. drop(self: omni.ui._ui.AbstractItemModel, item_tagget: omni.ui._ui.AbstractItem, source: str, drop_location: int = -1) -> None

Called when the user droped a string to the item.

drop_accepted(*args, **kwargs)

Overloaded function.

  1. drop_accepted(self: omni.ui._ui.AbstractItemModel, item_tagget: omni.ui._ui.AbstractItem, item_source: omni.ui._ui.AbstractItem, drop_location: int = -1) -> bool

Called to determine if the model can perform drag and drop to the given item. If this method returns false, the widget shouldn’t highlight the visual element that represents this item.

  1. drop_accepted(self: omni.ui._ui.AbstractItemModel, item_tagget: omni.ui._ui.AbstractItem, source: str, drop_location: int = -1) -> bool

Called to determine if the model can perform drag and drop of the given string to the given item. If this method returns false, the widget shouldn’t highlight the visual element that represents this item.

end_edit(self: omni.ui._ui.AbstractItemModel, item: omni.ui._ui.AbstractItem) None

Called when the user finishes the editing. If it’s a field, this method is called when the user presses Enter or selects another field for editing. It’s useful for undo/redo.

get_drag_mime_data(self: omni.ui._ui.AbstractItemModel, item: omni.ui._ui.AbstractItem = None) str

Returns Multipurpose Internet Mail Extensions (MIME) for drag and drop.

get_item_children(self: omni.ui._ui.AbstractItemModel, parentItem: omni.ui._ui.AbstractItem = None) List[omni.ui._ui.AbstractItem]

Returns the vector of items that are nested to the given parent item.

### Arguments:

`id :`

The item to request children from. If it’s null, the children of root will be returned.

get_item_value_model(self: omni.ui._ui.AbstractItemModel, item: omni.ui._ui.AbstractItem = None, column_id: int = 0) omni.ui._ui.AbstractValueModel

Get the value model associated with this item.

### Arguments:

`item :`

The item to request the value model from. If it’s null, the root value model will be returned.

`index :`

The column number to get the value model.

get_item_value_model_count(self: omni.ui._ui.AbstractItemModel, item: omni.ui._ui.AbstractItem = None) int

Returns the number of columns this model item contains.

remove_begin_edit_fn(self: omni.ui._ui.AbstractItemModel, arg0: int) None

Remove the callback by its id.

### Arguments:

`id :`

The id that addBeginEditFn returns.

remove_end_edit_fn(self: omni.ui._ui.AbstractItemModel, arg0: int) None

Remove the callback by its id.

### Arguments:

`id :`

The id that addEndEditFn returns.

remove_item(self: omni.ui._ui.AbstractItemModel, item: omni.ui._ui.AbstractItem) None

Removes the item from the model. There is no parent here because we assume that the reimplemented model deals with its data and can figure out how to remove this item.

remove_item_changed_fn(self: omni.ui._ui.AbstractItemModel, arg0: int) None

Remove the callback by its id.

### Arguments:

`id :`

The id that addValueChangedFn returns.

subscribe_begin_edit_fn(self: omni.ui._ui.AbstractItemModel, arg0: Callable[[omni.ui._ui.AbstractItemModel, omni.ui._ui.AbstractItem], None]) carb._carb.Subscription

Adds the function that will be called every time the user starts the editing. The id of the callback that is used to remove the callback.

subscribe_end_edit_fn(self: omni.ui._ui.AbstractItemModel, arg0: Callable[[omni.ui._ui.AbstractItemModel, omni.ui._ui.AbstractItem], None]) carb._carb.Subscription

Adds the function that will be called every time the user finishes the editing. The id of the callback that is used to remove the callback.

subscribe_item_changed_fn(self: omni.ui._ui.AbstractItemModel, arg0: Callable[[omni.ui._ui.AbstractItemModel, omni.ui._ui.AbstractItem], None]) carb._carb.Subscription

Adds the function that will be called every time the value changes. The id of the callback that is used to remove the callback.