|
Developer Documentation
|
Signals | |
| void | dataChangedInside (int _id, int _column, const QVariant &_value) |
| void | moveBaseObject (int _id, int _newParentId) |
Public Member Functions | |
| TreeModel (QObject *_parent=0) | |
| Constructor. | |
| ~TreeModel () | |
| Destructor. | |
inherited from QAbstractItemModel | |
| QVariant | data (const QModelIndex &_index, int _role) const |
| Get the data of the corresponding entry. | |
| Qt::ItemFlags | flags (const QModelIndex &_index) const |
| return the types of the corresponding entry | |
| QVariant | headerData (int _section, Qt::Orientation _orientation, int _role=Qt::DisplayRole) const |
| return the header data of the model | |
| QModelIndex | index (int _row, int _column, const QModelIndex &_parent=QModelIndex()) const |
| Get the ModelIndex at given row,column. | |
| QModelIndex | parent (const QModelIndex &_index) const |
| Get the parent ModelIndex. | |
| int | rowCount (const QModelIndex &_parent=QModelIndex()) const |
| get the number of rows | |
| int | columnCount (const QModelIndex &_parent=QModelIndex()) const |
| Return the number of columns. | |
| bool | setData (const QModelIndex &_index, const QVariant &_value, int _role) |
| Set Data at 'index' to 'value'. | |
Drag and Drop | |
| Qt::DropActions | supportedDropActions () const |
| supported drag & Drop actions | |
| QStringList | mimeTypes () const |
| stores the mimeType for Drag & Drop | |
| QMimeData * | mimeData (const QModelIndexList &indexes) const |
| get the mimeData for a given ModelIndex | |
| bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
| This is called when mimeData is dropped. | |
Internal DataStructure (the TreeItem Tree) | |
| TreeItem * | rootItem_ |
| Root item of the tree. | |
| QModelIndex | getModelIndex (TreeItem *_object, int _column) |
| Return the ModelIndex corresponding to a given TreeItem and Column. | |
| bool | isRoot (TreeItem *_item) |
| Check if the given item is the root item. | |
| 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. | |
| TreeItem * | getItem (const int _id) const |
| Get the TreeItem corresponding to a given OpenFlipper ObjectID. | |
| QString | itemName (const QModelIndex &_index) const |
| Get the name of a TreeItem corresponding to a given ModelIndex. | |
| int | itemId (const QModelIndex &_index) const |
| Get the id of a TreeItem corresponding to a given ModelIndex. | |
| void | objectChanged (int _id) |
| The object with the given id has been changed. Check if model also has to be changed. | |
| void | objectAdded (BaseObject *_object) |
| The object with the given id has been added. add it to the internal tree. | |
| void | objectDeleted (int _id) |
| The object with the given id has been deleted. delete it from the internal tree. | |
| void | moveItem (TreeItem *_item, TreeItem *_parent) |
| move the item to a new parent | |
Definition at line 53 of file TreeModel.hh.
|
explicit |
| TreeModel::~TreeModel | ( | ) |
Destructor.
Definition at line 72 of file TreeModel.cc.
| int TreeModel::columnCount | ( | const QModelIndex & | _parent = QModelIndex() | ) | const |
Return the number of columns.
| _parent | unused |
Definition at line 80 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 95 of file TreeModel.cc.
| bool TreeModel::dropMimeData | ( | const QMimeData * | data, |
| Qt::DropAction | action, | ||
| int | row, | ||
| int | column, | ||
| const QModelIndex & | parent | ||
| ) |
This is called when mimeData is dropped.
| data | The dropped data |
| action | The definition of the dropAction which occurred |
| row | Unused |
| column | Unused |
| parent | Parent under which the drop occurred |
Definition at line 668 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 221 of file TreeModel.cc.
| TreeItem * TreeModel::getItem | ( | const int | _id | ) | const |
Get the TreeItem corresponding to a given OpenFlipper ObjectID.
Definition at line 711 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 517 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 571 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 267 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 294 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 601 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 551 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 534 of file TreeModel.cc.
| QMimeData * TreeModel::mimeData | ( | const QModelIndexList & | _indexes | ) | const |
get the mimeData for a given ModelIndex
generate mimeData for given ModelIndexes
| _indexes | list of ModelIndexes |
Definition at line 640 of file TreeModel.cc.
| QStringList TreeModel::mimeTypes | ( | ) | const |
stores the mimeType for Drag & Drop
return the mimeType for drag & drop
Definition at line 625 of file TreeModel.cc.
move the item to a new parent
| _item | the item |
| _parent | new parent |
Definition at line 497 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 435 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 362 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 470 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 321 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 343 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 584 of file TreeModel.cc.
| Qt::DropActions TreeModel::supportedDropActions | ( | ) | const |
supported drag & Drop actions
return the supported drop actions
Definition at line 613 of file TreeModel.cc.
|
private |
Root item of the tree.
Definition at line 161 of file TreeModel.hh.