te::qt::widgets::LayerItemModel Class Reference

Defines an abstract model based on TreeItem objects. More...

#include <LayerItemModel.h>

Inheritance diagram for te::qt::widgets::LayerItemModel:

Signals

Qt signals

Signals emitted by LayerItemModel

void visibilityChanged ()
 Signal emited when an item visibility has changed. More...
 

Public Member Functions

void removeItems (const QModelIndexList &lst)
 Removes the items in lst from the model. More...
 
Instantiation Methods

Methods related to creation and destruction of the object.

 LayerItemModel (QObject *parent=0)
 Constructor. More...
 
 ~LayerItemModel ()
 Destructor. More...
 
Update Methods

Methods used for feed the model.

void addLayer (te::map::AbstractLayerPtr layer, const std::string &idxPath="./")
 Adds a layer to the model at the end of children list. More...
 
void addLayer (te::map::AbstractLayerPtr layer, const QModelIndex &parent, const std::string &idxPath="./")
 Adds the layer to the model. More...
 
void addLayers (const std::list< te::map::AbstractLayerPtr > &layers, const std::string &idxPath="./")
 Adds a list of layers to the model at the end of children list. More...
 
void addLayers (const std::list< te::map::AbstractLayerPtr > &layers, const QModelIndex &parent, const std::string &idxPath="./")
 Adds a list of layers to the model. More...
 
void setLayers (const std::list< te::map::AbstractLayerPtr > &layers)
 Updates the list of layers in the model. More...
 
void addItems (const std::vector< TreeItem * > items, TreeItem *parent, const int &pos=0)
 Adds the set of items to the parent at the position pos. More...
 
void addFolder (const std::string &name, TreeItem *parent=0)
 Adds a new folder item to the model. More...
 
void addFolder (const std::string &name, const QModelIndex &idx)
 Adds a new folder item to the model. More...
 
Getter Methods

Methods used for get items from the model.

std::list< te::map::AbstractLayerPtrgetAllLayers ()
 Get all layers contained in the model. Commonly used for persistent pourposes. More...
 
std::list< te::map::AbstractLayerPtrgetVisibleLayers ()
 Returns a list with layers that are visible. More...
 
Reimplementation of QAbstractItemModel

Methods reimplemented of the QAbstractItemModel class.

QVariant data (const QModelIndex &index, int role) const Q_DECL_OVERRIDE
 
Qt::ItemFlags flags (const QModelIndex &index) const Q_DECL_OVERRIDE
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const Q_DECL_OVERRIDE
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
 
QModelIndex parent (const QModelIndex &index) const Q_DECL_OVERRIDE
 
int rowCount (const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
 
int columnCount (const QModelIndex &parent=QModelIndex()) const Q_DECL_OVERRIDE
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) Q_DECL_OVERRIDE
 
bool removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) Q_DECL_OVERRIDE
 
bool insertRows (int row, int count, const QModelIndex &parent=QModelIndex()) Q_DECL_OVERRIDE
 
Qt::DropActions supportedDropActions () const Q_DECL_OVERRIDE
 
QStringList mimeTypes () const Q_DECL_OVERRIDE
 
QMimeData * mimeData (const QModelIndexList &indexes) const Q_DECL_OVERRIDE
 
bool canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE
 

Protected Attributes

std::auto_ptr< TreeItemm_root
 The root item of the model. More...
 

Detailed Description

Defines an abstract model based on TreeItem objects.

Models are used by the item views of the Qt5 that represents some data structure. Its used for manipulate models using a view. This is part of the Model / View framework of the Qt5.

See also
TreeItem, te::map::AbstractLayer

Definition at line 69 of file LayerItemModel.h.

Constructor & Destructor Documentation

te::qt::widgets::LayerItemModel::LayerItemModel ( QObject *  parent = 0)
explicit

Constructor.

Parameters
parentModel parent (Used by Qt5).
te::qt::widgets::LayerItemModel::~LayerItemModel ( )

Destructor.

Member Function Documentation

void te::qt::widgets::LayerItemModel::addFolder ( const std::string &  name,
TreeItem parent = 0 
)

Adds a new folder item to the model.

Parameters
nameLabel of the folder.
parentParent item. If this value is "0" the folder is added to the root of the model.
void te::qt::widgets::LayerItemModel::addFolder ( const std::string &  name,
const QModelIndex &  idx 
)

