16#ifndef QGSMAPLAYERMODEL_H
17#define QGSMAPLAYERMODEL_H
19#include <QAbstractItemModel>
20#include <QSortFilterProxyModel>
40 Q_PROPERTY(
bool allowEmptyLayer READ allowEmptyLayer WRITE setAllowEmptyLayer )
41 Q_PROPERTY(
bool showCrs READ showCrs WRITE setShowCrs )
42 Q_PROPERTY(
bool itemsCheckable READ itemsCheckable WRITE setItemsCheckable )
43 Q_PROPERTY( QStringList additionalItems READ additionalItems WRITE setAdditionalItems )
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 );
234 QMap<QString, Qt::CheckState> mLayersChecked;
235 bool mItemCheckable = false;
236 bool mCanReorder = false;
242 bool mAllowEmpty = false;
245 bool mShowCrs = false;
246 QStringList mAdditionalItems;
The QgsMapLayerModel class is a model to display layers in widgets.
bool itemsCheckable() const
returns if the items can be checked or not
bool showCrs() const
Returns true if the model includes layer's CRS in the display role.
CustomRole
Custom model roles.
QStringList additionalItems() const
Returns the list of additional (non map layer) items included at the end of the model.
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)