Interface for providing Key-Value pairs for Qt Tree/List Views.
Usage:
#include <PropertyTree.h>
|
virtual void | fillTree (IBlock *b)=0 |
| Method to fill the tree. More...
|
|
virtual void | clear ()=0 |
| Removes all data from the Property Tree. More...
|
|
template<typename T > |
ItemID | addItem (const std::string &name, const T &val, ItemID parent=nullptr) |
| Adds property value pair to the tree. More...
|
|
ItemID | addItem (const std::string &name, ItemID parent=nullptr) |
| Convenience method, behaves like addItem above with no value -> empty second column. More...
|
|
template<typename T > |
void | modifyItem (const std::string &name, const T &val, ItemID id) |
| Changes an existing item. More...
|
|
template<typename T > |
void | modifyItem (const T &val, ItemID id) |
| Convenience method, behaves like modifyItem(string,T,ItemID) but does not change the first column. More...
|
|
void | removeItem (ItemID id) |
| Removes an item from the tree. More...
|
|
◆ ItemID
◆ PropertyTree()
walberla::gui::PropertyTree::PropertyTree |
( |
| ) |
|
◆ ~PropertyTree()
walberla::gui::PropertyTree::~PropertyTree |
( |
| ) |
|
|
virtualdefault |
◆ addItem() [1/2]
Adds property value pair to the tree.
- Parameters
-
name | the string that appears in the first column of the treeView |
val | value that appears in the second column T can be every type that QString.arg() accepts i.e. all native data types and std::string; |
parent | key-value pairs can be organized hierarchically, here an ItemID of another item can be specified, which is used as parent |
- Returns
- identifier for this item which can be used to modify/remove this item or to add children
◆ addItem() [2/2]
Convenience method, behaves like addItem above with no value -> empty second column.
◆ clear()
virtual void walberla::gui::PropertyTree::clear |
( |
| ) |
|
|
protectedpure virtual |
Removes all data from the Property Tree.
This method should restore the object to its initial state i.e. delete all stored data, usually the ItemID's see also fillTree()
◆ create()
virtual shared_ptr<PropertyTree> walberla::gui::PropertyTree::create |
( |
| ) |
const |
|
pure virtual |
Virtual constructor.
a new object has to be instantiated for each opened treeView that displays this model In the implementation just return "make_shared<YourDerivedClass>()"
◆ fillTree()
virtual void walberla::gui::PropertyTree::fillTree |
( |
IBlock * |
b | ) |
|
|
protectedpure virtual |
Method to fill the tree.
This method is called whenever the data in the block may have changed or the block itself has changed. The first time fillTree is called add your display data using addItem and store the ItemIDs. On the next call, change the value of the items using modifyItem If the block is not the same as on the last call, clear() is called between the two fillTree invocations. In the clear method the saved ItemID's can be deleted
◆ getModel()
Retrieves the Qt Model Data structure.
used by gui, do not change in subclass
◆ getName()
virtual const std::string walberla::gui::PropertyTree::getName |
( |
| ) |
|
|
pure virtual |
Returns name/type of data of this model.
When multiple PropertyTrees have been registered the user can choose which data to display using this name
◆ modifyItem() [1/2]
template<typename T >
void walberla::gui::PropertyTree::modifyItem |
( |
const std::string & |
name, |
|
|
const T & |
val, |
|
|
ItemID |
id |
|
) |
| |
|
protected |
Changes an existing item.
Store the ItemID's between fillTree calls, to modify items instead of clearing and new adding, since otherwise the TreeView is reset after each timestep and expansion states etc. are lost
- Parameters
-
name | new first column string for the item |
val | new value for second column |
id | id returned by addItem to specify which item is modified |
◆ modifyItem() [2/2]
template<typename T >
void walberla::gui::PropertyTree::modifyItem |
( |
const T & |
val, |
|
|
ItemID |
id |
|
) |
| |
|
protected |
Convenience method, behaves like modifyItem(string,T,ItemID) but does not change the first column.
◆ removeItem()
void walberla::gui::PropertyTree::removeItem |
( |
ItemID |
id | ) |
|
|
protected |
Removes an item from the tree.
To remove all items, call clear() instead of this method
- Parameters
-
◆ setBlock()
void walberla::gui::PropertyTree::setBlock |
( |
IBlock * |
b | ) |
|
Updates Model, using given block.
This method is called by gui when a different block should be displayed, or the data inside a block has changed. Should not be changed by subclasses
◆ lastBlock_
IBlock* walberla::gui::PropertyTree::lastBlock_ |
|
private |
◆ model_
The documentation for this class was generated from the following files: