Source code for pyleecan.GUI.Tools.WTreeEdit.TreeEditModelItems
# -*- coding: utf-8 -*-
[docs]class ObjectItem:
"""TreeEditModel item class."""
def __init__(self, obj, name, index=None, parent=None):
self._parent = parent
self._obj = obj
self._name = name
self._index = index
self._children = []
self._columns = 1
if parent is not None:
parent.appendChild(self)
[docs] def parent(self):
return self._parent
[docs] def children(self):
return self._children
[docs] def child(self, row):
if row >= self.childCount():
return None
return self._children[row]
[docs] def childCount(self):
return len(self._children)
[docs] def row(self):
if self._parent is not None:
children = self._parent.children()
return children.index(self) if self in children else None
[docs] def columnCount(self):
return self._columns
[docs] def object(self):
return self._obj
[docs] def name(self):
return self._name
[docs] def appendChild(self, item):
self._children.append(item)
item._parent = self
[docs] def clearChildren(self):
self._children = []
[docs] def setObject(self, obj):
self._obj = obj
[docs] def data(self, role=None):
return None
[docs] def index(self):
return self._index
[docs]class UnknownItem(ObjectItem):
"""Convienence class for unknown (not implemented yet) objects."""
pass