QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgsproviderutils.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsproviderutils.cpp
3 ----------------------------
4 begin : June 2021
5 copyright : (C) 2021 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#include "qgsproviderutils.h"
18
20
21#include <QFileInfo>
22#include <QString>
23
24using namespace Qt::StringLiterals;
25
26bool QgsProviderUtils::sublayerDetailsAreIncomplete( const QList<QgsProviderSublayerDetails> &details, SublayerCompletenessFlags flags )
27{
28 const bool ignoreUnknownGeometryTypes = flags & SublayerCompletenessFlag::IgnoreUnknownGeometryType;
29 const bool ignoreUnknownFeatureCount = flags & SublayerCompletenessFlag::IgnoreUnknownFeatureCount;
30
31 for ( const QgsProviderSublayerDetails &sublayer : details )
32 {
33 switch ( sublayer.type() )
34 {
36 if ( sublayer.skippedContainerScan()
37 || ( !ignoreUnknownGeometryTypes && sublayer.wkbType() == Qgis::WkbType::Unknown )
38 || ( !ignoreUnknownFeatureCount && ( sublayer.featureCount() == static_cast< long long >( Qgis::FeatureCountState::Uncounted ) || sublayer.featureCount() == static_cast< long long >( Qgis::FeatureCountState::UnknownCount ) ) ) )
39 return true;
40 break;
41
44 if ( sublayer.skippedContainerScan() )
45 return true;
46 break;
47
54 break;
55 }
56 }
57
58 return false;
59}
60
62{
63 const QFileInfo info( path );
64 // default to base name of file
65 QString name = info.completeBaseName();
66
67 // special handling for .adf files -- use directory as base name, not the unhelpful .adf file name
68 if ( info.suffix().compare( "adf"_L1, Qt::CaseInsensitive ) == 0 )
69 {
70 const QString dirName = info.path();
71 name = QFileInfo( dirName ).completeBaseName();
72 }
73 // special handling for ept.json files -- use directory as base name
74 else if ( info.fileName().compare( "ept.json"_L1, Qt::CaseInsensitive ) == 0 )
75 {
76 const QString dirName = info.path();
77 name = QFileInfo( dirName ).completeBaseName();
78 }
79
80 return name;
81}
@ Group
Composite group layer. Added in QGIS 3.24.
Definition qgis.h:214
@ Plugin
Plugin based layer.
Definition qgis.h:209
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
Definition qgis.h:215
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
Definition qgis.h:212
@ Vector
Vector layer.
Definition qgis.h:207
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
Definition qgis.h:211
@ Mesh
Mesh layer. Added in QGIS 3.2.
Definition qgis.h:210
@ Raster
Raster layer.
Definition qgis.h:208
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
Definition qgis.h:213
@ Unknown
Unknown.
Definition qgis.h:295
Contains details about a sub layer available from a dataset.
static bool sublayerDetailsAreIncomplete(const QList< QgsProviderSublayerDetails > &details, QgsProviderUtils::SublayerCompletenessFlags flags=QgsProviderUtils::SublayerCompletenessFlags())
Returns true if the sublayer details are incomplete, and require a more in-depth scan.
QFlags< SublayerCompletenessFlag > SublayerCompletenessFlags
static QString suggestLayerNameFromFilePath(const QString &path)
Suggests a suitable layer name given only a file path.
@ IgnoreUnknownGeometryType
Indicates that an unknown geometry type should not be considered as incomplete.
@ IgnoreUnknownFeatureCount
Indicates that an unknown feature count should not be considered as incomplete.
@ Uncounted
Feature count not yet computed.
Definition qgis.h:572
@ UnknownCount
Provider returned an unknown feature count.
Definition qgis.h:573