QGIS API Documentation
3.0.2-Girona (307d082)
|
The QgsMapLayerModel class is a model to display layers in widgets. More...
#include <qgsmaplayermodel.h>
Public Types | |
enum | ItemDataRole { LayerIdRole = Qt::UserRole + 1, LayerRole, EmptyRole, AdditionalRole } |
Item data roles. More... | |
Public Member Functions | |
QgsMapLayerModel (QObject *parent=nullptr) | |
QgsMapLayerModel creates a model to display layers in widgets. More... | |
QgsMapLayerModel (const QList< QgsMapLayer *> &layers, QObject *parent=nullptr) | |
QgsMapLayerModel creates a model to display a specific list of layers in a widget. More... | |
QStringList | additionalItems () const |
Return the list of additional (non map layer) items included at the end of the model. More... | |
bool | allowEmptyLayer () const |
Returns true if the model allows the empty layer ("not set") choice. More... | |
void | checkAll (Qt::CheckState checkState) |
checkAll changes the checkstate for all the layers More... | |
int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
Qt::ItemFlags | flags (const QModelIndex &index) const override |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override |
QModelIndex | indexFromLayer (QgsMapLayer *layer) const |
indexFromLayer returns the model index for a given layer More... | |
bool | itemsCheckable () const |
returns if the items can be checked or not More... | |
QgsMapLayer * | layerFromIndex (const QModelIndex &index) const |
Returns the map layer corresponding to the specified index. More... | |
QList< QgsMapLayer * > | layersChecked (Qt::CheckState checkState=Qt::Checked) |
layersChecked returns the list of layers which are checked (or unchecked) More... | |
QModelIndex | parent (const QModelIndex &child) const override |
QHash< int, QByteArray > | roleNames () const override |
Returns strings for all roles supported by this model. More... | |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
void | setAdditionalItems (const QStringList &items) |
Sets a list of additional (non map layer) items to include at the end of the model. More... | |
void | setAllowEmptyLayer (bool allowEmpty) |
Sets whether an optional empty layer ("not set") option is present in the model. More... | |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
void | setItemsCheckable (bool checkable) |
setItemsCheckable defines if layers should be selectable in the widget More... | |
void | setShowCrs (bool showCrs) |
Sets whether the CRS of layers is also included in the model's display role. More... | |
bool | showCrs () const |
Returns true if the model includes layer's CRS in the display role. More... | |
Static Public Member Functions | |
static QIcon | iconForLayer (QgsMapLayer *layer) |
Returns the icon corresponding to a specified map layer. More... | |
Protected Slots | |
void | addLayers (const QList< QgsMapLayer *> &layers) |
void | removeLayers (const QStringList &layerIds) |
Protected Attributes | |
bool | mItemCheckable = false |
QList< QgsMapLayer * > | mLayers |
QMap< QString, Qt::CheckState > | mLayersChecked |
Properties | |
QStringList | additionalItems |
bool | allowEmptyLayer |
bool | itemsCheckable |
bool | showCrs |
The QgsMapLayerModel class is a model to display layers in widgets.
Definition at line 36 of file qgsmaplayermodel.h.
Item data roles.
Definition at line 48 of file qgsmaplayermodel.h.
|
explicit |
QgsMapLayerModel creates a model to display layers in widgets.
Definition at line 32 of file qgsmaplayermodel.cpp.
|
explicit |
QgsMapLayerModel creates a model to display a specific list of layers in a widget.
Definition at line 25 of file qgsmaplayermodel.cpp.
|
inline |
Return the list of additional (non map layer) items included at the end of the model.
Definition at line 138 of file qgsmaplayermodel.h.
|
protectedslot |
Definition at line 155 of file qgsmaplayermodel.cpp.
|
inline |
Returns true if the model allows the empty layer ("not set") choice.
Definition at line 88 of file qgsmaplayermodel.h.
void QgsMapLayerModel::checkAll | ( | Qt::CheckState | checkState | ) |
checkAll changes the checkstate for all the layers
Definition at line 45 of file qgsmaplayermodel.cpp.
|
override |
Definition at line 207 of file qgsmaplayermodel.cpp.
|
override |
Definition at line 214 of file qgsmaplayermodel.cpp.
|
override |
Definition at line 335 of file qgsmaplayermodel.cpp.
|
static |
Returns the icon corresponding to a specified map layer.
Definition at line 353 of file qgsmaplayermodel.cpp.
|
override |
Definition at line 173 of file qgsmaplayermodel.cpp.
QModelIndex QgsMapLayerModel::indexFromLayer | ( | QgsMapLayer * | layer | ) | const |
indexFromLayer returns the model index for a given layer
Definition at line 96 of file qgsmaplayermodel.cpp.
|
inline |
returns if the items can be checked or not
Definition at line 109 of file qgsmaplayermodel.h.
QgsMapLayer * QgsMapLayerModel::layerFromIndex | ( | const QModelIndex & | index | ) | const |
Returns the map layer corresponding to the specified index.
Definition at line 104 of file qgsmaplayermodel.cpp.
QList< QgsMapLayer * > QgsMapLayerModel::layersChecked | ( | Qt::CheckState | checkState = Qt::Checked | ) |
layersChecked returns the list of layers which are checked (or unchecked)
Definition at line 83 of file qgsmaplayermodel.cpp.
|
override |
Definition at line 192 of file qgsmaplayermodel.cpp.
|
protectedslot |
Definition at line 134 of file qgsmaplayermodel.cpp.
|
override |
Returns strings for all roles supported by this model.
Definition at line 326 of file qgsmaplayermodel.cpp.
|
override |
Definition at line 199 of file qgsmaplayermodel.cpp.
void QgsMapLayerModel::setAdditionalItems | ( | const QStringList & | items | ) |
Sets a list of additional (non map layer) items to include at the end of the model.
These may represent additional layers such as layers which are not included in the map layer registry, or paths to layers which have not yet been loaded into QGIS.
Definition at line 109 of file qgsmaplayermodel.cpp.
void QgsMapLayerModel::setAllowEmptyLayer | ( | bool | allowEmpty | ) |
Sets whether an optional empty layer ("not set") option is present in the model.
Definition at line 55 of file qgsmaplayermodel.cpp.
|
override |
Definition at line 402 of file qgsmaplayermodel.cpp.
void QgsMapLayerModel::setItemsCheckable | ( | bool | checkable | ) |
setItemsCheckable defines if layers should be selectable in the widget
Definition at line 40 of file qgsmaplayermodel.cpp.
void QgsMapLayerModel::setShowCrs | ( | bool | showCrs | ) |
Sets whether the CRS of layers is also included in the model's display role.
Definition at line 74 of file qgsmaplayermodel.cpp.
|
inline |
Returns true if the model includes layer's CRS in the display role.
Definition at line 102 of file qgsmaplayermodel.h.
|
protected |
Definition at line 170 of file qgsmaplayermodel.h.
|
protected |
Definition at line 168 of file qgsmaplayermodel.h.
|
protected |
Definition at line 169 of file qgsmaplayermodel.h.
|
readwrite |
Definition at line 43 of file qgsmaplayermodel.h.
|
readwrite |
Definition at line 40 of file qgsmaplayermodel.h.
|
readwrite |
Definition at line 42 of file qgsmaplayermodel.h.
|
readwrite |
Definition at line 41 of file qgsmaplayermodel.h.