QGIS API Documentation 3.39.0-Master (52f98f8c831)
Loading...
Searching...
No Matches
qgsmaplayermodel.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaplayermodel.cpp
3 --------------------------------------
4 Date : 01.04.2014
5 Copyright : (C) 2014 Denis Rouzaud
7***************************************************************************
8* *
9* This program is free software; you can redistribute it and/or modify *
10* it under the terms of the GNU General Public License as published by *
11* the Free Software Foundation; either version 2 of the License, or *
12* (at your option) any later version. *
13* *
14***************************************************************************/
15
16#include <QIcon>
17
18#include "qgsmaplayermodel.h"
19#include "qgsproject.h"
20#include "qgsvectorlayer.h"
21#include "qgsiconutils.h"
23#include <QMimeData>
24
25QgsMapLayerModel::QgsMapLayerModel( const QList<QgsMapLayer *> &layers, QObject *parent, QgsProject *project )
26 : QAbstractItemModel( parent )
27 , mProject( project ? project : QgsProject::instance() )
28{
29 connect( mProject, static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsMapLayerModel::removeLayers );
30 addLayers( layers );
31}
32
34 : QAbstractItemModel( parent )
35 , mProject( project ? project : QgsProject::instance() )
36{
38 connect( mProject, static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsMapLayerModel::removeLayers );
39 addLayers( mProject->mapLayers().values() );
40}
41
43{
44
45 // remove layers from previous project
46 if ( mProject )
47 {
48 removeLayers( mProject->mapLayers().keys() );
50 disconnect( mProject, static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsMapLayerModel::removeLayers );
51 }
52
53 mProject = project ? project : QgsProject::instance();
54
56 connect( mProject, static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsMapLayerModel::removeLayers );
57 addLayers( mProject->mapLayers().values() );
58}
59
60
62{
63 mItemCheckable = checkable;
64}
65
67{
68 mCanReorder = allow;
69}
70
72{
73 return mCanReorder;
74}
75
76void QgsMapLayerModel::checkAll( Qt::CheckState checkState )
77{
78 QMap<QString, Qt::CheckState>::iterator i = mLayersChecked.begin();
79 for ( ; i != mLayersChecked.end(); ++i )
80 {
81 *i = checkState;
82 }
83 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ) );
84}
85
86void QgsMapLayerModel::setAllowEmptyLayer( bool allowEmpty, const QString &text, const QIcon &icon )
87{
88 mEmptyText = text;
89 mEmptyIcon = icon;
90 if ( allowEmpty == mAllowEmpty )
91 return;
92
93 if ( allowEmpty )
94 {
95 beginInsertRows( QModelIndex(), 0, 0 );
96 mAllowEmpty = true;
97 endInsertRows();
98 }
99 else
100 {
101 beginRemoveRows( QModelIndex(), 0, 0 );
102 mAllowEmpty = false;
103 endRemoveRows();
104 }
105}
106
108{
109 if ( mShowCrs == showCrs )
110 return;
111
112 mShowCrs = showCrs;
113 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector<int>() << Qt::DisplayRole );
114}
115
116QList<QgsMapLayer *> QgsMapLayerModel::layersChecked( Qt::CheckState checkState )
117{
118 QList<QgsMapLayer *> layers;
119 const auto constMLayers = mLayers;
120 for ( QgsMapLayer *layer : constMLayers )
121 {
122 if ( mLayersChecked[layer->id()] == checkState )
123 {
124 layers.append( layer );
125 }
126 }
127 return layers;
128}
129
130void QgsMapLayerModel::setLayersChecked( const QList<QgsMapLayer *> &layers )
131{
132 QMap<QString, Qt::CheckState>::iterator i = mLayersChecked.begin();
133 for ( ; i != mLayersChecked.end(); ++i )
134 {
135 *i = Qt::Unchecked;
136 }
137 for ( const QgsMapLayer *layer : layers )
138 {
139 mLayersChecked[ layer->id() ] = Qt::Checked;
140 }
141 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector<int>() << Qt::CheckStateRole );
142}
143
145{
146 int r = mLayers.indexOf( layer );
147 if ( r >= 0 && mAllowEmpty )
148 r++;
149 return index( r, 0 );
150}
151
152QgsMapLayer *QgsMapLayerModel::layerFromIndex( const QModelIndex &index ) const
153{
154 return mProject->mapLayer( index.data( static_cast< int >( CustomRole::LayerId ) ).toString() );
155}
156
157void QgsMapLayerModel::setAdditionalItems( const QStringList &items )
158{
159 if ( items == mAdditionalItems )
160 return;
161
162 int offset = 0;
163 if ( mAllowEmpty )
164 offset++;
165
166 offset += mLayers.count();
167
168 //remove existing
169 if ( !mAdditionalItems.isEmpty() )
170 {
171 beginRemoveRows( QModelIndex(), offset, offset + mAdditionalItems.count() - 1 );
172 mAdditionalItems.clear();
173 endRemoveRows();
174 }
175
176 //add new
177 beginInsertRows( QModelIndex(), offset, offset + items.count() - 1 );
178 mAdditionalItems = items;
179 endInsertRows();
180}
181
182void QgsMapLayerModel::setAdditionalLayers( const QList<QgsMapLayer *> &layers )
183{
184 if ( layers == _qgis_listQPointerToRaw( mAdditionalLayers ) )
185 return;
186
187 QStringList layerIdsToRemove;
188 for ( QgsMapLayer *layer : std::as_const( mAdditionalLayers ) )
189 {
190 if ( layer )
191 layerIdsToRemove << layer->id();
192 }
193 removeLayers( layerIdsToRemove );
194
195 for ( QgsMapLayer *layer : layers )
196 {
197 if ( layer )
198 {
199 addLayers( { layer } );
200 const QString layerId = layer->id();
201 connect( layer, &QgsMapLayer::willBeDeleted, this, [this, layerId] { removeLayers( {layerId} ); } );
202 }
203 }
204
205 mAdditionalLayers = _qgis_listRawToQPointer( layers );
206}
207
208QList<QgsMapLayer *> QgsMapLayerModel::additionalLayers() const
209{
210 return _qgis_listQPointerToRaw( mAdditionalLayers );
211}
212
213void QgsMapLayerModel::removeLayers( const QStringList &layerIds )
214{
215 int offset = 0;
216 if ( mAllowEmpty )
217 offset++;
218
219 for ( const QString &layerId : layerIds )
220 {
221 QModelIndex startIndex = index( 0, 0 );
222 QModelIndexList list = match( startIndex, static_cast< int >( CustomRole::LayerId ), layerId, 1 );
223 if ( !list.isEmpty() )
224 {
225 QModelIndex index = list[0];
226 beginRemoveRows( QModelIndex(), index.row(), index.row() );
227 mLayersChecked.remove( layerId );
228 mLayers.removeAt( index.row() - offset );
229 endRemoveRows();
230 }
231 }
232}
233
234void QgsMapLayerModel::addLayers( const QList<QgsMapLayer *> &layers )
235{
236 if ( !layers.empty( ) )
237 {
238 int offset = 0;
239 if ( mAllowEmpty )
240 offset++;
241
242 beginInsertRows( QModelIndex(), mLayers.count() + offset, mLayers.count() + layers.count() - 1 + offset );
243 const auto constLayers = layers;
244 for ( QgsMapLayer *layer : constLayers )
245 {
246 mLayers.append( layer );
247 mLayersChecked.insert( layer->id(), Qt::Unchecked );
248 }
249 endInsertRows();
250 }
251}
252
253QModelIndex QgsMapLayerModel::index( int row, int column, const QModelIndex &parent ) const
254{
255 int offset = 0;
256 if ( mAllowEmpty )
257 offset++;
258
259 if ( hasIndex( row, column, parent ) )
260 {
261 QgsMapLayer *layer = nullptr;
262 if ( row - offset >= 0 && row - offset < mLayers.count() )
263 layer = mLayers.at( row - offset );
264
265 return createIndex( row, column, layer );
266 }
267
268 return QModelIndex();
269
270}
271
272QModelIndex QgsMapLayerModel::parent( const QModelIndex &child ) const
273{
274 Q_UNUSED( child )
275 return QModelIndex();
276}
277
278
279int QgsMapLayerModel::rowCount( const QModelIndex &parent ) const
280{
281 if ( parent.isValid() )
282 return 0;
283
284 return ( mAllowEmpty ? 1 : 0 ) + mLayers.length() + mAdditionalItems.count();
285}
286
287int QgsMapLayerModel::columnCount( const QModelIndex &parent ) const
288{
289 Q_UNUSED( parent )
290 return 1;
291}
292
293
294QVariant QgsMapLayerModel::data( const QModelIndex &index, int role ) const
295{
296 if ( !index.isValid() )
297 return QVariant();
298
299 bool isEmpty = index.row() == 0 && mAllowEmpty;
300 int additionalIndex = index.row() - ( mAllowEmpty ? 1 : 0 ) - mLayers.count();
301
302 switch ( role )
303 {
304 case Qt::DisplayRole:
305 case Qt::EditRole:
306 {
307 if ( index.row() == 0 && mAllowEmpty )
308 return mEmptyText;
309
310 if ( additionalIndex >= 0 )
311 return mAdditionalItems.at( additionalIndex );
312
313 QgsMapLayer *layer = mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) );
314 if ( !layer )
315 return QVariant();
316
317 if ( !mShowCrs || !layer->isSpatial() || role == Qt::EditRole )
318 {
319 return layer->name();
320 }
321 else
322 {
323 return tr( "%1 [%2]" ).arg( layer->name(), layer->crs().authid() );
324 }
325 }
326
327 case static_cast< int >( CustomRole::LayerId ):
328 {
329 if ( isEmpty || additionalIndex >= 0 )
330 return QVariant();
331
332 QgsMapLayer *layer = mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) );
333 return layer ? layer->id() : QVariant();
334 }
335
336 case static_cast< int >( CustomRole::Layer ):
337 {
338 if ( isEmpty || additionalIndex >= 0 )
339 return QVariant();
340
341 return QVariant::fromValue<QgsMapLayer *>( mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) ) );
342 }
343
344 case static_cast< int >( CustomRole::Empty ):
345 return isEmpty;
346
347 case static_cast< int >( CustomRole::Additional ):
348 return additionalIndex >= 0;
349
350 case Qt::CheckStateRole:
351 {
352 if ( mItemCheckable )
353 {
354 if ( isEmpty || additionalIndex >= 0 )
355 return QVariant();
356
357 QgsMapLayer *layer = mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) );
358 return layer ? mLayersChecked[layer->id()] : QVariant();
359 }
360
361 return QVariant();
362 }
363
364 case Qt::ToolTipRole:
365 {
366 QgsMapLayer *layer = mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) );
367 if ( layer )
368 {
369 QStringList parts;
370 QString title = !layer->metadata().title().isEmpty() ? layer->metadata().title() : ( layer->serverProperties()->title().isEmpty() ? layer->serverProperties()->shortName() : layer->serverProperties()->title() );
371 if ( title.isEmpty() )
372 title = layer->name();
373 title = "<b>" + title + "</b>";
374 if ( layer->isSpatial() && layer->crs().isValid() )
375 {
376 QString layerCrs = layer->crs().authid();
377 if ( !std::isnan( layer->crs().coordinateEpoch() ) )
378 {
379 layerCrs += QStringLiteral( " @ %1" ).arg( qgsDoubleToString( layer->crs().coordinateEpoch(), 3 ) );
380 }
381 if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer ) )
382 title = tr( "%1 (%2 - %3)" ).arg( title, QgsWkbTypes::displayString( vl->wkbType() ), layerCrs );
383 else
384 title = tr( "%1 (%2)" ).arg( title, layerCrs );
385 }
386 parts << title;
387
388 QString abstract = !layer->metadata().abstract().isEmpty() ? layer->metadata().abstract() : layer->serverProperties()->abstract();
389 if ( !abstract.isEmpty() )
390 parts << "<br/>" + abstract.replace( QLatin1String( "\n" ), QLatin1String( "<br/>" ) );
391 parts << "<i>" + layer->publicSource() + "</i>";
392 return parts.join( QLatin1String( "<br/>" ) );
393 }
394 return QVariant();
395 }
396
397 case Qt::DecorationRole:
398 {
399 if ( isEmpty )
400 return mEmptyIcon.isNull() ? QVariant() : mEmptyIcon;
401
402 if ( additionalIndex >= 0 )
403 return QVariant();
404
405 QgsMapLayer *layer = mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) );
406 if ( !layer )
407 return QVariant();
408
409 return iconForLayer( layer );
410 }
411
412 default:
413 break;
414 }
415
416 return QVariant();
417}
418
419QHash<int, QByteArray> QgsMapLayerModel::roleNames() const
420{
421 QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
422 roles[static_cast< int >( CustomRole::LayerId ) ] = "layerId";
423 roles[static_cast< int >( CustomRole::Layer )] = "layer";
424
425 return roles;
426}
427
428Qt::ItemFlags QgsMapLayerModel::flags( const QModelIndex &index ) const
429{
430 if ( !index.isValid() )
431 {
432 if ( mCanReorder )
433 return Qt::ItemIsDropEnabled;
434 else
435 return Qt::ItemFlags();
436 }
437
438 bool isEmpty = index.row() == 0 && mAllowEmpty;
439 int additionalIndex = index.row() - ( mAllowEmpty ? 1 : 0 ) - mLayers.count();
440
441 Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
442
443 if ( mCanReorder && !isEmpty && additionalIndex < 0 )
444 {
445 flags |= Qt::ItemIsDragEnabled;
446 }
447
448 if ( mItemCheckable && !isEmpty && additionalIndex < 0 )
449 {
450 flags |= Qt::ItemIsUserCheckable;
451 }
452 return flags;
453}
454
455bool QgsMapLayerModel::insertRows( int row, int count, const QModelIndex &parent )
456{
457 if ( parent.isValid() )
458 return false;
459
460 int offset = 0;
461 if ( mAllowEmpty )
462 offset++;
463
464 beginInsertRows( parent, row, row + count - 1 );
465 for ( int i = row; i < row + count; ++i )
466 mLayers.insert( i - offset, nullptr );
467 endInsertRows();
468
469 return true;
470}
471
472bool QgsMapLayerModel::removeRows( int row, int count, const QModelIndex &parent )
473{
474 if ( parent.isValid() || row < 0 )
475 return false;
476
477 int offset = 0;
478 if ( mAllowEmpty )
479 {
480 if ( row == 0 )
481 return false;
482
483 offset++;
484 }
485
486 if ( row - offset > mLayers.count() - 1 )
487 {
488 return false;
489 }
490
491 beginRemoveRows( parent, row, row + count - 1 );
492 for ( int i = 0; i != count; ++i )
493 mLayers.removeAt( row - offset );
494 endRemoveRows();
495
496 return true;
497}
498
500{
501 QStringList types;
502 types << QStringLiteral( "application/qgis.layermodeldata" );
503 return types;
504}
505
506bool QgsMapLayerModel::canDropMimeData( const QMimeData *data, Qt::DropAction action, int, int, const QModelIndex & ) const
507{
508 if ( !mCanReorder || action != Qt::MoveAction || !data->hasFormat( QStringLiteral( "application/qgis.layermodeldata" ) ) )
509 return false;
510 return true;
511}
512
513QMimeData *QgsMapLayerModel::mimeData( const QModelIndexList &indexes ) const
514{
515 std::unique_ptr< QMimeData > mimeData = std::make_unique< QMimeData >();
516
517 QByteArray encodedData;
518 QDataStream stream( &encodedData, QIODevice::WriteOnly );
519 QSet< QString > addedLayers;
520
521 for ( const QModelIndex &i : indexes )
522 {
523 if ( i.isValid() )
524 {
525 const QString id = data( index( i.row(), 0, i.parent() ), static_cast< int >( CustomRole::LayerId ) ).toString();
526 if ( !addedLayers.contains( id ) )
527 {
528 addedLayers.insert( id );
529 stream << id;
530 }
531 }
532 }
533 mimeData->setData( QStringLiteral( "application/qgis.layermodeldata" ), encodedData );
534 return mimeData.release();
535}
536
537bool QgsMapLayerModel::dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent )
538{
539 if ( !canDropMimeData( data, action, row, column, parent ) || row < 0 )
540 return false;
541
542 if ( action == Qt::IgnoreAction )
543 return true;
544 else if ( action != Qt::MoveAction )
545 return false;
546
547 QByteArray encodedData = data->data( QStringLiteral( "application/qgis.layermodeldata" ) );
548 QDataStream stream( &encodedData, QIODevice::ReadOnly );
549 QStringList newItems;
550 int rows = 0;
551
552 while ( !stream.atEnd() )
553 {
554 QString text;
555 stream >> text;
556 newItems << text;
557 ++rows;
558 }
559
560 insertRows( row, rows, QModelIndex() );
561 for ( const QString &text : std::as_const( newItems ) )
562 {
563 QModelIndex idx = index( row, 0, QModelIndex() );
564 setData( idx, text, static_cast< int >( CustomRole::LayerId ) );
565 row++;
566 }
567
568 return true;
569}
570
572{
573 return Qt::MoveAction;
574}
575
577{
578 return QgsIconUtils::iconForLayer( layer );
579}
580
581bool QgsMapLayerModel::setData( const QModelIndex &index, const QVariant &value, int role )
582{
583 if ( !index.isValid() )
584 return false;
585
586 bool isEmpty = index.row() == 0 && mAllowEmpty;
587 int additionalIndex = index.row() - ( mAllowEmpty ? 1 : 0 ) - mLayers.count();
588
589 switch ( role )
590 {
591 case Qt::CheckStateRole:
592 {
593 if ( !isEmpty && additionalIndex < 0 )
594 {
595 QgsMapLayer *layer = static_cast<QgsMapLayer *>( index.internalPointer() );
596 mLayersChecked[layer->id()] = ( Qt::CheckState )value.toInt();
597 emit dataChanged( index, index, QVector< int >() << Qt::CheckStateRole );
598 return true;
599 }
600 break;
601 }
602
603 case static_cast< int >( CustomRole::LayerId ):
604 if ( !isEmpty && additionalIndex < 0 )
605 {
606 mLayers[index.row() - ( mAllowEmpty ? 1 : 0 )] = mProject->mapLayer( value.toString() );
607 emit dataChanged( index, index );
608 return true;
609 }
610 break;
611
612 default:
613 break;
614 }
615
616 return false;
617}
QString abstract() const
Returns a free-form description of the resource.
QString title() const
Returns the human readable name of the resource, typically displayed in search results.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
double coordinateEpoch() const
Returns the coordinate epoch, as a decimal year.
static QIcon iconForLayer(const QgsMapLayer *layer)
Returns the icon corresponding to a specified map layer.
QList< QPointer< QgsMapLayer > > mAdditionalLayers
void setShowCrs(bool showCrs)
Sets whether the CRS of layers is also included in the model's display role.
void setItemsCanBeReordered(bool allow)
Sets whether items in the model can be reordered via drag and drop.
QHash< int, QByteArray > roleNames() const override
Returns strings for all roles supported by this model.
Qt::ItemFlags flags(const QModelIndex &index) const override
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
int rowCount(const QModelIndex &parent=QModelIndex()) const override
QList< QgsMapLayer * > layersChecked(Qt::CheckState checkState=Qt::Checked)
layersChecked returns the list of layers which are checked (or unchecked)
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
QModelIndex parent(const QModelIndex &child) const override
QgsProject * mProject
void setProject(QgsProject *project)
Sets the QgsProject from which map layers are shown.
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QModelIndex indexFromLayer(QgsMapLayer *layer) const
indexFromLayer returns the model index for a given layer
void setAllowEmptyLayer(bool allowEmpty, const QString &text=QString(), const QIcon &icon=QIcon())
Sets whether an optional empty layer ("not set") option is present in the model.
void setAdditionalItems(const QStringList &items)
Sets a list of additional (non map layer) items to include at the end of the model.
QList< QgsMapLayer * > additionalLayers() const
Returns the list of additional layers added to the model.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
void setItemsCheckable(bool checkable)
setItemsCheckable defines if layers should be selectable in the widget
static QIcon iconForLayer(QgsMapLayer *layer)
Returns the icon corresponding to a specified map layer.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
QgsMapLayer * layerFromIndex(const QModelIndex &index) const
Returns the map layer corresponding to the specified index.
Qt::DropActions supportedDropActions() const override
void setLayersChecked(const QList< QgsMapLayer * > &layers)
Sets which layers are checked in the model.
void checkAll(Qt::CheckState checkState)
checkAll changes the checkstate for all the layers
void removeLayers(const QStringList &layerIds)
QStringList mimeTypes() const override
@ Additional
True if index corresponds to an additional (non map layer) item.
@ Layer
Stores pointer to the map layer itself.
@ LayerId
Stores the map layer ID.
@ Empty
True if index corresponds to the empty (not set) value.
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
bool itemsCanBeReordered() const
Returns true if items in the model can be reordered via drag and drop.
QMap< QString, Qt::CheckState > mLayersChecked
QgsMapLayerModel(QObject *parent=nullptr, QgsProject *project=nullptr)
QgsMapLayerModel creates a model to display layers in widgets.
QList< QgsMapLayer * > mLayers
void setAdditionalLayers(const QList< QgsMapLayer * > &layers)
Sets a list of additional layers to include in the model.
void addLayers(const QList< QgsMapLayer * > &layers)
QMimeData * mimeData(const QModelIndexList &indexes) const override
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
QString shortName() const
Returns the short name of the layer used by QGIS Server to identify the layer.
QString abstract() const
Returns the abstract of the layerused by QGIS Server in GetCapabilities request.
Base class for all map layer types.
Definition qgsmaplayer.h:75
QString name
Definition qgsmaplayer.h:79
virtual bool isSpatial() const
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
QgsCoordinateReferenceSystem crs
Definition qgsmaplayer.h:82
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
QString id
Definition qgsmaplayer.h:78
QgsLayerMetadata metadata
Definition qgsmaplayer.h:81
QString publicSource(bool hidePassword=false) const
Gets a version of the internal layer definition that has sensitive bits removed (for example,...
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
static QgsProject * instance()
Returns the QgsProject singleton instance.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
void layersWillBeRemoved(const QStringList &layerIds)
Emitted when one or more layers are about to be removed from the registry.
void layersAdded(const QList< QgsMapLayer * > &layers)
Emitted when one or more layers were added to the registry.
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID.
Represents a vector layer which manages a vector based data sets.
static QString displayString(Qgis::WkbType type)
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition qgis.h:5382