All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
te::qt::widgets::LayerTreeModel Class Reference

#include <LayerTreeModel.h>

Inheritance diagram for te::qt::widgets::LayerTreeModel:

Signals

void layerOrderChanged ()
 
void visibilityChanged (const te::map::AbstractLayerPtr &layer)
 

Public Member Functions

void add (const te::map::AbstractLayerPtr &layer, AbstractTreeItem *parentItem=0)
 It adds a item layer to the list of item layers of the parent layer item. If the parent layer is not specified, the item layer is added as a top layer item. More...
 
bool canFetchMore (const QModelIndex &parent) const
 It fetches more data for the given parent. More...
 
int columnCount (const QModelIndex &parent=QModelIndex()) const
 It returns the number of columns for the children of the given parent. More...
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const
 It returns the data stored under the given role for the item referred to by the index. More...
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 It handles the data supplied by a drag and drop operation that ended with the given action. More...
 
void fetchMore (const QModelIndex &parent)
 It fetches any available data for the items with the parent specified by the parent index. More...
 
Qt::ItemFlags flags (const QModelIndex &index) const
 It returns the item flags for the given index. More...
 
QModelIndex getIndex (AbstractTreeItem *item)
 It gets the index that is associated to the given item. More...
 
te::qt::widgets::AbstractTreeItemgetLayerItem (const te::map::AbstractLayerPtr &layer)
 It gets the layer item that is associated to the given layer. More...
 
const std::vector
< te::qt::widgets::AbstractTreeItem * > & 
getTopLayerItems () const
 It gets the top level layer items of the model. More...
 
const std::vector
< te::map::AbstractLayerPtr > & 
getTopLayers () const
 It gets the top level layers of the model. More...
 
bool hasChildren (const QModelIndex &parent=QModelIndex()) const
 It checks if the given index has children. More...
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 It returns the index of the item in the model specified by the given row, column and parent index. More...
 
bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex())
 It inserts a determined number of rows given by the "count" parameter, starting with the given row under the parent "parent" from the model. More...
 
bool isCheckable () const
 It verifies if the model items are checkable or not. More...
 
 LayerTreeModel (QObject *parent=0)
 It constructs a layer tree model with the given parent. More...
 
 LayerTreeModel (const std::list< te::map::AbstractLayerPtr > &layers, QObject *parent=0)
 It constructs a layer tree model with the given parent. More...
 
QMimeData * mimeData (const QModelIndexList &indexes) const
 It 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. More...
 
QStringList mimeTypes () const
 It returns a list of MIME types that can be used to describe a list of model indexes. More...
 
QModelIndex parent (const QModelIndex &index) const
 It returns the item parent of the given index, or QModelIndex(), if it has no parent. More...
 
bool remove (AbstractTreeItem *item)
 It removes a item from the model. More...
 
bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex())
 It removes a determined number of rows given by the "count" parameter, starting with the given row under parent "parent" from the model. More...
 
int rowCount (const QModelIndex &parent=QModelIndex()) const
 It returns the number of rows of the given parent. More...
 
void set (const std::list< te::map::AbstractLayerPtr > &layers)
 It resets the model and associates the new top level items to the given top level layers. More...
 
void setCheckable (const bool checkable)
 It sets the model items as checkable or not. More...
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
 It sets the role data for the item at index to value. More...
 
Qt::DropActions supportedDropActions () const
 It returns the drop actions supported by this model. More...
 
 ~LayerTreeModel ()
 

Protected Member Functions

void emitDataChangedForAncestors (const QModelIndex &index)
 It emits the dataChanged signal for the indexes that are ancestors of the given index. More...
 
void emitDataChangedForDescendants (const QModelIndex &parent)
 It emits the dataChanged signal for the descendants indexes of the given index. More...
 
void removeLayerFromParentChildrenList (std::vector< te::map::AbstractLayerPtr > &layers)
 It removes the given layers from the list of children of their parents. More...
 

Private Attributes

bool m_checkable
 It informs if the model is checkable. More...
 
std::vector
< te::map::AbstractLayerPtr
m_insertingLayers
 The list of layers to be inserted. More...
 
