16 #ifndef QGSMAPLAYERMODEL_H
17 #define QGSMAPLAYERMODEL_H
19 #include <QAbstractItemModel>
20 #include <QSortFilterProxyModel>
21 #include <QStringList>
23 #include "qgis_core.h"
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 )
50 LayerIdRole = Qt::UserRole + 1,
55 Q_ENUM( ItemDataRole )
76 void setItemsCheckable(
bool checkable );
84 void setItemsCanBeReordered(
bool allow );
92 bool itemsCanBeReordered()
const;
97 void checkAll( Qt::CheckState checkState );
104 void setAllowEmptyLayer(
bool allowEmpty );
118 void setShowCrs(
bool showCrs );
130 QList<QgsMapLayer *> layersChecked( Qt::CheckState checkState = Qt::Checked );
138 QModelIndex indexFromLayer(
QgsMapLayer *layer )
const;
145 QgsMapLayer *layerFromIndex(
const QModelIndex &index )
const;
154 void setAdditionalItems(
const QStringList &items );
164 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
165 QModelIndex parent(
const QModelIndex &child )
const override;
166 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
167 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
168 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
169 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
170 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
171 bool insertRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
172 bool removeRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
173 QStringList mimeTypes()
const override;
174 bool canDropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
const override;
175 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
176 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
override;
177 Qt::DropActions supportedDropActions()
const override;
184 QHash<int, QByteArray> roleNames() const override
SIP_SKIP;
193 void removeLayers( const QStringList &layerIds );
194 void addLayers( const QList<
QgsMapLayer *> &layers );
198 QMap<QString, Qt::CheckState> mLayersChecked;
199 bool mItemCheckable = false;
200 bool mCanReorder = false;
206 bool mAllowEmpty = false;
207 bool mShowCrs = false;
208 QStringList mAdditionalItems;
211 #endif // QGSMAPLAYERMODEL_H