53 #include <QAbstractItemModel> 54 #include <QModelIndex> 57 #include "TreeItem.hh" 59 class TreeModel :
public QAbstractItemModel
65 void dataChangedInside(
int _id,
int _column,
const QVariant& _value);
83 QVariant
data(
const QModelIndex &_index,
int _role)
const;
86 Qt::ItemFlags
flags(
const QModelIndex &_index)
const;
90 Qt::Orientation _orientation,
91 int _role = Qt::DisplayRole)
const;
94 QModelIndex
index(
int _row,
int _column,
95 const QModelIndex &_parent = QModelIndex())
const;
98 QModelIndex
parent(
const QModelIndex &_index)
const;
101 int rowCount(
const QModelIndex &_parent = QModelIndex())
const;
108 int columnCount(
const QModelIndex &_parent = QModelIndex())
const;
117 bool setData(
const QModelIndex &_index,
const QVariant &_value ,
int _role);
144 QString
itemName(
const QModelIndex &_index)
const;
147 int itemId(
const QModelIndex &_index)
const;
int itemId(const QModelIndex &_index) const
Get the id of a TreeItem corresponding to a given ModelIndex.
int columnCount(const QModelIndex &_parent=QModelIndex()) const
Return the number of columns.
int rowCount(const QModelIndex &_parent=QModelIndex()) const
get the number of rows
QModelIndex getModelIndex(TreeItem *_object, int _column)
Return the ModelIndex corresponding to a given TreeItem and Column.
void objectChanged(int _id)
The object with the given id has been changed. Check if model also has to be changed.
void propagateDownwards(TreeItem *_obj, int _column)
Recursively update a column up to the root of the tree.
QString itemName(const QModelIndex &_index) const
Get the name of a TreeItem corresponding to a given ModelIndex.
TreeModel(QObject *_parent=0)
Constructor.
Qt::ItemFlags flags(const QModelIndex &_index) const
return the types of the corresponding entry
TreeItem * rootItem_
Root item of the tree.
void propagateUpwards(TreeItem *_obj, int _column, bool _value)
Recursively update a column up to the root of the tree.
QVariant data(const QModelIndex &_index, int _role) const
Get the data of the corresponding entry.
void objectAdded(BaseObject *_object)
The object with the given id has been added. add it to the internal tree.
QModelIndex parent(const QModelIndex &_index) const
Get the parent ModelIndex.
void moveItem(TreeItem *_item, TreeItem *_parent)
move the item to a new parent
bool isRoot(TreeItem *_item)
Check if the given item is the root item.
TreeItem * getItem(const QModelIndex &_index) const
Get the TreeItem corresponding to a given ModelIndex.
QModelIndex index(int _row, int _column, const QModelIndex &_parent=QModelIndex()) const
Get the ModelIndex at given row,column.
bool getObjectName(TreeItem *_object, QString &_name)
Get the name of a given object.
void objectDeleted(int _id)
The object with the given id has been deleted. delete it from the internal tree.
QVariant headerData(int _section, Qt::Orientation _orientation, int _role=Qt::DisplayRole) const
return the header data of the model
bool setData(const QModelIndex &_index, const QVariant &_value, int _role)
Set Data at 'index' to 'value'.