3#include <Gui/RaGui.hpp>
8#include <QAbstractItemModel>
58 int getIndexInParent()
const;
60 bool isChecked()
const {
return m_checked; }
61 void setChecked(
bool checked =
true ) { m_checked = checked; }
73 bool m_checked {
true };
78class RA_GUI_API
TreeModel :
public QAbstractItemModel
83 TreeModel( QObject* parent =
nullptr ) : QAbstractItemModel( parent ) {}
92 int rowCount(
const QModelIndex& parent = QModelIndex() )
const override;
99 int columnCount(
const QModelIndex& parent = QModelIndex() )
const override {
100 CORE_UNUSED( parent );
110 QVariant data(
const QModelIndex& index,
int role )
const override;
112 bool setData(
const QModelIndex& index,
const QVariant& value,
int role )
override;
121 QVariant headerData(
int section,
122 Qt::Orientation orientation,
123 int role = Qt::DisplayRole )
const override;
133 index(
int row,
int column,
const QModelIndex& parent = QModelIndex() )
const override;
140 QModelIndex parent(
const QModelIndex& child )
const override;
147 Qt::ItemFlags flags(
const QModelIndex& index )
const override;
167 TreeItem* getItem(
const QModelIndex& index )
const;
170 bool findInTree(
const TreeItem* item )
const;
173 void printModel()
const;
176 void setAllItemsChecked(
bool checked =
true );
179 void setItemChecked(
const QModelIndex& index,
bool checked =
true );
Base class for element of the tree representation.
TreeItem(const TreeItem &)=delete
TreeItems are non-copyable.
std::vector< std::unique_ptr< TreeItem > > m_children
Children of item in the tree.
virtual bool isValid() const =0
Return true if the represented object is valid.
virtual bool isSelectable() const =0
Return true if the represented object can be selected.
void modelRebuilt()
Emitted when the model has been rebuilt.
virtual void buildModel()=0
int columnCount(const QModelIndex &parent=QModelIndex()) const override
std::unique_ptr< TreeItem > m_rootItem
Root of the tree.
hepler function to manage enum as underlying types in VariableSet