QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsmaplayerfactory.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaplayerfactory.cpp
3  --------------------------------------
4  Date : March 2021
5  Copyright : (C) 2021 by Nyall Dawson
6  Email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgsmaplayerfactory.h"
19 
20 QgsMapLayerType QgsMapLayerFactory::typeFromString( const QString &string, bool &ok )
21 {
22  ok = true;
23  if ( string.compare( QLatin1String( "vector" ), Qt::CaseInsensitive ) == 0 )
25  else if ( string.compare( QLatin1String( "raster" ), Qt::CaseInsensitive ) == 0 )
27  else if ( string.compare( QLatin1String( "mesh" ), Qt::CaseInsensitive ) == 0 )
29  else if ( string.compare( QLatin1String( "vector-tile" ), Qt::CaseInsensitive ) == 0 )
31  else if ( string.compare( QLatin1String( "point-cloud" ), Qt::CaseInsensitive ) == 0 )
33  else if ( string.compare( QLatin1String( "plugin" ), Qt::CaseInsensitive ) == 0 )
35  else if ( string.compare( QLatin1String( "annotation" ), Qt::CaseInsensitive ) == 0 )
37 
38  ok = false;
40 }
41 
43 {
44  switch ( type )
45  {
47  return QStringLiteral( "vector" );
49  return QStringLiteral( "raster" );
51  return QStringLiteral( "plugin" );
53  return QStringLiteral( "mesh" );
55  return QStringLiteral( "vector-tile" );
57  return QStringLiteral( "annotation" );
59  return QStringLiteral( "point-cloud" );
60  }
61  return QString();
62 }
static QgsMapLayerType typeFromString(const QString &string, bool &ok)
Returns the map layer type corresponding a string value.
static QString typeToString(QgsMapLayerType type)
Converts a map layer type to a string value.
QgsMapLayerType
Types of layers that can be added to a map.
Definition: qgis.h:46
@ PointCloudLayer
Added in 3.18.
@ MeshLayer
Added in 3.2.
@ VectorTileLayer
Added in 3.14.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.