Developer Documentation
TreeModel Class Reference
Inheritance diagram for TreeModel:

Signals

void dataChangedInside (int _id, int _column, const QVariant &_value)
 
void moveBaseObject (int _id, int _newParentId)
 
void dataChangedInside (int _id, int _column, const QVariant &_value)
 

Public Member Functions

 TreeModel (QObject *_parent=0)
 Constructor. More...
 
 ~TreeModel ()
 Destructor. More...
 
 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. 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...
 
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. More...
 
bool setData (const QModelIndex &_index, const QVariant &_value, int _role)
 Set Data at 'index' to 'value'. More...
 
Drag and Drop
Qt::DropActions supportedDropActions () const
 supported drag & Drop actions More...
 
QStringList mimeTypes () const
 stores the mimeType for Drag & Drop More...
 
QMimeData * mimeData (const QModelIndexList &indexes) const
 get the mimeData for a given ModelIndex More...
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 This is called when mimeData is dropped. More...
 

Internal DataStructure (the TreeItem Tree)

TreeItemrootItem_
 Root item of the tree. More...
 
QModelIndex getModelIndex (TreeItem *_object, int _column)
 Return the ModelIndex corresponding to a given TreeItem 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.
 
TreeItemgetItem (const QModelIndex &_index) const
 Get the TreeItem corresponding to a given ModelIndex. More...
 
TreeItemgetItem (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. 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 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...
 
QModelIndex getModelIndex (TreeItem *_object, int _column)
 Return the ModelIndex corresponding to a given TreeItem and Column.
 
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.
 
bool getObjectName (TreeItem *_object, QString &_name)
 Get the name of a given object.
 
TreeItemgetItem (const QModelIndex &_index) const
 Get the TreeItem corresponding to a given ModelIndex.
 
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 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.
 
void moveItem (TreeItem *_item, TreeItem *_parent)
 move the item to a new parent
 
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...
 

Detailed Description

Definition at line 59 of file TreeModel.hh.

Constructor & Destructor Documentation

TreeModel::TreeModel ( QObject *  _parent = 0)

Constructor.

Parameters
_parentparent Object

Definition at line 71 of file TreeModel.cc.

TreeModel::~TreeModel ( )

Destructor.

Definition at line 82 of file TreeModel.cc.

Member Function Documentation

int TreeModel::columnCount ( const QModelIndex &  _parent = QModelIndex()) const

Return the number of columns.

Parameters
_parentunused
Returns
return always 2
int TreeModel::columnCount ( const QModelIndex &  _parent = QModelIndex()) const

Return the number of columns.

Parameters
_parentunused
Returns
return always 4

Definition at line 90 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.

Parameters
_indexa ModelIndex that defines the item in the tree
_roledefines the kind of data requested
Returns
requested data

Definition at line 105 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.

Parameters
dataThe dropped data
actionThe definition of the dropAction which occurred
rowUnused
columnUnused
parentParent under which the drop occurred
Returns
returns if the drop was successful

Definition at line 669 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.

Parameters
_indexModelIndex that defines an item in the tree
Returns
flags for the given ModelIndex

Definition at line 231 of file TreeModel.cc.

TreeItem * TreeModel::getItem ( const QModelIndex &  _index) const

Get the TreeItem corresponding to a given ModelIndex.

Return item at given index.

Parameters
_indexa ModelIndex
Returns
item at given index

Definition at line 518 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

Parameters
_objectan object
_columna column
Returns
index of object and column

Definition at line 572 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

Parameters
_idan object id
_columna column
Returns
index of object and column

Definition at line 503 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.

Parameters
_sectionthe column in the header
_orientationheader orientation (only horizontal handled)
_rolethe role that defines the type of data
Returns
the requested data

Definition at line 268 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.

Parameters
_rowthe row
_columnthe column
_parentparent item
Returns
corresponding ModelIndex

Definition at line 295 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

Parameters
_itemthe item to be checked
Returns
is it the root object?

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.

Parameters
_indexa ModelIndex
Returns
item-id at given index

Definition at line 552 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.

Parameters
_indexA ModelIndex
Returns
name of the item at given index
Parameters
_indexa ModelIndex
Returns
name of the item at given index

Definition at line 535 of file TreeModel.cc.

QMimeData * TreeModel::mimeData ( const QModelIndexList &  _indexes) const

get the mimeData for a given ModelIndex

generate mimeData for given ModelIndexes

Parameters
_indexeslist of ModelIndexes
Returns
the mimeData

Definition at line 641 of file TreeModel.cc.

QStringList TreeModel::mimeTypes ( ) const

stores the mimeType for Drag & Drop

return the mimeType for drag & drop

Returns
the mimeType

Definition at line 626 of file TreeModel.cc.

void TreeModel::moveItem ( TreeItem _item,
TreeItem _parent 
)

move the item to a new parent

Parameters
_itemthe item
_parentnew parent

Definition at line 498 of file TreeModel.cc.

void TreeModel::objectAdded ( BaseObject _object)

The object with the given id has been added. add it to the internal tree.

Parameters
_objectThe added object

Definition at line 436 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.

Parameters
_objectThe added object
_parentThe new parent object

Definition at line 337 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.

Parameters
_idid of an object

Definition at line 363 of file TreeModel.cc.

void TreeModel::objectDeleted ( int  _id)

The object with the given id has been deleted. delete it from the internal tree.

Parameters
_idid of the object

Definition at line 471 of file TreeModel.cc.

QModelIndex TreeModel::parent ( const QModelIndex &  _index) const

Get the parent ModelIndex.

Return index of parent item.

Parameters
_indexa ModelIndex
Returns
parent of the given ModelIndex

Definition at line 322 of file TreeModel.cc.

void TreeModel::propagateDownwards ( TreeItem _item,
int  _column 
)
private

Recursively update a column up to the root of the tree.

Parameters
_itemitem to start with
_columncolumn which needs the update (1: visibility)

Definition at line 552 of file TreeModel.cc.

void TreeModel::propagateUpwards ( TreeItem _item,
int  _column,
bool  _value 
)
private

Recursively update a column up to the root of the tree.

Parameters
_itemitem to start with
_columncolumn which needs the update (1: visibility)
_valuevalue which will be assigned

Definition at line 522 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.

Parameters
_parentparent Item
Returns
number of rows that are children of given parent

Definition at line 344 of file TreeModel.cc.

bool TreeModel::setData ( const QModelIndex &  _index,
const QVariant &  _value,
int  _role 
)

Set Data at 'index' to 'value'.

Parameters
_indexa ModelIndex defining the positin in the model
_valuethe new value
_roleunused
Returns
return if the data was set successfully
bool TreeModel::setData ( const QModelIndex &  _index,
const QVariant &  _value,
int  _role 
)

Set Data at 'index' to 'value'.

Parameters
_indexa ModelIndex defining the positin in the model
_valuethe new value
_roleunused
Returns
return if the data was set successfully

Definition at line 585 of file TreeModel.cc.

Qt::DropActions TreeModel::supportedDropActions ( ) const

supported drag & Drop actions

return the supported drop actions

Returns
drop actions

Definition at line 614 of file TreeModel.cc.

Member Data Documentation

TreeItem * TreeModel::rootItem_
private

Root item of the tree.

Rootitem of the tree.

Definition at line 167 of file TreeModel.hh.


The documentation for this class was generated from the following files: