Version: 9.12.0
SUIT_TreeModel::TreeSync Class Reference

Functor class for synchronizing data tree and tree model when the data tree is changed outside the model. More...

Public Member Functions

 TreeSync (SUIT_TreeModel *)
 Constructor. More...
 
bool isEqual (const ObjPtr &, const ItemPtr &) const
 Check if item corresponds to the specified data object. More...
 
ObjPtr nullSrc () const
 Get null data object. More...
 
ItemPtr nullTrg () const
 Get null tree item. More...
 
ItemPtr createItem (const ObjPtr &, const ItemPtr &, const ItemPtr &) const
 Create an item corresponding to the specified data object. More...
 
void updateItem (const ObjPtr &, const ItemPtr &) const
 Update tree item. More...
 
void deleteItemWithChildren (const ItemPtr &) const
 Delete item with all children recursively. More...
 
QList< ObjPtrchildren (const ObjPtr &) const
 Get all the children of the specified data object. More...
 
QList< ItemPtrchildren (const ItemPtr &) const
 Get all the children of the specified tree item. More...
 
ItemPtr parent (const ItemPtr &) const
 Get item which is the parent for the specified item. More...
 

Private Member Functions

bool needUpdate (const ItemPtr &) const
 Check if the tree item needs updating. More...
 

Private Attributes

SUIT_TreeModelmyModel
 

Detailed Description

Functor class for synchronizing data tree and tree model when the data tree is changed outside the model.

Constructor & Destructor Documentation

◆ TreeSync()

SUIT_TreeModel::TreeSync::TreeSync ( SUIT_TreeModel model)

Constructor.

Parameters
modeltree model

Member Function Documentation

◆ children() [1/2]

QList< SUIT_TreeModel::ItemPtr > SUIT_TreeModel::TreeSync::children ( const ItemPtr item) const

Get all the children of the specified tree item.

Parameters
itemtree item
Returns
list of the children

References SUIT_TreeModel::TreeItem::children().

◆ children() [2/2]

QList< SUIT_TreeModel::ObjPtr > SUIT_TreeModel::TreeSync::children ( const ObjPtr obj) const

Get all the children of the specified data object.

Parameters
objdata object
Returns
list of the children

References SUIT_DataObject::children().

◆ createItem()

SUIT_TreeModel::ItemPtr SUIT_TreeModel::TreeSync::createItem ( const ObjPtr obj,
const ItemPtr parent,
const ItemPtr after 
) const

Create an item corresponding to the specified data object.

Parameters
objdata object
parentparent tree item
aftertree item after each new one should be inserted
Returns
created item

References SUIT_TreeModel::parent(), and SUIT_DataObject::update().

◆ deleteItemWithChildren()

void SUIT_TreeModel::TreeSync::deleteItemWithChildren ( const ItemPtr item) const

Delete item with all children recursively.

Parameters
itemtree item

◆ isEqual()

bool SUIT_TreeModel::TreeSync::isEqual ( const ObjPtr obj,
const ItemPtr item 
) const

Check if item corresponds to the specified data object.

Parameters
objdata object
itemtree item
Returns
true if item corresponds to the data object

References SUIT_TreeModel::TreeItem::dataObject(), and SUIT_DataObject::root().

◆ needUpdate()

bool SUIT_TreeModel::TreeSync::needUpdate ( const ItemPtr item) const
private

Check if the tree item needs updating.

Parameters
itemtree item to be checked
Returns
true if item needs updating
Todo:
finalize this method

References SUIT_TreeModel::TreeItem::dataObject().

◆ nullSrc()

SUIT_TreeModel::ObjPtr SUIT_TreeModel::TreeSync::nullSrc ( ) const

Get null data object.

Returns
null data object

◆ nullTrg()

SUIT_TreeModel::ItemPtr SUIT_TreeModel::TreeSync::nullTrg ( ) const

Get null tree item.

Returns
null tree item

◆ parent()

SUIT_TreeModel::ItemPtr SUIT_TreeModel::TreeSync::parent ( const ItemPtr item) const

Get item which is the parent for the specified item.

Parameters
itemtree item
Returns
parent item

References SUIT_TreeModel::TreeItem::parent().

◆ updateItem()

void SUIT_TreeModel::TreeSync::updateItem ( const ObjPtr obj,
const ItemPtr item 
) const

Update tree item.

Parameters
objreference data object
itemtree item to be updated

References SUIT_DataObject::update().

Member Data Documentation

◆ myModel

SUIT_TreeModel* SUIT_TreeModel::TreeSync::myModel
private

The documentation for this class was generated from the following file: