28 : QAbstractItemModel( parent )
29 , mLayersChecked( QMap<QString, Qt::CheckState>() )
30 , mItemCheckable( false )
37 : QAbstractItemModel( parent )
38 , mLayersChecked( QMap<QString, Qt::CheckState>() )
39 , mItemCheckable( false )
62 QList<QgsMapLayer *> layers;
67 layers.append( layer );
75 int r =
mLayers.indexOf( layer );
81 foreach (
const QString layerId, layerIds )
83 QModelIndex startIndex =
index( 0, 0 );
84 QModelIndexList list = match( startIndex,
LayerIdRole, layerId, 1 );
87 QModelIndex
index = list[0];
88 beginRemoveRows( QModelIndex(), index.row(), index.row() );
90 mLayers.removeAt( index.row() );
98 beginInsertRows( QModelIndex(),
mLayers.count(),
mLayers.count() + layers.count() - 1 );
109 if ( hasIndex( row, column, parent ) )
111 return createIndex( row, column,
mLayers[row] );
114 return QModelIndex();
121 return QModelIndex();
127 return parent.isValid() ? 0 :
mLayers.length();
139 if ( !index.isValid() || !index.internalPointer() )
142 if ( role == Qt::DisplayRole )
145 return layer->
name();
160 if ( role == Qt::DecorationRole )
164 if ( role == Qt::DecorationRole )
219 if ( !index.isValid() )
224 Qt::ItemFlags
flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
227 flags |= Qt::ItemIsUserCheckable;
235 if ( role == Qt::CheckStateRole )
239 emit dataChanged( index, index );