Loading...
Searching...
No Matches
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:

Public Member Functions

Instantiation Methods

Methods related to creation and destruction of the object.

 LayerItemModel (QObject *parent=0)
 Constructor.
 
 ~LayerItemModel ()
 Destructor.
 
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.
 
void addLayer (te::map::AbstractLayerPtr layer, const QModelIndex &parent, const std::string &idxPath="./")
 Adds the layer to the model.
 
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.
 
void addLayers (const std::list< te::map::AbstractLayerPtr > &layers, const QModelIndex &parent, const std::string &idxPath="./")
 Adds a list of layers to the model.
 
void setLayers (const std::list< te::map::AbstractLayerPtr > &layers)
 Updates the list of layers in the model.
 
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.
 
void addFolder (const std::string &name, TreeItem *parent=0)
 Adds a new folder item to the model.
 
void addFolder (const std::string &name, const QModelIndex &idx)
 Adds a new folder item to the model.
 
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.
 
std::list< te::map::AbstractLayerPtrgetVisibleLayers ()
 Returns a list with layers that are visible.
 
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
 
void removeItems (const QModelIndexList &lst)
 Removes the items in lst from the model.
 

Qt signals

Signals emitted by LayerItemModel

std::unique_ptr< TreeItemm_root
 The root item of the model.
 
void visibilityChanged ()
 Signal emited when an item visibility has changed.
 
void styleVisibilityChanged (te::map::AbstractLayerPtr layer)
 

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

◆ LayerItemModel()

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

Constructor.

Parameters
parentModel parent (Used by Qt5).

References parent().

◆ ~LayerItemModel()

te::qt::widgets::LayerItemModel::~LayerItemModel ( )

Destructor.

Member Function Documentation

◆ addFolder() [1/2]

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.

◆ addFolder() [2/2]

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.

References parent().

◆ addItems()

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.

References parent().

◆ addLayer() [1/2]

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.

References parent().

◆ addLayer() [2/2]

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.

◆ addLayers() [1/2]

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.

References parent().

◆ addLayers() [2/2]

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.

◆ canDropMimeData()

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

References canDropMimeData(), data(), and parent().

Referenced by canDropMimeData().

◆ columnCount()

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

References columnCount(), parent(), and Q_DECL_OVERRIDE.

Referenced by columnCount().

◆ data()

QVariant te::qt::widgets::LayerItemModel::data ( const QModelIndex & index,
int role ) const

References index(), and Q_DECL_OVERRIDE.

Referenced by canDropMimeData(), and dropMimeData().

◆ dropMimeData()

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

References data(), dropMimeData(), parent(), and Q_DECL_OVERRIDE.

Referenced by dropMimeData().

◆ flags()

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

References index(), and Q_DECL_OVERRIDE.

◆ getAllLayers()

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.

◆ getVisibleLayers()

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.

◆ headerData()

QVariant te::qt::widgets::LayerItemModel::headerData ( int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole ) const

References Q_DECL_OVERRIDE.

◆ index()

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

References parent(), and Q_DECL_OVERRIDE.

Referenced by data(), flags(), parent(), and setData().

◆ insertRows()

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

References insertRows(), parent(), and Q_DECL_OVERRIDE.

Referenced by insertRows().

◆ mimeData()

QMimeData * te::qt::widgets::LayerItemModel::mimeData ( const QModelIndexList & indexes) const

References mimeData(), and Q_DECL_OVERRIDE.

Referenced by mimeData().

◆ mimeTypes()

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

References mimeTypes(), and Q_DECL_OVERRIDE.

Referenced by mimeTypes().

◆ parent()

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

◆ removeItems()

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.

References removeItems().

Referenced by removeItems().

◆ removeRows()

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

References parent(), Q_DECL_OVERRIDE, and removeRows().

Referenced by removeRows().

◆ rowCount()

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

References parent(), Q_DECL_OVERRIDE, and rowCount().

Referenced by rowCount().

◆ setData()

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

References index(), Q_DECL_OVERRIDE, and setData().

Referenced by setData().

◆ setLayers()

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.

◆ styleVisibilityChanged

void te::qt::widgets::LayerItemModel::styleVisibilityChanged ( te::map::AbstractLayerPtr layer)
signal

◆ supportedDropActions()

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

◆ visibilityChanged

void te::qt::widgets::LayerItemModel::visibilityChanged ( )
signal

Signal emited when an item visibility has changed.

References visibilityChanged().

Referenced by visibilityChanged().

Member Data Documentation

◆ m_root

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

The root item of the model.

Definition at line 278 of file LayerItemModel.h.


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