TreeWidgetBuilder< _ElementT > Struct Template Reference

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

#include <RobotAPI/libraries/armem_gui/instance/tree_builders/DataTreeBuilderBase.h>

Public Types

using CompareFn = std::function< int(const ElementT &element, QTreeWidgetItem *item)>
 Return < 0 if element < item, 0 if element == item, and > 0 if element > item. More...
 
using ElementT = _ElementT
 
using MakeItemFn = std::function< QTreeWidgetItem *(const ElementT &element)>
 
using NameFn = std::function< std::string(const ElementT &element)>
 
using UpdateItemFn = std::function< bool(const ElementT &element, QTreeWidgetItem *item)>
 

Public Member Functions

void setCompareFn (CompareFn compareFn)
 
void setExpand (bool expand)
 
void setMakeItemFn (MakeItemFn makeItemFn)
 
void setNameFn (NameFn nameFn, int nameColumn=0)
 
void setUpdateItemFn (UpdateItemFn updateItemFn)
 
 TreeWidgetBuilder ()=default
 
 TreeWidgetBuilder (CompareFn compareFn, MakeItemFn makeItemFn, UpdateItemFn updateItemFn=NoUpdate)
 
 TreeWidgetBuilder (const ElementT &)
 Constructor to automatically derive the template argument. More...
 
 TreeWidgetBuilder (NameFn nameFn, MakeItemFn makeItemFn, UpdateItemFn updateItemFn=NoUpdate, int nameColumn=0)
 
template<class ParentT , class ContainerT >
void updateTreeWithContainer (ParentT *parent, const ContainerT &elements)
 Update the tree with the iterable container. More...
 
template<class ParentT , class IteratorFn >
void updateTreeWithIterator (ParentT *parent, IteratorFn &&iteratorFn)
 Update the tree according to the elements iterated over by iteratorFn. More...
 

Static Public Member Functions

static CompareFn MakeCompareNameFn (NameFn nameFn, int nameColumn)
 Uses the name for comparison. More...
 
static bool NoUpdate (const ElementT &element, QTreeWidgetItem *item)
 No update function (default). More...
 

Detailed Description

template<class _ElementT>
struct armarx::TreeWidgetBuilder< _ElementT >

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

Definition at line 10 of file DataTreeBuilderBase.h.

Member Typedef Documentation

◆ CompareFn

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

Return < 0 if element < item, 0 if element == item, and > 0 if element > item.

Definition at line 25 of file TreeWidgetBuilder.h.

◆ ElementT

using ElementT = _ElementT

Definition at line 22 of file TreeWidgetBuilder.h.

◆ MakeItemFn

using MakeItemFn = std::function<QTreeWidgetItem*(const ElementT& element)>

Definition at line 27 of file TreeWidgetBuilder.h.

◆ NameFn

using NameFn = std::function<std::string(const ElementT& element)>

Definition at line 26 of file TreeWidgetBuilder.h.

◆ UpdateItemFn

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

Definition at line 28 of file TreeWidgetBuilder.h.

Constructor & Destructor Documentation

◆ TreeWidgetBuilder() [1/4]

TreeWidgetBuilder ( )
default

◆ TreeWidgetBuilder() [2/4]

TreeWidgetBuilder ( const ElementT )
inline

Constructor to automatically derive the template argument.

Definition at line 33 of file TreeWidgetBuilder.h.

◆ TreeWidgetBuilder() [3/4]

TreeWidgetBuilder ( CompareFn  compareFn,
MakeItemFn  makeItemFn,
UpdateItemFn  updateItemFn = NoUpdate 
)
inline

Definition at line 36 of file TreeWidgetBuilder.h.

◆ TreeWidgetBuilder() [4/4]

TreeWidgetBuilder ( NameFn  nameFn,
MakeItemFn  makeItemFn,
UpdateItemFn  updateItemFn = NoUpdate,
int  nameColumn = 0 
)
inline

Definition at line 39 of file TreeWidgetBuilder.h.

Member Function Documentation

◆ MakeCompareNameFn()

auto MakeCompareNameFn ( NameFn  nameFn,
int  nameColumn 
)
static

Uses the name for comparison.

Definition at line 301 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

◆ NoUpdate()

static bool NoUpdate ( const ElementT element,
QTreeWidgetItem *  item 
)
inlinestatic

No update function (default).

Definition at line 96 of file TreeWidgetBuilder.h.

◆ setCompareFn()

void setCompareFn ( CompareFn  compareFn)
inline

Definition at line 45 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

◆ setExpand()

void setExpand ( bool  expand)
inline

Definition at line 62 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

◆ setMakeItemFn()

void setMakeItemFn ( MakeItemFn  makeItemFn)
inline

Definition at line 53 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

◆ setNameFn()

void setNameFn ( NameFn  nameFn,
int  nameColumn = 0 
)
inline

Definition at line 49 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

◆ setUpdateItemFn()

void setUpdateItemFn ( UpdateItemFn  updateItemFn)
inline

Definition at line 57 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

◆ updateTreeWithContainer()

void updateTreeWithContainer ( ParentT *  parent,
const ContainerT &  elements 
)

Update the tree with the iterable container.

Parameters
parentThe parent, i.e. the tree widget or a tree widget item.
iteratorFnFunction taking a function bool fn(const ElementT& element) and calling it for each element in the underlying container, i.e. like: void iteratorFn(bool (*elementFn)(const ElementT& element));

Definition at line 312 of file TreeWidgetBuilder.h.

+ Here is the caller graph for this function:

◆ updateTreeWithIterator()

void updateTreeWithIterator ( ParentT *  parent,
IteratorFn &&  iteratorFn 
)

Update the tree according to the elements iterated over by iteratorFn.

Parameters
parentThe parent, i.e. the tree widget or a tree widget item.
iteratorFnFunction taking a function bool fn(const ElementT& element) and calling it for each element in the underlying container, i.e. like: void iteratorFn(bool (*elementFn)(const ElementT& element));

Definition at line 329 of file TreeWidgetBuilder.h.


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