Developer Documentation
|
Signals | |
void | dataChangedInside (int _id, int _column, const QVariant &_value) |
Public Member Functions | |
TreeModel (QObject *_parent=0) | |
Constructor. More... | |
~TreeModel () | |
Destructor. More... | |
inherited from QAbstractItemModel | |
QVariant | data (const QModelIndex &_index, int _role) const |
Get the data of the corresponding entry. More... | |
Qt::ItemFlags | flags (const QModelIndex &_index) const |
return the types of the corresponding entry More... | |
QVariant | headerData (int _section, Qt::Orientation _orientation, int _role=Qt::DisplayRole) const |
return the header data of the model More... | |
QModelIndex | index (int _row, int _column, const QModelIndex &_parent=QModelIndex()) const |
Get the ModelIndex at given row,column. More... | |
QModelIndex | parent (const QModelIndex &_index) const |
Get the parent ModelIndex. More... | |
int | rowCount (const QModelIndex &_parent=QModelIndex()) const |
get the number of rows More... | |
int | columnCount (const QModelIndex &_parent=QModelIndex()) const |
Return the number of columns. More... | |
bool | setData (const QModelIndex &_index, const QVariant &_value, int _role) |
Set Data at 'index' to 'value'. More... | |
Internal DataStructure (the TreeItem Tree) | |
TreeItem * | rootItem_ |
Rootitem of the tree. | |
QModelIndex | getModelIndex (TreeItem *_object, int _column) |
Return the ModelIndex corresponding to a given TreeItem and Column. More... | |
QModelIndex | getModelIndex (int _id, int _column) |
Return the ModelIndex corresponding to a given object id and Column. More... | |
bool | isRoot (TreeItem *_item) |
Check if the given item is the root item. More... | |
bool | getObjectName (TreeItem *_object, QString &_name) |
Get the name of a given object. | |
TreeItem * | getItem (const QModelIndex &_index) const |
Get the TreeItem corresponding to a given ModelIndex. More... | |
QString | itemName (const QModelIndex &_index) const |
Get the name of a TreeItem corresponding to a given ModelIndex. More... | |
int | itemId (const QModelIndex &_index) const |
Get the id of a TreeItem corresponding to a given ModelIndex. More... | |
void | objectChanged (int id_) |
The object with the given id has been changed. Check if model also has to be changed. More... | |
void | objectAdded (BaseObject *_object) |
The object with the given id has been added. add it to the internal tree. More... | |
void | objectAdded (BaseObject *_object, BaseObject *_parent) |
The object with the given id has been added. add it to the internal tree. More... | |
void | objectDeleted (int id_) |
The object with the given id has been deleted. delete it from the internal tree. More... | |
void | moveItem (TreeItem *_item, TreeItem *_parent) |
move the item to a new parent More... | |
void | propagateUpwards (TreeItem *_obj, int _column, bool _value) |
Recursively update a column up to the root of the tree. More... | |
void | propagateDownwards (TreeItem *_obj, int _column) |
Recursively update a column up to the root of the tree. More... | |
Definition at line 55 of file TreeModel.hh.
|
explicit |
TreeModel::~TreeModel | ( | ) |
Destructor.
Definition at line 73 of file TreeModel.cc.
int TreeModel::columnCount | ( | const QModelIndex & | _parent = QModelIndex() | ) | const |
Return the number of columns.
_parent | unused |
Definition at line 81 of file TreeModel.cc.
QVariant TreeModel::data | ( | const QModelIndex & | _index, |
int | _role | ||
) | const |
Get the data of the corresponding entry.
Returns the data stored under the given role for the item referred to by the index.
_index | a ModelIndex that defines the item in the tree |
_role | defines the kind of data requested |
Definition at line 96 of file TreeModel.cc.
Qt::ItemFlags TreeModel::flags | ( | const QModelIndex & | _index | ) | const |
return the types of the corresponding entry
Returns the item flags for the given index.
_index | ModelIndex that defines an item in the tree |
Definition at line 141 of file TreeModel.cc.
TreeItem * TreeModel::getItem | ( | const QModelIndex & | _index | ) | const |
Get the TreeItem corresponding to a given ModelIndex.
Return item at given index.
_index | a ModelIndex |
Definition at line 427 of file TreeModel.cc.
QModelIndex TreeModel::getModelIndex | ( | TreeItem * | _object, |
int | _column | ||
) |
Return the ModelIndex corresponding to a given TreeItem and Column.
Return index of given item.
Warning: Only use this function if you know that all ModelIndices are created
_object | an object |
_column | a column |
Definition at line 481 of file TreeModel.cc.
QModelIndex TreeModel::getModelIndex | ( | int | _id, |
int | _column | ||
) |
Return the ModelIndex corresponding to a given object id and Column.
Return index of given item.
Warning: Only use this function if you know that all ModelIndices are created
_id | an object id |
_column | a column |
Definition at line 502 of file TreeModel.cc.
QVariant TreeModel::headerData | ( | int | _section, |
Qt::Orientation | _orientation, | ||
int | _role = Qt::DisplayRole |
||
) | const |
return the header data of the model
Returns the data in the header.
_section | the column in the header |
_orientation | header orientation (only horizontal handled) |
_role | the role that defines the type of data |
Definition at line 174 of file TreeModel.cc.
QModelIndex TreeModel::index | ( | int | _row, |
int | _column, | ||
const QModelIndex & | _parent = QModelIndex() |
||
) | const |
Get the ModelIndex at given row,column.
Returns the index of the item in the model specified by the given row, column and parent index.
_row | the row |
_column | the column |
_parent | parent item |
Definition at line 200 of file TreeModel.cc.
bool TreeModel::isRoot | ( | TreeItem * | _item | ) |
Check if the given item is the root item.
return if an object is equal to the root object
_item | the item to be checked |
Definition at line 602 of file TreeModel.cc.
int TreeModel::itemId | ( | const QModelIndex & | _index | ) | const |
Get the id of a TreeItem corresponding to a given ModelIndex.
Return item-id at given index.
_index | a ModelIndex |
Definition at line 461 of file TreeModel.cc.
QString TreeModel::itemName | ( | const QModelIndex & | _index | ) | const |
Get the name of a TreeItem corresponding to a given ModelIndex.
Return item-name at given index.
_index | a ModelIndex |
Definition at line 444 of file TreeModel.cc.
move the item to a new parent
_item | the item |
_parent | new parent |
Definition at line 398 of file TreeModel.cc.
void TreeModel::objectAdded | ( | BaseObject * | _object | ) |
The object with the given id has been added. add it to the internal tree.
_object | The added object |
Definition at line 326 of file TreeModel.cc.
void TreeModel::objectAdded | ( | BaseObject * | _object, |
BaseObject * | _parent | ||
) |
The object with the given id has been added. add it to the internal tree.
_object | The added object |
_parent | The new parent object |
Definition at line 336 of file TreeModel.cc.
void TreeModel::objectChanged | ( | int | _id | ) |
The object with the given id has been changed. Check if model also has to be changed.
The object with the given id has been changed. Update the model.
_id | id of an object |
Definition at line 267 of file TreeModel.cc.
void TreeModel::objectDeleted | ( | int | _id | ) |
The object with the given id has been deleted. delete it from the internal tree.
_id | id of the object |
Definition at line 371 of file TreeModel.cc.
QModelIndex TreeModel::parent | ( | const QModelIndex & | _index | ) | const |
Get the parent ModelIndex.
Return index of parent item.
_index | a ModelIndex |
Definition at line 224 of file TreeModel.cc.
|
private |
Recursively update a column up to the root of the tree.
_item | item to start with |
_column | column which needs the update (1: visibility) |
Definition at line 551 of file TreeModel.cc.
|
private |
Recursively update a column up to the root of the tree.
_item | item to start with |
_column | column which needs the update (1: visibility) |
_value | value which will be assigned |
Definition at line 521 of file TreeModel.cc.
int TreeModel::rowCount | ( | const QModelIndex & | _parent = QModelIndex() | ) | const |
get the number of rows
Returns the number of rows under given parent.
_parent | parent Item |
Definition at line 246 of file TreeModel.cc.
bool TreeModel::setData | ( | const QModelIndex & | _index, |
const QVariant & | _value, | ||
int | _role | ||
) |
Set Data at 'index' to 'value'.
_index | a ModelIndex defining the positin in the model |
_value | the new value |
_role | unused |
Definition at line 586 of file TreeModel.cc.