std::vector< AbstractTreeItem * > m_items
 The list of top level items. More...
 
std::vector
< te::map::AbstractLayerPtr
m_layers
 The list of top level layers. More...
 

Detailed Description

Definition at line 47 of file LayerTreeModel.h.

Constructor & Destructor Documentation

te::qt::widgets::LayerTreeModel::LayerTreeModel ( QObject *  parent = 0)

It constructs a layer tree model with the given parent.

Parameters
parentThe parent object of the layer tree model.

Definition at line 41 of file LayerTreeModel.cpp.

te::qt::widgets::LayerTreeModel::LayerTreeModel ( const std::list< te::map::AbstractLayerPtr > &  layers,
QObject *  parent = 0 
)

It constructs a layer tree model with the given parent.

Parameters
layersThe layers that will be associated to the layer items of the layer tree model.
parentThe parent object of the layer tree model.

Definition at line 50 of file LayerTreeModel.cpp.

te::qt::widgets::LayerTreeModel::~LayerTreeModel ( )

Destructor

Definition at line 59 of file LayerTreeModel.cpp.

References te::common::FreeContents().

Member Function Documentation

void te::qt::widgets::LayerTreeModel::add ( const te::map::AbstractLayerPtr layer,
AbstractTreeItem parentItem = 0 
)

It adds a item layer to the list of item layers of the parent layer item. If the parent layer is not specified, the item layer is added as a top layer item.

Parameters
layerThe layer that will be associated to the item layer to be added.
parentItemThe parent item where the layer item will be added.

Definition at line 661 of file LayerTreeModel.cpp.

bool te::qt::widgets::LayerTreeModel::canFetchMore ( const QModelIndex &  parent) const

It fetches more data for the given parent.

Parameters
parentThe object used to fetch more data.
Returns
It returns true if there is more data available for parent.

Definition at line 97 of file LayerTreeModel.cpp.

References te::qt::widgets::AbstractTreeItem::canFetchMore().

int te::qt::widgets::LayerTreeModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const

It returns the number of columns for the children of the given parent.

Parameters
parentThe parent index.
Returns
The number of columns for the children of the given parent.

Definition at line 120 of file LayerTreeModel.cpp.

QVariant te::qt::widgets::LayerTreeModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const

It returns the data stored under the given role for the item referred to by the index.

Parameters
indexThe item index.
roleThe role that is used by the view to indicate to the model which type of data it needs.
Returns
The data stored under the given role for the item referred to by the index.

Definition at line 226 of file LayerTreeModel.cpp.

References te::qt::widgets::AbstractTreeItem::data().

bool te::qt::widgets::LayerTreeModel::dropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
)

It handles the data supplied by a drag and drop operation that ended with the given action.

Parameters
dataThe object containing serialized items of data.
actionThe action associated by the drag and drop operation.
rowThe item row in the model where the operation ended.
columnThe item column in the model where the operation ended.
parentThe item parent in the model where the operation ended.
Returns
It returns true if the data and action can be handled by the model; otherwise, it returns false.

Definition at line 327 of file LayerTreeModel.cpp.

References te::qt::widgets::AbstractTreeItem::getLayer(), and te::qt::widgets::AbstractTreeItem::hasChildren().

void te::qt::widgets::LayerTreeModel::emitDataChangedForAncestors ( const QModelIndex &  index)
protected

It emits the dataChanged signal for the indexes that are ancestors of the given index.

Parameters
indexThe item index whose ancestors will have the dataChanged signal emitted.

Definition at line 752 of file LayerTreeModel.cpp.

void te::qt::widgets::LayerTreeModel::emitDataChangedForDescendants ( const QModelIndex &  parent)
protected

It emits the dataChanged signal for the descendants indexes of the given index.

Parameters
parentThe item index whose descendants will have the dataChanged signal emitted.

Definition at line 734 of file LayerTreeModel.cpp.

void te::qt::widgets::LayerTreeModel::fetchMore ( const QModelIndex &  parent)

It fetches any available data for the items with the parent specified by the parent index.

