Defines an abstract model based on TreeItem objects. More...
#include <LayerItemModel.h>
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::AbstractLayerPtr > | getAllLayers () |
Get all layers contained in the model. Commonly used for persistent pourposes. More... | |
std::list< te::map::AbstractLayerPtr > | getVisibleLayers () |
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< TreeItem > | m_root |
The root item of the model. More... | |
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.
Definition at line 69 of file LayerItemModel.h.
|
explicit |
Constructor.
parent | Model parent (Used by Qt5). |
te::qt::widgets::LayerItemModel::~LayerItemModel | ( | ) |
Destructor.
void te::qt::widgets::LayerItemModel::addFolder | ( | const std::string & | name, |
TreeItem * | parent = 0 |
||
) |
Adds a new folder item to the model.
name | Label of the folder. |
parent | Parent 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.
name | Label of the folder. |
idx | The 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.
items | The items to be reparent. |
parent | The new parent, where the items must be inserted. |
pos | The position where the items must be inserted. |
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.
layer | The layer to be added. |
idxPath | Unused. |
void te::qt::widgets::LayerItemModel::addLayer | ( | te::map::AbstractLayerPtr | layer, |
const QModelIndex & | parent, | ||
const std::string & | idxPath = "./" |
||
) |
Adds the layer to the model.
layer | Layer to be added. |
parent | Parent of the new LayerItem. |
idxPath | Unused. |
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.
layers | The layer list to be added. |
idxPath | Unused. |
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.
layers | The layer list to be added. |
parent | The parent of the new LayerItems. |
idxPath | Unused. |
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.
std::list<te::map::AbstractLayerPtr> te::qt::widgets::LayerItemModel::getVisibleLayers | ( | ) |
Returns a list with layers that are visible.
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.
lst | List 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.
layers | The new set of layers to be set to the model. |
Qt::DropActions te::qt::widgets::LayerItemModel::supportedDropActions | ( | ) | const |
|
signal |
Signal emited when an item visibility has changed.
|
protected |
The root item of the model.
Definition at line 276 of file LayerItemModel.h.