Loading [MathJax]/extensions/TeX/AMSmath.js
Radium Engine  1.5.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
Ra::Gui::TreeModel Class Referenceabstract

#include <Gui/TreeModel/TreeModel.hpp>

+ Inheritance diagram for Ra::Gui::TreeModel:
+ Collaboration diagram for Ra::Gui::TreeModel:

Signals

void modelRebuilt ()
 Emitted when the model has been rebuilt.
 

Public Member Functions

 TreeModel (QObject *parent=nullptr)
 
void rebuildModel ()
 
QAbstractItemModel interface
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role) const override
 
bool setData (const QModelIndex &index, const QVariant &value, int role) override
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
QModelIndex parent (const QModelIndex &child) const override
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 

Protected Member Functions

virtual std::string getHeaderString () const =0
 
virtual void buildModel ()=0
 
TreeItemgetItem (const QModelIndex &index) const
 Get the tree item corresponding to the given index.
 
bool findInTree (const TreeItem *item) const
 Internal functions to check if an item is in the tree.
 
void printModel () const
 Prints elements in the model to stdout (debug only)
 
void setAllItemsChecked (bool checked=true)
 Set the check state of all items.
 
void setItemChecked (const QModelIndex &index, bool checked=true)
 Set the check state of one item and all of its children.
 

Protected Attributes

std::unique_ptr< TreeItemm_rootItem
 Root of the tree.
 

Detailed Description

This class implement QAbstractItem model with the TreeItem as its model Derived class must use some kind of cast to access the derived TreeItems.

Definition at line 76 of file TreeModel.hpp.

Member Function Documentation

◆ buildModel()

virtual void Ra::Gui::TreeModel::buildModel ( )
protectedpure virtual

Function to build the model from scratch. Call either at initialization or through rebuildModel().

Implemented in Ra::Gui::ItemModel.

◆ columnCount()

int Ra::Gui::TreeModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
inlineoverride

Returns the number of columns (only one in our case).

Parameters
parent
Returns

Definition at line 97 of file TreeModel.hpp.

◆ data()

QVariant Ra::Gui::TreeModel::data ( const QModelIndex &  index,
int  role 
) const
override

Return the data corresponding to the given index : in this case a string with the item name.

Parameters
index
role
Returns

Definition at line 32 of file TreeModel.cpp.

◆ flags()

Qt::ItemFlags Ra::Gui::TreeModel::flags ( const QModelIndex &  index) const
override

Get the flags of the object.

Parameters
index
Returns

Definition at line 89 of file TreeModel.cpp.

◆ headerData()

QVariant Ra::Gui::TreeModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
override

Return the header data of the given section.

Parameters
section
orientation
role
Returns

Definition at line 56 of file TreeModel.cpp.

◆ index()

QModelIndex Ra::Gui::TreeModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
override

Create an index for the given row, column and parent.

Parameters
row
column
parent
Returns

Definition at line 63 of file TreeModel.cpp.

◆ parent()

QModelIndex Ra::Gui::TreeModel::parent ( const QModelIndex &  child) const
override

Get the parent of a given child item.

Parameters
child
Returns

Definition at line 75 of file TreeModel.cpp.

+ Here is the call graph for this function:

◆ rebuildModel()

void Ra::Gui::TreeModel::rebuildModel ( )

Call this function to update the tree model to the current content of the engine.

Definition at line 95 of file TreeModel.cpp.

◆ rowCount()

int Ra::Gui::TreeModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Returns the number of rows, i.e .the number of children of a given parent item.

Parameters
parent
Returns

The row count of an item is the number of child it has.

Definition at line 13 of file TreeModel.cpp.


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