Radium Engine  1.5.20
Loading...
Searching...
No Matches
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 78 of file TreeModel.hpp.

Constructor & Destructor Documentation

◆ TreeModel()

Ra::Gui::TreeModel::TreeModel ( QObject * parent = nullptr)
inline

Definition at line 83 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 99 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.

+ Here is the call graph for this function:

◆ findInTree()

bool Ra::Gui::TreeModel::findInTree ( const TreeItem * item) const
protected

Internal functions to check if an item is in the tree.

Definition at line 104 of file TreeModel.cpp.

+ Here is the call graph for this function:

◆ 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.

+ Here is the call graph for this function:

◆ getItem()

TreeItem * Ra::Gui::TreeModel::getItem ( const QModelIndex & index) const
protected

Get the tree item corresponding to the given index.

Definition at line 20 of file TreeModel.cpp.

+ Here is the call graph for this function:

◆ 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.

+ Here is the call graph for this function:

◆ 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:

◆ printModel()

void Ra::Gui::TreeModel::printModel ( ) const
protected

Prints elements in the model to stdout (debug only)

Definition at line 118 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.

+ Here is the call graph for this function:

◆ 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.

+ Here is the call graph for this function:

◆ setAllItemsChecked()

void Ra::Gui::TreeModel::setAllItemsChecked ( bool checked = true)
protected

Set the check state of all items.

Definition at line 134 of file TreeModel.cpp.

+ Here is the call graph for this function:

◆ setData()

bool Ra::Gui::TreeModel::setData ( const QModelIndex & index,
const QVariant & value,
int role )
override

Definition at line 44 of file TreeModel.cpp.

◆ setItemChecked()

void Ra::Gui::TreeModel::setItemChecked ( const QModelIndex & index,
bool checked = true )
protected

Set the check state of one item and all of its children.

Definition at line 141 of file TreeModel.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_rootItem

std::unique_ptr<TreeItem> Ra::Gui::TreeModel::m_rootItem
protected

Root of the tree.

Definition at line 183 of file TreeModel.hpp.


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