# Resource-tree panel in SMTK3/CMB6

**URL:** https://discourse.kitware.com/t/resource-tree-panel-in-smtk3-cmb6/146
**Category:** Design
**Created:** [August 21, 2018, 6:42pm UTC](https://discourse.kitware.com/t/resource-tree-panel-in-smtk3-cmb6/146 "2018-08-21T18:42:20Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![dcthomp](https://discourse.kitware.com/user_avatar/discourse.kitware.com/dcthomp/32/10_2.png) [@dcthomp](https://discourse.kitware.com/u/dcthomp)
#### Post date: [August 21, 2018, 6:42pm UTC](https://discourse.kitware.com/t/resource-tree-panel-in-smtk3-cmb6/146/1 "2018-08-21T18:42:21Z")

</div>

@Bob_Obara You asked in our weekly meeting about where the logic lives to handle updates to the resource panel when operations occur. It goes something like this:

- When the SMTK plugins are loaded and/or a ParaView server connects, [the PhraseModel for the tree panel is told to observe the resource and operation managers](https://gitlab.kitware.com/cmb/smtk/blob/master/smtk/view/PhraseModel.cxx#L74)
- When a resource is loaded, created, or modified by an operation, the PhraseModel’s [handleResourceEvent](https://gitlab.kitware.com/cmb/smtk/blob/master/smtk/view/PhraseModel.cxx#L194) and/or [handleOperationEvent](https://gitlab.kitware.com/cmb/smtk/blob/master/smtk/view/PhraseModel.cxx#L200) methods are invoked.
- Some of these methods are not implemented yet (since I wrote them before TJ’s work on operations was not complete), but they are responsible for identifying which entries in the tree are about to have their _children_ modified You can see that sometimes subclasses of PhraseModel take on this responsibility, e.g., [ComponentPhraseModel::processResource](https://gitlab.kitware.com/cmb/smtk/blob/101679d6/smtk/view/ComponentPhraseModel.cxx#L120), called by the subclass’s handleResourceEvent.
- Once the methods in the PhraseModel or its subclasses identify children based on the event, they use the relevant SubphraseGenerator to obtain a new list of descriptive phrases and pass that list to PhraseModel::updateChildren().
- [PhraseModel::updateChildren](https://gitlab.kitware.com/cmb/smtk/blob/101679d6/smtk/view/PhraseModel.cxx#L278) looks at the difference between existing phrases and the new phrases, turning it into a list of edits (insert/remove/move/modify). It performs the edits, calling its [trigger()](https://gitlab.kitware.com/cmb/smtk/blob/101679d6/smtk/view/PhraseModel.cxx#L460) method before and after each edit.
- The trigger method simply [invokes an observer that qtDescriptivePhraseModel added](https://gitlab.kitware.com/cmb/smtk/blob/101679d6/smtk/extension/qt/qtDescriptivePhraseModel.cxx#L695) which tells Qt which QModelIndex objects are about to change in all the QTreeView widgets displaying the descriptive-phrase model.

It might seem like a a lot, but if we want updates to be efficient and not recompute the entire tree for every operation, it’s what’s needed.
