16 #ifndef QGSMAPLAYERMODEL_H 
   17 #define QGSMAPLAYERMODEL_H 
   19 #include <QAbstractItemModel> 
   20 #include <QSortFilterProxyModel> 
   21 #include <QStringList> 
   24 #include "qgis_core.h" 
   41     Q_PROPERTY( 
bool allowEmptyLayer READ allowEmptyLayer WRITE setAllowEmptyLayer )
 
   42     Q_PROPERTY( 
bool showCrs READ showCrs WRITE setShowCrs )
 
   43     Q_PROPERTY( 
bool itemsCheckable READ itemsCheckable WRITE setItemsCheckable )
 
   44     Q_PROPERTY( QStringList additionalItems READ additionalItems WRITE setAdditionalItems )
 
   51       LayerIdRole = Qt::UserRole + 1, 
 
   56     Q_ENUM( ItemDataRole )
 
   77     void setItemsCheckable( 
bool checkable );
 
   85     void setItemsCanBeReordered( 
bool allow );
 
   93     bool itemsCanBeReordered() 
const;
 
   98     void checkAll( Qt::CheckState checkState );
 
  108     void setAllowEmptyLayer( 
bool allowEmpty, 
const QString &text = QString(), 
const QIcon &icon = QIcon() );
 
  122     void setShowCrs( 
bool showCrs );
 
  134     QList<QgsMapLayer *> layersChecked( Qt::CheckState checkState = Qt::Checked );
 
  139     void setLayersChecked( 
const QList< QgsMapLayer * > &layers );
 
  148     QModelIndex indexFromLayer( 
QgsMapLayer *layer ) 
const;
 
  155     QgsMapLayer *layerFromIndex( 
const QModelIndex &index ) 
const;
 
  164     void setAdditionalItems( 
const QStringList &items );
 
  182     void setAdditionalLayers( 
const QList<QgsMapLayer *> &layers );
 
  190     QList< QgsMapLayer * > additionalLayers() 
const;
 
  193     QModelIndex index( 
int row, 
int column, 
const QModelIndex &parent = QModelIndex() ) 
const override;
 
  194     QModelIndex parent( 
const QModelIndex &child ) 
const override;
 
  195     int rowCount( 
const QModelIndex &parent = QModelIndex() ) 
const override;
 
  196     int columnCount( 
const QModelIndex &parent = QModelIndex() ) 
const override;
 
  197     QVariant data( 
const QModelIndex &index, 
int role = Qt::DisplayRole ) 
const override;
 
  198     bool setData( 
const QModelIndex &index, 
const QVariant &value, 
int role = Qt::EditRole ) 
override;
 
  199     Qt::ItemFlags flags( 
const QModelIndex &index ) 
const override;
 
  200     bool insertRows( 
int row, 
int count, 
const QModelIndex &parent = QModelIndex() ) 
override;
 
  201     bool removeRows( 
int row, 
int count, 
const QModelIndex &parent = QModelIndex() ) 
override;
 
  202     QStringList mimeTypes() 
const override;
 
  203     bool canDropMimeData( 
const QMimeData *data, Qt::DropAction action, 
int row, 
int column, 
const QModelIndex &parent ) 
const override;
 
  204     QMimeData *mimeData( 
const QModelIndexList &indexes ) 
const override;
 
  205     bool dropMimeData( 
const QMimeData *data, Qt::DropAction action, 
int row, 
int column, 
const QModelIndex &parent ) 
override;
 
  206     Qt::DropActions supportedDropActions() 
const override;
 
  213     QHash<int, QByteArray> roleNames() const override 
SIP_SKIP;
 
  222     void removeLayers( const QStringList &layerIds );
 
  223     void addLayers( const QList<
QgsMapLayer *> &layers );
 
  228     QMap<QString, Qt::CheckState> mLayersChecked;
 
  229     bool mItemCheckable = false;
 
  230     bool mCanReorder = false;
 
  236     bool mAllowEmpty = false;
 
  239     bool mShowCrs = false;
 
  240     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
ItemDataRole
Item data roles.
@ EmptyRole
True if index corresponds to the empty (not set) value.
@ LayerRole
Stores pointer to the map layer itself.
@ AdditionalRole
True if index corresponds to an additional (non map layer) item.
bool showCrs() const
Returns true if the model includes layer's CRS in the display role.
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,...