TreeModel Class Reference
A tree model for the nodes.
More...
#include <treemodel.h>
List of all members.
Signals |
void | dropped (QModelIndex index) |
Public Member Functions |
| TreeModel (QObject *parent=0) |
QVariant | data (const QModelIndex &index, int role) const |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
Qt::ItemFlags | flags (const QModelIndex &index) const |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const |
QModelIndex | parent (const QModelIndex &index) const |
int | rowCount (const QModelIndex &parent=QModelIndex()) const |
int | columnCount (const QModelIndex &parent=QModelIndex()) const |
bool | insertRows (int position, int rows, const QModelIndex &parent=QModelIndex()) |
bool | removeRows (int position, int rows, const QModelIndex &parent=QModelIndex()) |
Qt::DropActions | supportedDropActions () const |
QMimeData * | mimeData (const QModelIndexList &indexes) const |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
QStringList | mimeTypes () const |
Node * | getItem (const QModelIndex &index) const |
QModelIndex | findByNodeId (int id) |
Detailed Description
A tree model for the nodes.
This model is a implementation of the QAbstractItemModel. For more informations take a look at the QT documentation.
The model is used by the TreeView.
- Author:
- Manuel Unglaub
Constructor & Destructor Documentation
TreeModel::TreeModel |
( |
QObject * |
parent = 0 |
) |
|
The constructor.
Constructs the TreeModel which is a child of parent.
- Parameters:
-
Member Function Documentation
int TreeModel::columnCount |
( |
const QModelIndex & |
parent = QModelIndex() |
) |
const |
Get the number of columns for the children of the given parent.
- Parameters:
-
| parent | The number of columns for the children under the given parent. (not used) |
- Returns:
- The number of columns for the children of the given parent. Always 1 because there is only one column at the moment.
- See also:
- rowCount()
QVariant TreeModel::data |
( |
const QModelIndex & |
index, |
|
|
int |
role | |
|
) |
| | const |
Get the caption or icon, dependent on the role, of a Node specified by the index.
- Parameters:
-
| index | The index of the requested data. |
| role | The role of the requested data. |
- Returns:
- The data stored under the given role for the item referred to by the index.
- See also:
- setData()
bool TreeModel::dropMimeData |
( |
const QMimeData * |
data, |
|
|
Qt::DropAction |
action, |
|
|
int |
row, |
|
|
int |
column, |
|
|
const QModelIndex & |
parent | |
|
) |
| | |
Handles the data supplied by a drag and drop operation that ended with the given action.
- Parameters:
-
| data | The data supplied by a drag and drop operation. |
| action | The action the drag and drop operation ended with. |
| row | The row where the drag and drop operation ended. |
| column | The column where the drag and drop operation ended. |
| parent | The parent where the drag and drop operation ended. |
- Returns:
- True if the dropping was successfull.
void TreeModel::dropped |
( |
QModelIndex |
index |
) |
[signal] |
This signal will be emitted after a successfull drop operation.
- Parameters:
-
| index | The index of the dropped node. |
QModelIndex TreeModel::findByNodeId |
( |
int |
id |
) |
|
Get the QModelIndex for a specified id.
- Parameters:
-
| id | The id of the node to look for. |
- Returns:
- The QModelIndex of the node with the provided id.
Qt::ItemFlags TreeModel::flags |
( |
const QModelIndex & |
index |
) |
const |
Returns the item flags for the given index.
- Parameters:
-
| index | The index for the requested flags. |
- Returns:
- If the index is valid a combination of the following flags: Qt::ItemIsEnabled, Qt::ItemIsSelectable, Qt::ItemIsEditable, Qt::ItemIsDragEnabled, Qt::ItemIsDropEnabled.
Node * TreeModel::getItem |
( |
const QModelIndex & |
index |
) |
const |
Get the node from a specified index.
- Parameters:
-
| index | The index of the requested Node. |
- Returns:
- The node specified by the given index.
QVariant TreeModel::headerData |
( |
int |
section, |
|
|
Qt::Orientation |
orientation, |
|
|
int |
role = Qt::DisplayRole | |
|
) |
| | const |
Returns the date for the header.
- Parameters:
-
| section | The section of the requested data. |
| orientation | The orientation of the requested data. |
| role | The role of the requested data. |
- Returns:
- The header data.
QModelIndex TreeModel::index |
( |
int |
row, |
|
|
int |
column, |
|
|
const QModelIndex & |
parent = QModelIndex() | |
|
) |
| | const |
Get a specified index.
- Parameters:
-
| row | The row of the requested index. |
| column | The column of the requested index. |
| parent | The parent of the requested index. |
- Returns:
- The requested index.
bool TreeModel::insertRows |
( |
int |
position, |
|
|
int |
rows, |
|
|
const QModelIndex & |
parent = QModelIndex() | |
|
) |
| | |
Insert rows at a specified position to a given parent.
- Parameters:
-
| position | The position in the list of children of the parent. |
| rows | The number of rows to insert. |
| parent | The parent to insert the rows. |
- Returns:
- True if successfull.
- See also:
- removeRows()
QMimeData * TreeModel::mimeData |
( |
const QModelIndexList & |
indexes |
) |
const |
Returns an object that contains serialized items of data corresponding to the list of indexes specified. The formats used to describe the encoded data is obtained from the mimeTypes() function.
- Parameters:
-
| indexes | The indexes that will be serialized. |
- Returns:
- The object that contains serialized items of data.
QStringList TreeModel::mimeTypes |
( |
|
) |
const |
Get a list of MIME types that can be used to describe a list of model indexes.
- Returns:
- A list of MIME types that can be used to describe a list of model indexes.
QModelIndex TreeModel::parent |
( |
const QModelIndex & |
index |
) |
const |
Get the parent of a specified index.
- Parameters:
-
| index | The child of the requested index. |
- Returns:
- The parent index of the specified index.
bool TreeModel::removeRows |
( |
int |
position, |
|
|
int |
rows, |
|
|
const QModelIndex & |
parent = QModelIndex() | |
|
) |
| | |
Remove rows at a specified position from a given parent.
- Parameters:
-
| position | The position in th list of children of the parent. |
| rows | The number of rows to remove. |
| parent | The parent to remove the rows from. |
- Returns:
- True if successfull.
- See also:
- insertRows()
int TreeModel::rowCount |
( |
const QModelIndex & |
parent = QModelIndex() |
) |
const |
Get the number of children of a specified index.
- Parameters:
-
| parent | The index for the request of the number of its children. |
- Returns:
- The number of rows under the given parent.
- See also:
- columnCount()
bool TreeModel::setData |
( |
const QModelIndex & |
index, |
|
|
const QVariant & |
value, |
|
|
int |
role = Qt::EditRole | |
|
) |
| | |
Sets the role data for the item at index to value. The dataChanged() signal will be emitted if the data was successfully set.
- Parameters:
-
| index | The index of the Node. |
| value | The caption for the Node. |
| role | The role the data is for. Only Qt::EditRole will have any effect. |
- Returns:
- True if successfull.
- See also:
- data()
Qt::DropActions TreeModel::supportedDropActions |
( |
|
) |
const |
Find out which drop actions are supported by this model.
- Returns:
- The drop actions supported by this model.
The documentation for this class was generated from the following files:
- src/data/model/treemodel.h
- src/data/model/treemodel.cpp