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;
void objectAdded(BaseObject *_object)
The object with the given id has been added. add it to the internal tree.
QString itemName(const QModelIndex &_index) const
Get the name of a TreeItem corresponding to a given ModelIndex.
TreeModel(QObject *_parent=0)
Constructor.
QModelIndex parent(const QModelIndex &_index) const
Get the parent ModelIndex.
void propagateUpwards(TreeItem *_obj, int _column, bool _value)
Recursively update a column up to the root of the tree.
bool isRoot(TreeItem *_item)
Check if the given item is the root item.
void propagateDownwards(TreeItem *_obj, int _column)
Recursively update a column up to the root of the tree.
QModelIndex index(int _row, int _column, const QModelIndex &_parent=QModelIndex()) const
Get the ModelIndex at given row,column.
QVariant headerData(int _section, Qt::Orientation _orientation, int _role=Qt::DisplayRole) const
return the header data of the model
TreeItem * rootItem_
Root item of the tree.
void objectChanged(int _id)
The object with the given id has been changed. Check if model also has to be changed.
int rowCount(const QModelIndex &_parent=QModelIndex()) const
get the number of rows
int itemId(const QModelIndex &_index) const
Get the id of a TreeItem corresponding to a given ModelIndex.
Qt::ItemFlags flags(const QModelIndex &_index) const
return the types of the corresponding entry
QVariant data(const QModelIndex &_index, int _role) const
Get the data of the corresponding entry.
bool setData(const QModelIndex &_index, const QVariant &_value, int _role)
Set Data at 'index' to 'value'.
bool getObjectName(TreeItem *_object, QString &_name)
Get the name of a given object.
int columnCount(const QModelIndex &_parent=QModelIndex()) const
Return the number of columns.
void objectDeleted(int _id)
The object with the given id has been deleted. delete it from the internal tree.
TreeItem * getItem(const QModelIndex &_index) const
Get the TreeItem corresponding to a given ModelIndex.
QModelIndex getModelIndex(TreeItem *_object, int _column)
Return the ModelIndex corresponding to a given TreeItem and Column.
void moveItem(TreeItem *_item, TreeItem *_parent)
move the item to a new parent