16#ifndef QGSMAPLAYERMODEL_H
17#define QGSMAPLAYERMODEL_H
22#include <QAbstractItemModel>
24#include <QSortFilterProxyModel>
84 void setItemsCheckable(
bool checkable );
99 void setItemsCanBeReordered(
bool allow );
107 bool itemsCanBeReordered()
const;
112 void checkAll( Qt::CheckState checkState );
121 void setAllowEmptyLayer(
bool allowEmpty,
const QString &text = QString(),
const QIcon &icon = QIcon() );
133 void setShowCrs(
bool showCrs );
144 QList<QgsMapLayer *> layersChecked( Qt::CheckState checkState = Qt::Checked );
149 void setLayersChecked(
const QList< QgsMapLayer * > &layers );
158 QModelIndex indexFromLayer(
QgsMapLayer *layer )
const;
164 QgsMapLayer *layerFromIndex(
const QModelIndex &index )
const;
172 void setAdditionalItems(
const QStringList &items );
189 void setAdditionalLayers(
const QList<QgsMapLayer *> &layers );
197 QList< QgsMapLayer * > additionalLayers()
const;
200 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
201 QModelIndex parent(
const QModelIndex &child )
const override;
202 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
203 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
204 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
205 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
206 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
207 bool insertRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
208 bool removeRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
209 QStringList mimeTypes()
const override;
210 bool canDropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
const override;
211 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
212 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
override;
213 Qt::DropActions supportedDropActions()
const override;
220 QHash<int, QByteArray> roleNames() const override
SIP_SKIP;
228 void removeLayers( const QStringList &layerIds );
229 void addLayers( const QList<
QgsMapLayer *> &layers );
242 bool mAllowEmpty = false;
245 bool mShowCrs = false;
246 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)