Adds a new folder item to the model.

Parameters
nameLabel of the folder.
idxThe parent of the new FolderItem.
void te::qt::widgets::LayerItemModel::addItems ( const std::vector< TreeItem * >  items,
TreeItem parent,
const int &  pos = 0 
)

Adds the set of items to the parent at the position pos.

These methods is used when you needs to reparent some items. It is a common operation on the view, like a drag and drop operation, for example. The items are removed from its parents and added in the parent, as children.

Parameters
itemsThe items to be reparent.
parentThe new parent, where the items must be inserted.
posThe position where the items must be inserted.
Note
If pos is greater than the size of the list of children, items are, then, added to end of the list of children.
If you want to add items to the root, try to pass "0" as value for parent argument.
void te::qt::widgets::LayerItemModel::addLayer ( te::map::AbstractLayerPtr  layer,
const std::string &  idxPath = "./" 
)

Adds a layer to the model at the end of children list.

Parameters
layerThe layer to be added.
idxPathUnused.
void te::qt::widgets::LayerItemModel::addLayer ( te::map::AbstractLayerPtr  layer,
const QModelIndex &  parent,
const std::string &  idxPath = "./" 
)

Adds the layer to the model.

Parameters
layerLayer to be added.
parentParent of the new LayerItem.
idxPathUnused.
void te::qt::widgets::LayerItemModel::addLayers ( const std::list< te::map::AbstractLayerPtr > &  layers,
const std::string &  idxPath = "./" 
)

Adds a list of layers to the model at the end of children list.

Parameters
layersThe layer list to be added.
idxPathUnused.
void te::qt::widgets::LayerItemModel::addLayers ( const std::list< te::map::AbstractLayerPtr > &  layers,
const QModelIndex &  parent,
const std::string &  idxPath = "./" 
)

Adds a list of layers to the model.

Parameters
layersThe layer list to be added.
parentThe parent of the new LayerItems.
idxPathUnused.
bool te::qt::widgets::LayerItemModel::canDropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
)
int te::qt::widgets::LayerItemModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
QVariant te::qt::widgets::LayerItemModel::data ( const QModelIndex &  index,
int  role 
) const
bool te::qt::widgets::LayerItemModel::dropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
)
Qt::ItemFlags te::qt::widgets::LayerItemModel::flags ( const QModelIndex &  index) const
std::list<te::map::AbstractLayerPtr> te::qt::widgets::LayerItemModel::getAllLayers ( )

Get all layers contained in the model. Commonly used for persistent pourposes.

Returns
A list with all layers containded in the model.
std::list<te::map::AbstractLayerPtr> te::qt::widgets::LayerItemModel::getVisibleLayers ( )

Returns a list with layers that are visible.

Returns
List of visible layers.
Note
Folder layers are not contained in the returned list.
QVariant te::qt::widgets::LayerItemModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
QModelIndex te::qt::widgets::LayerItemModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
bool te::qt::widgets::LayerItemModel::insertRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)
QMimeData* te::qt::widgets::LayerItemModel::mimeData ( const QModelIndexList &  indexes) const
QStringList te::qt::widgets::LayerItemModel::mimeTypes ( ) const
QModelIndex te::qt::widgets::LayerItemModel::parent ( const QModelIndex &  index) const
void te::qt::widgets::LayerItemModel::removeItems ( const QModelIndexList &  lst)

Removes the items in lst from the model.

Parameters
lstList of indexes of the items to be removed.
bool te::qt::widgets::LayerItemModel::removeRows ( int  row,
int  count,
const QModelIndex &  parent = QModelIndex() 
)
int te::qt::widgets::LayerItemModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
bool te::qt::widgets::LayerItemModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
void te::qt::widgets::LayerItemModel::setLayers ( const std::list< te::map::AbstractLayerPtr > &  layers)

Updates the list of layers in the model.

Parameters
layersThe new set of layers to be set to the model.
Note
Older items are removed from the model.
Qt::DropActions te::qt::widgets::LayerItemModel::supportedDropActions ( ) const
void te::qt::widgets::LayerItemModel::visibilityChanged ( )
signal

Signal emited when an item visibility has changed.

Member Data Documentation

std::auto_ptr<TreeItem> te::qt::widgets::LayerItemModel::m_root
protected

The root item of the model.

Definition at line 276 of file LayerItemModel.h.


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