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