Branch data Line data Source code
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 : 0 : QgsMapLayerType QgsMapLayerFactory::typeFromString( const QString &string, bool &ok ) 21 : : { 22 : 0 : ok = true; 23 : 0 : if ( string.compare( QLatin1String( "vector" ), Qt::CaseInsensitive ) == 0 ) 24 : 0 : return QgsMapLayerType::VectorLayer; 25 : 0 : else if ( string.compare( QLatin1String( "raster" ), Qt::CaseInsensitive ) == 0 ) 26 : 0 : return QgsMapLayerType::RasterLayer; 27 : 0 : else if ( string.compare( QLatin1String( "mesh" ), Qt::CaseInsensitive ) == 0 ) 28 : 0 : return QgsMapLayerType::MeshLayer; 29 : 0 : else if ( string.compare( QLatin1String( "vector-tile" ), Qt::CaseInsensitive ) == 0 ) 30 : 0 : return QgsMapLayerType::VectorTileLayer; 31 : 0 : else if ( string.compare( QLatin1String( "point-cloud" ), Qt::CaseInsensitive ) == 0 ) 32 : 0 : return QgsMapLayerType::PointCloudLayer; 33 : 0 : else if ( string.compare( QLatin1String( "plugin" ), Qt::CaseInsensitive ) == 0 ) 34 : 0 : return QgsMapLayerType::PluginLayer; 35 : 0 : else if ( string.compare( QLatin1String( "annotation" ), Qt::CaseInsensitive ) == 0 ) 36 : 0 : return QgsMapLayerType::AnnotationLayer; 37 : : 38 : 0 : ok = false; 39 : 0 : return QgsMapLayerType::VectorLayer; 40 : 0 : } 41 : : 42 : 0 : QString QgsMapLayerFactory::typeToString( QgsMapLayerType type ) 43 : : { 44 : 0 : switch ( type ) 45 : : { 46 : : case QgsMapLayerType::VectorLayer: 47 : 0 : return QStringLiteral( "vector" ); 48 : : case QgsMapLayerType::RasterLayer: 49 : 0 : return QStringLiteral( "raster" ); 50 : : case QgsMapLayerType::PluginLayer: 51 : 0 : return QStringLiteral( "plugin" ); 52 : : case QgsMapLayerType::MeshLayer: 53 : 0 : return QStringLiteral( "mesh" ); 54 : : case QgsMapLayerType::VectorTileLayer: 55 : 0 : return QStringLiteral( "vector-tile" ); 56 : : case QgsMapLayerType::AnnotationLayer: 57 : 0 : return QStringLiteral( "annotation" ); 58 : : case QgsMapLayerType::PointCloudLayer: 59 : 0 : return QStringLiteral( "point-cloud" ); 60 : : } 61 : 0 : return QString(); 62 : 0 : }