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... | |
| void | styleVisibilityChanged (te::map::AbstractLayerPtr layer) |
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::unique_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). |
Definition at line 194 of file LayerItemModel.cpp.
References m_root, and ~LayerItemModel().
|
default |
Destructor.
Referenced by LayerItemModel().
| 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. |
Definition at line 333 of file LayerItemModel.cpp.
References FindIndex().
Referenced by te::qt::widgets::LayerItemView::addFolder().
| 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. |
Definition at line 338 of file LayerItemModel.cpp.
References FindInsertInformation(), te::qt::widgets::TreeItem::insertChild(), and m_root.
| 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. |
Definition at line 280 of file LayerItemModel.cpp.
References CleanRemoveList(), FindIndex(), te::qt::widgets::TreeItem::getChildrenCount(), te::qt::widgets::TreeItem::getParent(), te::qt::widgets::TreeItem::getPosition(), te::qt::widgets::TreeItem::insertChild(), m_root, parent(), and te::qt::widgets::TreeItem::removeChild().
Referenced by dropMimeData().
| 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. |
Definition at line 207 of file LayerItemModel.cpp.
| 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. |
Definition at line 212 of file LayerItemModel.cpp.
References FindInsertInformation(), GetFolder(), te::qt::widgets::TreeItem::insertChild(), m_root, and te::qt::widgets::TreeItemFactory::make().
| 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. |
Definition at line 226 of file LayerItemModel.cpp.
Referenced by te::qt::widgets::LayerItemView::addLayers(), and setLayers().
| 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. |
Definition at line 231 of file LayerItemModel.cpp.
References FindInsertInformation(), GetFolder(), GetRootFolder(), te::qt::widgets::TreeItem::hasChildren(), te::qt::widgets::TreeItem::insertChild(), m_root, te::qt::widgets::TreeItemFactory::make(), te::common::TaskProgress::pulse(), te::common::TaskProgress::setTotalSteps(), and TE_TR.
| bool te::qt::widgets::LayerItemModel::canDropMimeData | ( | const QMimeData * | data, |
| Qt::DropAction | action, | ||
| int | row, | ||
| int | column, | ||
| const QModelIndex & | parent | ||
| ) |
Definition at line 502 of file LayerItemModel.cpp.
Referenced by dropMimeData().
| int te::qt::widgets::LayerItemModel::columnCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Definition at line 379 of file LayerItemModel.cpp.
| QVariant te::qt::widgets::LayerItemModel::data | ( | const QModelIndex & | index, |
| int | role | ||
| ) | const |
Definition at line 568 of file LayerItemModel.cpp.
References te::qt::widgets::TreeItem::flags(), te::qt::widgets::TreeItem::getAsString(), te::qt::widgets::TreeItem::getToolTip(), te::qt::widgets::TreeItem::isVisible(), te::qt::widgets::NONE, parent(), te::qt::widgets::PARTIALLY, and rowCount().
Referenced by index().
| bool te::qt::widgets::LayerItemModel::dropMimeData | ( | const QMimeData * | data, |
| Qt::DropAction | action, | ||
| int | row, | ||
| int | column, | ||
| const QModelIndex & | parent | ||
| ) |
Definition at line 517 of file LayerItemModel.cpp.
References addItems(), canDropMimeData(), FindInsertInformation(), and m_root.
| Qt::ItemFlags te::qt::widgets::LayerItemModel::flags | ( | const QModelIndex & | index | ) | const |
Definition at line 597 of file LayerItemModel.cpp.
References te::qt::widgets::TreeItem::flags().
| std::list< te::map::AbstractLayerPtr > te::qt::widgets::LayerItemModel::getAllLayers | ( | ) |
Get all layers contained in the model. Commonly used for persistent pourposes.
Definition at line 361 of file LayerItemModel.cpp.
References GetAllLayers(), and m_root.
Referenced by te::qt::widgets::LayerItemView::getAllLayers().
| std::list< te::map::AbstractLayerPtr > te::qt::widgets::LayerItemModel::getVisibleLayers | ( | ) |
Returns a list with layers that are visible.
Definition at line 370 of file LayerItemModel.cpp.
References GetVisibleLayers(), and m_root.
Referenced by te::qt::widgets::LayerItemView::getVisibleLayers().
| QVariant te::qt::widgets::LayerItemModel::headerData | ( | int | section, |
| Qt::Orientation | orientation, | ||
| int | role = Qt::DisplayRole |
||
| ) | const |
Definition at line 609 of file LayerItemModel.cpp.
| QModelIndex te::qt::widgets::LayerItemModel::index | ( | int | row, |
| int | column, | ||
| const QModelIndex & | parent = QModelIndex() |
||
| ) | const |
Definition at line 618 of file LayerItemModel.cpp.
References data(), te::qt::widgets::TreeItem::getChild(), te::qt::widgets::TreeItem::getChildrenCount(), and m_root.
Referenced by FindIndex().
| bool te::qt::widgets::LayerItemModel::insertRows | ( | int | row, |
| int | count, | ||
| const QModelIndex & | parent = QModelIndex() |
||
| ) |
Definition at line 462 of file LayerItemModel.cpp.
Referenced by te::qt::widgets::LayerItemView::updateChart(), and te::qt::widgets::LayerItemView::updateLegend().
| QMimeData * te::qt::widgets::LayerItemModel::mimeData | ( | const QModelIndexList & | indexes | ) | const |
Definition at line 483 of file LayerItemModel.cpp.
| QStringList te::qt::widgets::LayerItemModel::mimeTypes | ( | ) | const |
Definition at line 476 of file LayerItemModel.cpp.
| QModelIndex te::qt::widgets::LayerItemModel::parent | ( | const QModelIndex & | index | ) | const |
Definition at line 652 of file LayerItemModel.cpp.
References te::qt::widgets::TreeItem::getParent(), te::qt::widgets::TreeItem::getPosition(), and m_root.
Referenced by addItems(), data(), FindInsertInformation(), and setData().
| 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. |
Definition at line 547 of file LayerItemModel.cpp.
References CleanRemoveList().
Referenced by te::qt::widgets::LayerItemView::removeItems().
| bool te::qt::widgets::LayerItemModel::removeRows | ( | int | row, |
| int | count, | ||
| const QModelIndex & | parent = QModelIndex() |
||
| ) |
Definition at line 446 of file LayerItemModel.cpp.
References m_root, and te::qt::widgets::TreeItem::removeChild().
| int te::qt::widgets::LayerItemModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Definition at line 666 of file LayerItemModel.cpp.
References te::qt::widgets::TreeItem::getChildrenCount(), and m_root.
Referenced by data(), FindIndex(), FindInsertInformation(), and setData().
| bool te::qt::widgets::LayerItemModel::setData | ( | const QModelIndex & | index, |
| const QVariant & | value, | ||
| int | role = Qt::EditRole |
||
| ) |
Definition at line 384 of file LayerItemModel.cpp.
References te::qt::widgets::LayerItem::getLayer(), te::qt::widgets::TreeItem::getParent(), te::qt::widgets::TreeItem::getType(), te::qt::widgets::NONE, parent(), rowCount(), te::qt::widgets::TreeItem::setVisible(), styleVisibilityChanged(), te::qt::widgets::TOTALLY, and visibilityChanged().
| 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. |
Definition at line 268 of file LayerItemModel.cpp.
References addLayers(), and m_root.
Referenced by te::qt::widgets::LayerItemView::setLayers().
|
signal |
Referenced by setData().
| Qt::DropActions te::qt::widgets::LayerItemModel::supportedDropActions | ( | ) | const |
Definition at line 471 of file LayerItemModel.cpp.
|
signal |
Signal emited when an item visibility has changed.
Referenced by setData().
|
protected |
The root item of the model.
Definition at line 278 of file LayerItemModel.h.
Referenced by addFolder(), addItems(), addLayer(), addLayers(), dropMimeData(), getAllLayers(), getVisibleLayers(), index(), LayerItemModel(), parent(), removeRows(), rowCount(), and setLayers().