QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Static Public Attributes | Protected Slots | Protected Attributes | List of all members
QgsMapLayerModel Class Reference

The QgsMapLayerModel class is a model to display layers in widgets. More...

#include <qgsmaplayermodel.h>

Inheritance diagram for QgsMapLayerModel:
Inheritance graph
[legend]

Public Member Functions

 QgsMapLayerModel (QObject *parent=0)
 QgsMapLayerModel creates a model to display layers in widgets. More...
 
 QgsMapLayerModel (QList< QgsMapLayer * > layers, QObject *parent=0)
 QgsMapLayerModel creates a model to display a specific list of layers in a widget. More...
 
void checkAll (Qt::CheckState checkState)
 checkAll changes the checkstate for all the layers More...
 
int columnCount (const QModelIndex &parent) const
 
QVariant data (const QModelIndex &index, int role) const
 
Qt::ItemFlags flags (const QModelIndex &index) const
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const
 
QModelIndex indexFromLayer (QgsMapLayer *layer) const
 indexFromLayer returns the model index for a given layer More...
 
bool itemsCheckable () const
 returns if the items can be checked or not More...
 
QList< QgsMapLayer * > layersChecked (Qt::CheckState checkState=Qt::Checked)
 layersChecked returns the list of layers which are checked (or unchecked) More...
 
QModelIndex parent (const QModelIndex &child) const
 
int rowCount (const QModelIndex &parent) const
 
bool setData (const QModelIndex &index, const QVariant &value, int role)
 
void setItemsCheckable (bool checkable)
 setItemsCheckable defines if layers should be selectable in the widget More...
 

Static Public Attributes

static const int LayerIdRole = Qt::UserRole + 1
 

Protected Slots

void addLayers (QList< QgsMapLayer * > layers)
 
void removeLayers (const QStringList layerIds)
 

Protected Attributes

bool mItemCheckable
 
QList< QgsMapLayer * > mLayers
 
QMap< QString, Qt::CheckState > mLayersChecked
 

Detailed Description

The QgsMapLayerModel class is a model to display layers in widgets.

See also
QgsMapLayerProxyModel to sort and/filter the layers
QgsFieldModel to combine in with a field selector.
Note
added in 2.3

Definition at line 32 of file qgsmaplayermodel.h.

Constructor & Destructor Documentation

QgsMapLayerModel::QgsMapLayerModel ( QObject *  parent = 0)
explicit

QgsMapLayerModel creates a model to display layers in widgets.

Definition at line 36 of file qgsmaplayermodel.cpp.

QgsMapLayerModel::QgsMapLayerModel ( QList< QgsMapLayer * >  layers,
QObject *  parent = 0 
)
explicit

QgsMapLayerModel creates a model to display a specific list of layers in a widget.

Definition at line 27 of file qgsmaplayermodel.cpp.

Member Function Documentation

void QgsMapLayerModel::addLayers ( QList< QgsMapLayer * >  layers)
protectedslot

Definition at line 96 of file qgsmaplayermodel.cpp.

void QgsMapLayerModel::checkAll ( Qt::CheckState  checkState)

checkAll changes the checkstate for all the layers

Definition at line 51 of file qgsmaplayermodel.cpp.

int QgsMapLayerModel::columnCount ( const QModelIndex &  parent) const

Definition at line 130 of file qgsmaplayermodel.cpp.

QVariant QgsMapLayerModel::data ( const QModelIndex &  index,
int  role 
) const

Definition at line 137 of file qgsmaplayermodel.cpp.

Qt::ItemFlags QgsMapLayerModel::flags ( const QModelIndex &  index) const

Definition at line 217 of file qgsmaplayermodel.cpp.

QModelIndex QgsMapLayerModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const

Definition at line 107 of file qgsmaplayermodel.cpp.

QModelIndex QgsMapLayerModel::indexFromLayer ( QgsMapLayer layer) const

indexFromLayer returns the model index for a given layer

Definition at line 73 of file qgsmaplayermodel.cpp.

bool QgsMapLayerModel::itemsCheckable ( ) const
inline

returns if the items can be checked or not

Definition at line 60 of file qgsmaplayermodel.h.

QList< QgsMapLayer * > QgsMapLayerModel::layersChecked ( Qt::CheckState  checkState = Qt::Checked)

layersChecked returns the list of layers which are checked (or unchecked)

Definition at line 60 of file qgsmaplayermodel.cpp.

QModelIndex QgsMapLayerModel::parent ( const QModelIndex &  child) const

Definition at line 118 of file qgsmaplayermodel.cpp.

void QgsMapLayerModel::removeLayers ( const QStringList  layerIds)
protectedslot

Definition at line 79 of file qgsmaplayermodel.cpp.

int QgsMapLayerModel::rowCount ( const QModelIndex &  parent) const

Definition at line 125 of file qgsmaplayermodel.cpp.

bool QgsMapLayerModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)

Definition at line 233 of file qgsmaplayermodel.cpp.

void QgsMapLayerModel::setItemsCheckable ( bool  checkable)

setItemsCheckable defines if layers should be selectable in the widget

Definition at line 46 of file qgsmaplayermodel.cpp.

Member Data Documentation

const int QgsMapLayerModel::LayerIdRole = Qt::UserRole + 1
static

Definition at line 36 of file qgsmaplayermodel.h.

bool QgsMapLayerModel::mItemCheckable
protected

Definition at line 75 of file qgsmaplayermodel.h.

QList<QgsMapLayer*> QgsMapLayerModel::mLayers
protected

Definition at line 73 of file qgsmaplayermodel.h.

QMap<QString, Qt::CheckState> QgsMapLayerModel::mLayersChecked
protected

Definition at line 74 of file qgsmaplayermodel.h.


The documentation for this class was generated from the following files: