47 #include <QAbstractItemModel> 48 #include <QModelIndex> 51 #include "TreeItem.hh" 59 void dataChangedInside(
int _id,
int _column,
const QVariant& _value);
61 void moveBaseObject(
int _id,
int _newParentId);
79 QVariant
data(
const QModelIndex &_index,
int _role)
const;
82 Qt::ItemFlags
flags(
const QModelIndex &_index)
const;
86 Qt::Orientation _orientation,
87 int _role = Qt::DisplayRole)
const;
90 QModelIndex
index(
int _row,
int _column,
91 const QModelIndex &_parent = QModelIndex())
const;
94 QModelIndex
parent(
const QModelIndex &_index)
const;
97 int rowCount(
const QModelIndex &_parent = QModelIndex())
const;
104 int columnCount(
const QModelIndex &_parent = QModelIndex())
const;
113 bool setData(
const QModelIndex &_index,
const QVariant &_value ,
int _role);
140 QString
itemName(
const QModelIndex &_index)
const;
143 int itemId(
const QModelIndex &_index)
const;
179 QMimeData*
mimeData(
const QModelIndexList& indexes)
const;
190 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent);
QMimeData * mimeData(const QModelIndexList &indexes) const
get the mimeData for a given ModelIndex
void objectDeleted(int _id)
The object with the given id has been deleted. delete it from the internal tree.
QModelIndex index(int _row, int _column, const QModelIndex &_parent=QModelIndex()) const
Get the ModelIndex at given row,column.
QString itemName(const QModelIndex &_index) const
Get the name of a TreeItem corresponding to a given ModelIndex.
Qt::ItemFlags flags(const QModelIndex &_index) const
return the types of the corresponding entry
void moveItem(TreeItem *_item, TreeItem *_parent)
move the item to a new parent
TreeItem * getItem(const QModelIndex &_index) const
Get the TreeItem corresponding to a given ModelIndex.
TreeItem * rootItem_
Root item of the tree.
int columnCount(const QModelIndex &_parent=QModelIndex()) const
Return the number of columns.
int itemId(const QModelIndex &_index) const
Get the id of a TreeItem corresponding to a given ModelIndex.
QModelIndex getModelIndex(TreeItem *_object, int _column)
Return the ModelIndex corresponding to a given TreeItem and Column.
QStringList mimeTypes() const
stores the mimeType for Drag & Drop
QVariant data(const QModelIndex &_index, int _role) const
Get the data of the corresponding entry.
bool getObjectName(TreeItem *_object, QString &_name)
Get the name of a given object.
QModelIndex parent(const QModelIndex &_index) const
Get the parent ModelIndex.
bool isRoot(TreeItem *_item)
Check if the given item is the root item.
void objectChanged(int _id)
The object with the given id has been changed. Check if model also has to be changed.
QVariant headerData(int _section, Qt::Orientation _orientation, int _role=Qt::DisplayRole) const
return the header data of the model
Qt::DropActions supportedDropActions() const
supported drag & Drop actions
int rowCount(const QModelIndex &_parent=QModelIndex()) const
get the number of rows
TreeModel(QObject *_parent=0)
Constructor.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
This is called when mimeData is dropped.
bool setData(const QModelIndex &_index, const QVariant &_value, int _role)
Set Data at 'index' to 'value'.
void objectAdded(BaseObject *_object)
The object with the given id has been added. add it to the internal tree.