16#ifndef QGSMAPLAYERMODEL_H
17#define QGSMAPLAYERMODEL_H
22#include <QAbstractItemModel>
24#include <QSortFilterProxyModel>
83 void setItemsCheckable(
bool checkable );
98 void setItemsCanBeReordered(
bool allow );
106 bool itemsCanBeReordered()
const;
111 void checkAll( Qt::CheckState checkState );
120 void setAllowEmptyLayer(
bool allowEmpty,
const QString &text = QString(),
const QIcon &icon = QIcon() );
132 void setShowCrs(
bool showCrs );
143 QList<QgsMapLayer *> layersChecked( Qt::CheckState checkState = Qt::Checked );
148 void setLayersChecked(
const QList< QgsMapLayer * > &layers );
157 QModelIndex indexFromLayer(
QgsMapLayer *layer )
const;
163 QgsMapLayer *layerFromIndex(
const QModelIndex &index )
const;
171 void setAdditionalItems(
const QStringList &items );
188 void setAdditionalLayers(
const QList<QgsMapLayer *> &layers );
196 QList< QgsMapLayer * > additionalLayers()
const;
199 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
200 QModelIndex parent(
const QModelIndex &child )
const override;
201 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
202 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
203 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
204 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
205 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
206 bool insertRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
207 bool removeRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
208 QStringList mimeTypes()
const override;
209 bool canDropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
const override;
210 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
211 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
override;
212 Qt::DropActions supportedDropActions()
const override;
219 QHash<int, QByteArray> roleNames() const override
SIP_SKIP;
227 void removeLayers( const QStringList &layerIds );
228 void addLayers( const QList<
QgsMapLayer *> &layers );
240 bool mAllowEmpty = false;
243 bool mShowCrs = false;
244 QStringList mAdditionalItems;
A model for display of map layers in widgets.
QList< QPointer< QgsMapLayer > > mAdditionalLayers
void setShowCrs(bool showCrs)
Sets whether the CRS of layers is also included in the model's display role.
bool itemsCheckable() const
Returns whether the items can be checked or not.
void setAllowEmptyLayer(bool allowEmpty, const QString &text=QString(), const QIcon &icon=QIcon())
Sets whether an optional empty layer ("not set") option is present in the model.
void setAdditionalItems(const QStringList &items)
Sets a list of additional (non map layer) items to include at the end of the model.
bool showCrs() const
Returns true if the model includes layer's CRS in the display role.
void setItemsCheckable(bool checkable)
Defines if layers should be selectable in the widget.
QStringList additionalItems
CustomRole
Custom model roles.
QMap< QString, Qt::CheckState > mLayersChecked
QStringList additionalItems() const
Returns the list of additional (non map layer) items included at the end of the model.
QgsMapLayerModel(QObject *parent=nullptr, QgsProject *project=nullptr)
QgsMapLayerModel creates a model to display layers in widgets.
QList< QgsMapLayer * > mLayers
bool allowEmptyLayer() const
Returns true if the model allows the empty layer ("not set") choice.
Base class for all map layer types.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
#define SIP_MONKEYPATCH_COMPAT_NAME(FORMERNAME)