MapTreeWidgetBuilder< KeyT, ValueT > Struct Template Reference

A class to efficiently build and maintain sorted items of QTreeWidget or QTreeWidgetItem based on a map matching the intended structure. More...

#include <RobotAPI/libraries/armem_gui/TreeWidgetBuilder.h>

Public Types

using Base = TreeWidgetBuilder< typename MapT::value_type >
 
using CompareFn = std::function< int(const ElementT &element, QTreeWidgetItem *item)>
 
using ElementT = typename Base::ElementT
 
using MakeItemFn = std::function< QTreeWidgetItem *(const KeyT &key, const ValueT &value)>
 
using MapT = std::map< KeyT, ValueT >
 
using NameFn = std::function< std::string(const KeyT &key, const ValueT &value)>
 
using UpdateItemFn = std::function< bool(const KeyT &key, const ValueT &value, QTreeWidgetItem *item)>
 

Public Member Functions

 MapTreeWidgetBuilder ()
 
 MapTreeWidgetBuilder (const MapT &)
 Allows declaring instance from container without explicit template arguments. More...
 
 MapTreeWidgetBuilder (MakeItemFn makeItemFn, UpdateItemFn updateItemFn=NoUpdate)
 
 MapTreeWidgetBuilder (NameFn nameFn, MakeItemFn makeItemFn, UpdateItemFn updateItemFn=NoUpdate)
 
void setCompareFn (CompareFn compareFn)
 
void setExpand (bool expand)
 
void setMakeItemFn (MakeItemFn makeItemFn)
 
void setNameFn (NameFn nameFn)
 
void setUpdateItemFn (UpdateItemFn updateItemFn)
 
template<class ParentT >
void updateTree (ParentT *tree, const MapT &elements)
 

Static Public Member Functions

static std::string KeyAsName (const KeyT &key, const ValueT &value)
 A name function using the key as name. More...
 
static bool NoUpdate (const KeyT &key, const ValueT &value, QTreeWidgetItem *item)
 No update function (default). More...
 

Detailed Description

template<class KeyT, class ValueT>
struct armarx::MapTreeWidgetBuilder< KeyT, ValueT >

A class to efficiently build and maintain sorted items of QTreeWidget or QTreeWidgetItem based on a map matching the intended structure.

Definition at line 124 of file TreeWidgetBuilder.h.

Member Typedef Documentation

◆ Base

using Base = TreeWidgetBuilder<typename MapT::value_type>

Definition at line 127 of file TreeWidgetBuilder.h.

◆ CompareFn

using CompareFn = std::function<int(const ElementT& element, QTreeWidgetItem* item)>

Definition at line 130 of file TreeWidgetBuilder.h.

◆ ElementT

using ElementT = typename Base::ElementT

Definition at line 128 of file TreeWidgetBuilder.h.

◆ MakeItemFn

using MakeItemFn = std::function<QTreeWidgetItem*(const KeyT& key, const ValueT& value)>

Definition at line 133 of file TreeWidgetBuilder.h.

◆ MapT

using MapT = std::map<KeyT, ValueT>

Definition at line 126 of file TreeWidgetBuilder.h.

◆ NameFn

using NameFn = std::function<std::string(const KeyT& key, const ValueT& value)>

Definition at line 131 of file TreeWidgetBuilder.h.

◆ UpdateItemFn

using UpdateItemFn = std::function<bool(const KeyT& key, const ValueT& value, QTreeWidgetItem* item)>

Definition at line 134 of file TreeWidgetBuilder.h.

Constructor & Destructor Documentation

◆ MapTreeWidgetBuilder() [1/4]

Definition at line 137 of file TreeWidgetBuilder.h.

◆ MapTreeWidgetBuilder() [2/4]

MapTreeWidgetBuilder ( const MapT )
inline

Allows declaring instance from container without explicit template arguments.

Definition at line 142 of file TreeWidgetBuilder.h.

◆ MapTreeWidgetBuilder() [3/4]

MapTreeWidgetBuilder ( MakeItemFn  makeItemFn,
UpdateItemFn  updateItemFn = NoUpdate 
)
inline

Definition at line 145 of file TreeWidgetBuilder.h.

◆ MapTreeWidgetBuilder() [4/4]

MapTreeWidgetBuilder ( NameFn  nameFn,
MakeItemFn  makeItemFn,
UpdateItemFn  updateItemFn = NoUpdate 
)
inline

Definition at line 150 of file TreeWidgetBuilder.h.

Member Function Documentation

◆ KeyAsName()

static std::string KeyAsName ( const KeyT &  key,
const ValueT &  value 
)
inlinestatic

A name function using the key as name.

Definition at line 202 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

◆ NoUpdate()

static bool NoUpdate ( const KeyT &  key,
const ValueT &  value,
QTreeWidgetItem *  item 
)
inlinestatic

No update function (default).

Definition at line 218 of file TreeWidgetBuilder.h.

◆ setCompareFn()

void setCompareFn ( CompareFn  compareFn)
inline

Definition at line 166 of file TreeWidgetBuilder.h.

◆ setExpand()

void setExpand ( bool  expand)
inline

Definition at line 188 of file TreeWidgetBuilder.h.

◆ setMakeItemFn()

void setMakeItemFn ( MakeItemFn  makeItemFn)
inline

Definition at line 171 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

◆ setNameFn()

void setNameFn ( NameFn  nameFn)
inline

Definition at line 157 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

◆ setUpdateItemFn()

void setUpdateItemFn ( UpdateItemFn  updateItemFn)
inline

Definition at line 179 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

◆ updateTree()

void updateTree ( ParentT *  tree,
const MapT elements 
)
inline

Definition at line 195 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

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