Parameters
parentThe object used to fetch available data.

Definition at line 107 of file LayerTreeModel.cpp.

References te::qt::widgets::AbstractTreeItem::fetchMore(), and TE_TR.

Qt::ItemFlags te::qt::widgets::LayerTreeModel::flags ( const QModelIndex &  index) const

It returns the item flags for the given index.

Parameters
indexThe item index.
Returns
The item flags for the given index.

Definition at line 213 of file LayerTreeModel.cpp.

References te::qt::widgets::AbstractTreeItem::flags(), and TE_TR.

QModelIndex te::qt::widgets::LayerTreeModel::getIndex ( AbstractTreeItem item)

It gets the index that is associated to the given item.

Parameters
itemThe item whose index will be returned.
Returns
The index that is associated to the item.

Definition at line 580 of file LayerTreeModel.cpp.

te::qt::widgets::AbstractTreeItem * te::qt::widgets::LayerTreeModel::getLayerItem ( const te::map::AbstractLayerPtr layer)

It gets the layer item that is associated to the given layer.

Parameters
layerThe layer whose the corresponding layer item will be returned.
Returns
The layer item associated to the layer.

Definition at line 608 of file LayerTreeModel.cpp.

const std::vector< te::qt::widgets::AbstractTreeItem * > & te::qt::widgets::LayerTreeModel::getTopLayerItems ( ) const

It gets the top level layer items of the model.

Parameters
layersThe top level layer items of the model.

Definition at line 92 of file LayerTreeModel.cpp.

const std::vector< te::map::AbstractLayerPtr > & te::qt::widgets::LayerTreeModel::getTopLayers ( ) const

It gets the top level layers of the model.

Parameters
layersThe top level layers of the model.

Definition at line 87 of file LayerTreeModel.cpp.

bool te::qt::widgets::LayerTreeModel::hasChildren ( const QModelIndex &  parent = QModelIndex()) const

It checks if the given index has children.

Parameters
parentThe item index.
Returns
It returns true if the given index has children.

Definition at line 270 of file LayerTreeModel.cpp.

References te::qt::widgets::AbstractTreeItem::hasChildren(), and TE_TR.

QModelIndex te::qt::widgets::LayerTreeModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const

It returns the index of the item in the model specified by the given row, column and parent index.

It will call createIndex() to generate model indexes that other components can use to refer to items in the model.

Parameters
rowThe item row.
columnThe item column.
parentThe parent index of the item.
Returns
The item index.

Definition at line 138 of file LayerTreeModel.cpp.

References TE_TR.

bool te::qt::widgets::LayerTreeModel::insertRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)

It inserts a determined number of rows given by the "count" parameter, starting with the given row under the parent "parent" from the model.

Parameters
rowThe initial row.
countThe number of rows to be inserted.
parentThe parent of the rows to be inserted.
Returns
True, if the rows were successfully inserted; otherwise, it returns false.

Definition at line 462 of file LayerTreeModel.cpp.

References te::qt::widgets::AbstractTreeItemFactory::make().

bool te::qt::widgets::LayerTreeModel::isCheckable ( ) const

It verifies if the model items are checkable or not.

Returns
It returns true if the model items are checkable.

Definition at line 575 of file LayerTreeModel.cpp.

Referenced by te::qt::widgets::LayerTreeView::onItemClicked().

void te::qt::widgets::LayerTreeModel::layerOrderChanged ( )
signal
QMimeData * te::qt::widgets::LayerTreeModel::mimeData ( const QModelIndexList &  indexes) const

It 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
indexesThe list of indexes that was dragged.
Returns
An object containing serialized items of data corresponding to the list of indexes specified. If the list of indexes is empty, or there are no supported MIME types, 0 is returned rather than a serialized empty list.

Definition at line 305 of file LayerTreeModel.cpp.

QStringList te::qt::widgets::LayerTreeModel::mimeTypes ( ) const

It returns a list of MIME types that can be used to describe a list of model indexes.

Returns
The list of MIME types that can be used to describe a list of model indexes.

Definition at line 283 of file LayerTreeModel.cpp.

