QGIS API Documentation 3.99.0-Master (d270888f95f)
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 &&
39 ( sublayer.featureCount() == static_cast< long long >( Qgis::FeatureCountState::Uncounted )
40 || sublayer.featureCount() == static_cast< long long >( Qgis::FeatureCountState::UnknownCount ) ) ) )
41 return true;
42 break;
43
46 if ( sublayer.skippedContainerScan() )
47 return true;
48 break;
49
56 break;
57 }
58 }
59
60 return false;
61}
62
64{
65 const QFileInfo info( path );
66 // default to base name of file
67 QString name = info.completeBaseName();
68
69 // special handling for .adf files -- use directory as base name, not the unhelpful .adf file name
70 if ( info.suffix().compare( "adf"_L1, Qt::CaseInsensitive ) == 0 )
71 {
72 const QString dirName = info.path();
73 name = QFileInfo( dirName ).completeBaseName();
74 }
75 // special handling for ept.json files -- use directory as base name
76 else if ( info.fileName().compare( "ept.json"_L1, Qt::CaseInsensitive ) == 0 )
77 {
78 const QString dirName = info.path();
79 name = QFileInfo( dirName ).completeBaseName();
80 }
81
82 return name;
83}
@ Group
Composite group layer. Added in QGIS 3.24.
Definition qgis.h:201
@ Plugin
Plugin based layer.
Definition qgis.h:196
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
Definition qgis.h:202
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
Definition qgis.h:199
@ Vector
Vector layer.
Definition qgis.h:194
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
Definition qgis.h:198
@ Mesh
Mesh layer. Added in QGIS 3.2.
Definition qgis.h:197
@ Raster
Raster layer.
Definition qgis.h:195
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
Definition qgis.h:200
@ Unknown
Unknown.
Definition qgis.h:281
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:565
@ UnknownCount
Provider returned an unknown feature count.
Definition qgis.h:566