QGIS API Documentation 3.99.0-Master (8e76e220402)
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 "qgsmaplayermodel.h"
17
18#include "qgsiconutils.h"
20#include "qgsproject.h"
21#include "qgsvectorlayer.h"
22
23#include <QIcon>
24#include <QMimeData>
25#include <QString>
26
27#include "moc_qgsmaplayermodel.cpp"
28
29using namespace Qt::StringLiterals;
30
31QgsMapLayerModel::QgsMapLayerModel( const QList<QgsMapLayer *> &layers, QObject *parent, QgsProject *project )
32 : QAbstractItemModel( parent )
33 , mProject( project ? project : QgsProject::instance() ) // skip-keyword-check
34{
35 connect( mProject, static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsMapLayerModel::removeLayers );
36 addLayers( layers );
37}
38
40 : QAbstractItemModel( parent )
41 , mProject( project ? project : QgsProject::instance() ) // skip-keyword-check
42{
44 connect( mProject, static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsMapLayerModel::removeLayers );
45 addLayers( mProject->mapLayers().values() );
46}
47
49{
50 if ( mProject == ( project ? project : QgsProject::instance() ) ) // skip-keyword-check
51 return;
52
53 // remove layers from previous project
54 if ( mProject )
55 {
56 removeLayers( mProject->mapLayers().keys() );
58 disconnect( mProject, static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsMapLayerModel::removeLayers );
59 }
60
61 mProject = project ? project : QgsProject::instance(); // skip-keyword-check
62
64 connect( mProject, static_cast < void ( QgsProject::* )( const QStringList & ) >( &QgsProject::layersWillBeRemoved ), this, &QgsMapLayerModel::removeLayers );
65 addLayers( mProject->mapLayers().values() );
66}
67
68
70{
71 mItemCheckable = checkable;
72}
73
75{
76 mCanReorder = allow;
77}
78
80{
81 return mCanReorder;
82}
83
84void QgsMapLayerModel::checkAll( Qt::CheckState checkState )
85{
86 QMap<QString, Qt::CheckState>::iterator i = mLayersChecked.begin();
87 for ( ; i != mLayersChecked.end(); ++i )
88 {
89 *i = checkState;
90 }
91 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ) );
92}
93
94void QgsMapLayerModel::setAllowEmptyLayer( bool allowEmpty, const QString &text, const QIcon &icon )
95{
96 mEmptyText = text;
97 mEmptyIcon = icon;
98 if ( allowEmpty == mAllowEmpty )
99 return;
100
101 if ( allowEmpty )
102 {
103 beginInsertRows( QModelIndex(), 0, 0 );
104 mAllowEmpty = true;
105 endInsertRows();
106 }
107 else
108 {
109 beginRemoveRows( QModelIndex(), 0, 0 );
110 mAllowEmpty = false;
111 endRemoveRows();
112 }
113}
114
116{
117 if ( mShowCrs == showCrs )
118 return;
119
120 mShowCrs = showCrs;
121 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector<int>() << Qt::DisplayRole );
122}
123
124QList<QgsMapLayer *> QgsMapLayerModel::layersChecked( Qt::CheckState checkState )
125{
126 QList<QgsMapLayer *> layers;
127 const auto constMLayers = mLayers;
128 for ( QgsMapLayer *layer : constMLayers )
129 {
130 if ( mLayersChecked[layer->id()] == checkState )
131 {
132 layers.append( layer );
133 }
134 }
135 return layers;
136}
137
138void QgsMapLayerModel::setLayersChecked( const QList<QgsMapLayer *> &layers )
139{
140 QMap<QString, Qt::CheckState>::iterator i = mLayersChecked.begin();
141 for ( ; i != mLayersChecked.end(); ++i )
142 {
143 *i = Qt::Unchecked;
144 }
145 for ( const QgsMapLayer *layer : layers )
146 {
147 mLayersChecked[ layer->id() ] = Qt::Checked;
148 }
149 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector<int>() << Qt::CheckStateRole );
150}
151
153{
154 int r = mLayers.indexOf( layer );
155 if ( r >= 0 && mAllowEmpty )
156 r++;
157 return index( r, 0 );
158}
159
161{
162 return mProject->mapLayer( index.data( static_cast< int >( CustomRole::LayerId ) ).toString() );
163}
164
165void QgsMapLayerModel::setAdditionalItems( const QStringList &items )
166{
167 if ( items == mAdditionalItems )
168 return;
169
170 int offset = 0;
171 if ( mAllowEmpty )
172 offset++;
173
174 offset += mLayers.count();
175
176 //remove existing
177 if ( !mAdditionalItems.isEmpty() )
178 {
179 beginRemoveRows( QModelIndex(), offset, offset + mAdditionalItems.count() - 1 );
180 mAdditionalItems.clear();
181 endRemoveRows();
182 }
183
184 //add new
185 beginInsertRows( QModelIndex(), offset, offset + items.count() - 1 );
186 mAdditionalItems = items;
187 endInsertRows();
188}
189
190void QgsMapLayerModel::setAdditionalLayers( const QList<QgsMapLayer *> &layers )
191{
192 if ( layers == _qgis_listQPointerToRaw( mAdditionalLayers ) )
193 return;
194
195 QStringList layerIdsToRemove;
196 for ( QgsMapLayer *layer : std::as_const( mAdditionalLayers ) )
197 {
198 if ( layer )
199 layerIdsToRemove << layer->id();
200 }
201 removeLayers( layerIdsToRemove );
202
203 for ( QgsMapLayer *layer : layers )
204 {
205 if ( layer )
206 {
207 addLayers( { layer } );
208 const QString layerId = layer->id();
209 connect( layer, &QgsMapLayer::willBeDeleted, this, [this, layerId] { removeLayers( {layerId} ); } );
210 }
211 }
212
213 mAdditionalLayers = _qgis_listRawToQPointer( layers );
214}
215
216QList<QgsMapLayer *> QgsMapLayerModel::additionalLayers() const
217{
218 return _qgis_listQPointerToRaw( mAdditionalLayers );
219}
220
221void QgsMapLayerModel::removeLayers( const QStringList &layerIds )
222{
223 int offset = 0;
224 if ( mAllowEmpty )
225 offset++;
226
227 for ( const QString &layerId : layerIds )
228 {
229 QModelIndex startIndex = index( 0, 0 );
230 QModelIndexList list = match( startIndex, static_cast< int >( CustomRole::LayerId ), layerId, 1 );
231 if ( !list.isEmpty() )
232 {
233 QModelIndex index = list[0];
234 beginRemoveRows( QModelIndex(), index.row(), index.row() );
235 mLayersChecked.remove( layerId );
236 mLayers.removeAt( index.row() - offset );
237 endRemoveRows();
238 }
239 }
240}
241
242void QgsMapLayerModel::addLayers( const QList<QgsMapLayer *> &layers )
243{
244 if ( !layers.empty( ) )
245 {
246 int offset = 0;
247 if ( mAllowEmpty )
248 offset++;
249
250 beginInsertRows( QModelIndex(), mLayers.count() + offset, mLayers.count() + layers.count() - 1 + offset );
251 const auto constLayers = layers;
252 for ( QgsMapLayer *layer : constLayers )
253 {
254 mLayers.append( layer );
255 mLayersChecked.insert( layer->id(), Qt::Unchecked );
256 }
257 endInsertRows();
258 }
259}
260
261QModelIndex QgsMapLayerModel::index( int row, int column, const QModelIndex &parent ) const
262{
263 int offset = 0;
264 if ( mAllowEmpty )
265 offset++;
266
267 if ( hasIndex( row, column, parent ) )
268 {
269 QgsMapLayer *layer = nullptr;
270 if ( row - offset >= 0 && row - offset < mLayers.count() )
271 layer = mLayers.at( row - offset );
272
273 return createIndex( row, column, layer );
274 }
275
276 return QModelIndex();
277
278}
279
280QModelIndex QgsMapLayerModel::parent( const QModelIndex &child ) const
281{
282 Q_UNUSED( child )
283 return QModelIndex();
284}
285
286
287int QgsMapLayerModel::rowCount( const QModelIndex &parent ) const
288{
289 if ( parent.isValid() )
290 return 0;
291
292 return ( mAllowEmpty ? 1 : 0 ) + mLayers.length() + mAdditionalItems.count();
293}
294
295int QgsMapLayerModel::columnCount( const QModelIndex &parent ) const
296{
297 Q_UNUSED( parent )
298 return 1;
299}
300
301
302QVariant QgsMapLayerModel::data( const QModelIndex &index, int role ) const
303{
304 if ( !index.isValid() )
305 return QVariant();
306
307 bool isEmpty = index.row() == 0 && mAllowEmpty;
308 int additionalIndex = index.row() - ( mAllowEmpty ? 1 : 0 ) - mLayers.count();
309
310 switch ( role )
311 {
312 case Qt::DisplayRole:
313 case Qt::EditRole:
314 {
315 if ( index.row() == 0 && mAllowEmpty )
316 return mEmptyText;
317
318 if ( additionalIndex >= 0 )
319 return mAdditionalItems.at( additionalIndex );
320
321 QgsMapLayer *layer = mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) );
322 if ( !layer )
323 return QVariant();
324
325 if ( !mShowCrs || !layer->isSpatial() || role == Qt::EditRole )
326 {
327 return layer->name();
328 }
329 else
330 {
331 return tr( "%1 [%2]" ).arg( layer->name(), layer->crs().authid() );
332 }
333 }
334
335 case static_cast< int >( CustomRole::LayerId ):
336 {
337 if ( isEmpty || additionalIndex >= 0 )
338 return QVariant();
339
340 QgsMapLayer *layer = mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) );
341 return layer ? layer->id() : QVariant();
342 }
343
344 case static_cast< int >( CustomRole::Layer ):
345 {
346 if ( isEmpty || additionalIndex >= 0 )
347 return QVariant();
348
349 return QVariant::fromValue<QgsMapLayer *>( mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) ) );
350 }
351
352 case static_cast< int >( CustomRole::Empty ):
353 return isEmpty;
354
355 case static_cast< int >( CustomRole::Additional ):
356 return additionalIndex >= 0;
357
358 case Qt::CheckStateRole:
359 {
360 if ( mItemCheckable )
361 {
362 if ( isEmpty || additionalIndex >= 0 )
363 return QVariant();
364
365 QgsMapLayer *layer = mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) );
366 return layer ? mLayersChecked[layer->id()] : QVariant();
367 }
368
369 return QVariant();
370 }
371
372 case Qt::ToolTipRole:
373 {
374 QgsMapLayer *layer = mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) );
375 if ( layer )
376 {
377 QStringList parts;
378 QString title = !layer->metadata().title().isEmpty() ? layer->metadata().title() : ( layer->serverProperties()->title().isEmpty() ? layer->serverProperties()->shortName() : layer->serverProperties()->title() );
379 if ( title.isEmpty() )
380 title = layer->name();
381 title = "<b>" + title + "</b>";
382 if ( layer->isSpatial() && layer->crs().isValid() )
383 {
384 QString layerCrs = layer->crs().authid();
385 if ( !std::isnan( layer->crs().coordinateEpoch() ) )
386 {
387 layerCrs += u" @ %1"_s.arg( qgsDoubleToString( layer->crs().coordinateEpoch(), 3 ) );
388 }
389 if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer ) )
390 title = tr( "%1 (%2 - %3)" ).arg( title, QgsWkbTypes::displayString( vl->wkbType() ), layerCrs );
391 else
392 title = tr( "%1 (%2)" ).arg( title, layerCrs );
393 }
394 parts << title;
395
396 QString abstract = !layer->metadata().abstract().isEmpty() ? layer->metadata().abstract() : layer->serverProperties()->abstract();
397 if ( !abstract.isEmpty() )
398 parts << "<br/>" + abstract.replace( "\n"_L1, "<br/>"_L1 );
399 parts << "<i>" + layer->publicSource() + "</i>";
400 return parts.join( "<br/>"_L1 );
401 }
402 return QVariant();
403 }
404
405 case Qt::DecorationRole:
406 {
407 if ( isEmpty )
408 return mEmptyIcon.isNull() ? QVariant() : mEmptyIcon;
409
410 if ( additionalIndex >= 0 )
411 return QVariant();
412
413 QgsMapLayer *layer = mLayers.value( index.row() - ( mAllowEmpty ? 1 : 0 ) );
414 if ( !layer )
415 return QVariant();
416
417 return iconForLayer( layer );
418 }
419
420 default:
421 break;
422 }
423
424 return QVariant();
425}
426
427QHash<int, QByteArray> QgsMapLayerModel::roleNames() const
428{
429 QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
430 roles[static_cast< int >( CustomRole::LayerId ) ] = "layerId";
431 roles[static_cast< int >( CustomRole::Layer )] = "layer";
432
433 return roles;
434}
435
436Qt::ItemFlags QgsMapLayerModel::flags( const QModelIndex &index ) const
437{
438 if ( !index.isValid() )
439 {
440 if ( mCanReorder )
441 return Qt::ItemIsDropEnabled;
442 else
443 return Qt::ItemFlags();
444 }
445
446 bool isEmpty = index.row() == 0 && mAllowEmpty;
447 int additionalIndex = index.row() - ( mAllowEmpty ? 1 : 0 ) - mLayers.count();
448
449 Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
450
451 if ( mCanReorder && !isEmpty && additionalIndex < 0 )
452 {
453 flags |= Qt::ItemIsDragEnabled;
454 }
455
456 if ( mItemCheckable && !isEmpty && additionalIndex < 0 )
457 {
458 flags |= Qt::ItemIsUserCheckable;
459 }
460 return flags;
461}
462
463bool QgsMapLayerModel::insertRows( int row, int count, const QModelIndex &parent )
464{
465 if ( parent.isValid() )
466 return false;
467
468 int offset = 0;
469 if ( mAllowEmpty )
470 offset++;
471
472 beginInsertRows( parent, row, row + count - 1 );
473 for ( int i = row; i < row + count; ++i )
474 mLayers.insert( i - offset, nullptr );
475 endInsertRows();
476
477 return true;
478}
479
480bool QgsMapLayerModel::removeRows( int row, int count, const QModelIndex &parent )
481{
482 if ( parent.isValid() || row < 0 )
483 return false;
484
485 int offset = 0;
486 if ( mAllowEmpty )
487 {
488 if ( row == 0 )
489 return false;
490
491 offset++;
492 }
493
494 if ( row - offset > mLayers.count() - 1 )
495 {
496 return false;
497 }
498
499 beginRemoveRows( parent, row, row + count - 1 );
500 for ( int i = 0; i != count; ++i )
501 mLayers.removeAt( row - offset );
502 endRemoveRows();
503
504 return true;
505}
506
508{
509 QStringList types;
510 types << u"application/qgis.layermodeldata"_s;
511 return types;
512}
513
514bool QgsMapLayerModel::canDropMimeData( const QMimeData *data, Qt::DropAction action, int, int, const QModelIndex & ) const
515{
516 if ( !mCanReorder || action != Qt::MoveAction || !data->hasFormat( u"application/qgis.layermodeldata"_s ) )
517 return false;
518 return true;
519}
520
521QMimeData *QgsMapLayerModel::mimeData( const QModelIndexList &indexes ) const
522{
523 auto mimeData = std::make_unique< QMimeData >();
524
525 QByteArray encodedData;
526 QDataStream stream( &encodedData, QIODevice::WriteOnly );
527 QSet< QString > addedLayers;
528
529 for ( const QModelIndex &i : indexes )
530 {
531 if ( i.isValid() )
532 {
533 const QString id = data( index( i.row(), 0, i.parent() ), static_cast< int >( CustomRole::LayerId ) ).toString();
534 if ( !addedLayers.contains( id ) )
535 {
536 addedLayers.insert( id );
537 stream << id;
538 }
539 }
540 }
541 mimeData->setData( u"application/qgis.layermodeldata"_s, encodedData );
542 return mimeData.release();
543}
544
545bool QgsMapLayerModel::dropMimeData( const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent )
546{
547 if ( !canDropMimeData( data, action, row, column, parent ) || row < 0 )
548 return false;
549
550 if ( action == Qt::IgnoreAction )
551 return true;
552 else if ( action != Qt::MoveAction )
553 return false;
554
555 QByteArray encodedData = data->data( u"application/qgis.layermodeldata"_s );
556 QDataStream stream( &encodedData, QIODevice::ReadOnly );
557 QStringList newItems;
558 int rows = 0;
559
560 while ( !stream.atEnd() )
561 {
562 QString text;
563 stream >> text;
564 newItems << text;
565 ++rows;
566 }
567
568 insertRows( row, rows, QModelIndex() );
569 for ( const QString &text : std::as_const( newItems ) )
570 {
571 QModelIndex idx = index( row, 0, QModelIndex() );
572 setData( idx, text, static_cast< int >( CustomRole::LayerId ) );
573 row++;
574 }
575
576 return true;
577}
578
580{
581 return Qt::MoveAction;
582}
583
585{
586 return QgsIconUtils::iconForLayer( layer );
587}
588
589bool QgsMapLayerModel::setData( const QModelIndex &index, const QVariant &value, int role )
590{
591 if ( !index.isValid() )
592 return false;
593
594 bool isEmpty = index.row() == 0 && mAllowEmpty;
595 int additionalIndex = index.row() - ( mAllowEmpty ? 1 : 0 ) - mLayers.count();
596
597 switch ( role )
598 {
599 case Qt::CheckStateRole:
600 {
601 if ( !isEmpty && additionalIndex < 0 )
602 {
603 QgsMapLayer *layer = static_cast<QgsMapLayer *>( index.internalPointer() );
604 mLayersChecked[layer->id()] = ( Qt::CheckState )value.toInt();
605 emit dataChanged( index, index, QVector< int >() << Qt::CheckStateRole );
606 return true;
607 }
608 break;
609 }
610
611 case static_cast< int >( CustomRole::LayerId ):
612 if ( !isEmpty && additionalIndex < 0 )
613 {
614 mLayers[index.row() - ( mAllowEmpty ? 1 : 0 )] = mProject->mapLayer( value.toString() );
615 emit dataChanged( index, index );
616 return true;
617 }
618 break;
619
620 default:
621 break;
622 }
623
624 return false;
625}
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)
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)
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:83
QString name
Definition qgsmaplayer.h:87
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:90
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
QString id
Definition qgsmaplayer.h:86
QgsLayerMetadata metadata
Definition qgsmaplayer.h:89
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:113
static QgsProject * instance()
Returns the QgsProject singleton instance.
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.
Represents a vector layer which manages a vector based dataset.
static Q_INVOKABLE 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:6852