QModelIndex te::qt::widgets::LayerTreeModel::parent ( const QModelIndex &  index) const

It returns the item parent of the given index, or QModelIndex(), if it has no parent.

Parameters
indexThe item index.
Returns
The parent index of the item with the given index, or QModelIndex(), if it has no parent.

Definition at line 170 of file LayerTreeModel.cpp.

References TE_TR.

bool te::qt::widgets::LayerTreeModel::remove ( AbstractTreeItem item)

It removes a item from the model.

Parameters
itemThe item to be removed from the model.
Returns
True, if the item was successfully removed; otherwise, it returns false.

Definition at line 684 of file LayerTreeModel.cpp.

References te::qt::widgets::AbstractTreeItem::getLayer().

void te::qt::widgets::LayerTreeModel::removeLayerFromParentChildrenList ( std::vector< te::map::AbstractLayerPtr > &  layers)
protected

It removes the given layers from the list of children of their parents.

Parameters
layersThe layers that will be removed from the list of children of their parents.

Definition at line 713 of file LayerTreeModel.cpp.

References te::common::TreeItem::remove().

bool te::qt::widgets::LayerTreeModel::removeRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)

It removes a determined number of rows given by the "count" parameter, starting with the given row under parent "parent" from the model.

Parameters
rowThe initial row.
countThe number of rows to be removed.
parentThe parent of the rows to be removed.
Returns
It returns true if the rows were successfully removed; otherwise, it returns false.

Definition at line 519 of file LayerTreeModel.cpp.

References te::qt::widgets::AbstractTreeItem::getLayer().

int te::qt::widgets::LayerTreeModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const

It returns the number of rows of the given parent.

Parameters
parentThe parent index.
Returns
The number of rows of the given parent.

Definition at line 125 of file LayerTreeModel.cpp.

References TE_TR.

void te::qt::widgets::LayerTreeModel::set ( const std::list< te::map::AbstractLayerPtr > &  layers)

It resets the model and associates the new top level items to the given top level layers.

Parameters
layersThe list of top level layers that will be associated to the new top level items.

Definition at line 64 of file LayerTreeModel.cpp.

References te::common::FreeContents(), and te::qt::widgets::AbstractTreeItemFactory::make().

void te::qt::widgets::LayerTreeModel::setCheckable ( const bool  checkable)

It sets the model items as checkable or not.

Parameters
checkableFlag that indicates if the model items are checkable.

Definition at line 570 of file LayerTreeModel.cpp.

Referenced by te::qt::widgets::LayerExplorer::LayerExplorer().

bool te::qt::widgets::LayerTreeModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)

It sets the role data for the item at index to value.

Parameters
indexThe item index.
valueThe value to be assigned to the item.
roleThe role used.
Returns
It returns true if successful; otherwise, it returns false.
Note
The dataChanged() signal is emitted if the data was successfully set.

Definition at line 242 of file LayerTreeModel.cpp.

References te::qt::widgets::AbstractTreeItem::setData().

Qt::DropActions te::qt::widgets::LayerTreeModel::supportedDropActions ( ) const

It returns the drop actions supported by this model.

Returns
The drop actions supported by this model.

Definition at line 292 of file LayerTreeModel.cpp.

void te::qt::widgets::LayerTreeModel::visibilityChanged ( const te::map::AbstractLayerPtr layer)
signal

Member Data Documentation

bool te::qt::widgets::LayerTreeModel::m_checkable
private

It informs if the model is checkable.

Definition at line 342 of file LayerTreeModel.h.

std::vector<te::map::AbstractLayerPtr> te::qt::widgets::LayerTreeModel::m_insertingLayers
private

The list of layers to be inserted.

Definition at line 341 of file LayerTreeModel.h.

std::vector<AbstractTreeItem*> te::qt::widgets::LayerTreeModel::m_items
private

The list of top level items.

Definition at line 339 of file LayerTreeModel.h.

std::vector<te::map::AbstractLayerPtr> te::qt::widgets::LayerTreeModel::m_layers
private

The list of top level layers.

Definition at line 340 of file LayerTreeModel.h.


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