3 #include <Gui/RaGui.hpp>
8 #include <QAbstractItemModel>
42 virtual std::string getName()
const = 0;
56 int getIndexInParent()
const;
58 bool isChecked()
const {
return m_checked; }
59 void setChecked(
bool checked =
true ) { m_checked = checked; }
71 bool m_checked {
true };
76 class RA_GUI_API
TreeModel :
public QAbstractItemModel
81 TreeModel( QObject* parent =
nullptr ) : QAbstractItemModel( parent ) {}
90 int rowCount(
const QModelIndex& parent = QModelIndex() )
const override;
97 int columnCount(
const QModelIndex& parent = QModelIndex() )
const override {
98 CORE_UNUSED( parent );
108 QVariant data(
const QModelIndex& index,
int role )
const override;
110 bool setData(
const QModelIndex& index,
const QVariant& value,
int role )
override;
119 QVariant headerData(
int section,
120 Qt::Orientation orientation,
121 int role = Qt::DisplayRole )
const override;
131 index(
int row,
int column,
const QModelIndex& parent = QModelIndex() )
const override;
138 QModelIndex parent(
const QModelIndex& child )
const override;
145 Qt::ItemFlags flags(
const QModelIndex& index )
const override;
158 virtual std::string getHeaderString()
const = 0;
165 TreeItem* getItem(
const QModelIndex& index )
const;
168 bool findInTree(
const TreeItem* item )
const;
171 void printModel()
const;
174 void setAllItemsChecked(
bool checked =
true );
177 void setItemChecked(
const QModelIndex& index,
bool checked =
true );
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.