26#include "moc_qgssensorthingsdataitems.cpp"
28using namespace Qt::StringLiterals;
36QgsSensorThingsRootItem::QgsSensorThingsRootItem(
QgsDataItem *parent, QString name, QString path )
40 mIconName = u
"mIconSensorThings.svg"_s;
44QVector<QgsDataItem *> QgsSensorThingsRootItem::createChildren()
46 QVector<QgsDataItem *> connections;
48 for (
const QString &connName : connectionList )
50 QgsDataItem *conn =
new QgsSensorThingsConnectionItem(
this, connName, mPath +
'/' + connName );
51 connections.append( conn );
60QgsSensorThingsConnectionItem::QgsSensorThingsConnectionItem(
QgsDataItem *parent,
const QString &name,
const QString &path )
64 mIconName = u
"mIconConnect.svg"_s;
68bool QgsSensorThingsConnectionItem::equal(
const QgsDataItem *other )
70 const QgsSensorThingsConnectionItem *o = qobject_cast<const QgsSensorThingsConnectionItem *>( other );
71 return ( type() == other->
type() && o && mPath == o->mPath && mName == o->mName );
74QVector<QgsDataItem *> QgsSensorThingsConnectionItem::createChildren()
76 QVector<QgsDataItem *> children;
84 const QMetaEnum entities = QMetaEnum::fromType<Qgis::SensorThingsEntity>();
85 for ( qint32 i = 0, count = entities.keyCount(); i < count; i++ )
92 QVariantMap entityUriParts = connectionUriParts;
115QgsSensorThingsEntityContainerItem::QgsSensorThingsEntityContainerItem(
119 , mEntityUriParts( entityUriParts )
120 , mEntityType( entityType )
121 , mConnectionName( connectionName )
127bool QgsSensorThingsEntityContainerItem::equal(
const QgsDataItem *other )
129 const QgsSensorThingsEntityContainerItem *o = qobject_cast<const QgsSensorThingsEntityContainerItem *>( other );
130 return ( type() == other->
type() && o && mPath == o->mPath && mName == o->mName );
133QVector<QgsDataItem *> QgsSensorThingsEntityContainerItem::createChildren()
135 QVector<QgsDataItem *> children;
138 QList< Qgis::WkbType > compatibleTypes;
159 for (
const Qgis::WkbType wkbType : std::as_const( compatibleTypes ) )
161 QVariantMap geometryUriParts = mEntityUriParts;
167 geometryUriParts.insert( u
"geometryType"_s, u
"point"_s );
168 name = tr(
"Points" );
172 geometryUriParts.insert( u
"geometryType"_s, u
"multipoint"_s );
173 name = tr(
"MultiPoints" );
177 geometryUriParts.insert( u
"geometryType"_s, u
"line"_s );
178 name = tr(
"Lines" );
182 geometryUriParts.insert( u
"geometryType"_s, u
"polygon"_s );
183 name = tr(
"Polygons" );
187 geometryUriParts.remove( u
"geometryType"_s );
188 name = tr(
"No Geometry" );
194 children.append(
new QgsSensorThingsLayerEntityItem(
this, name, mPath +
'/' + name, geometryUriParts, QgsSensorThingsProvider::SENSORTHINGS_PROVIDER_KEY, layerType, mEntityType, mConnectionName ) );
195 children.last()->setSortKey( sortKey++ );
205QgsSensorThingsLayerEntityItem::QgsSensorThingsLayerEntityItem(
208 :
QgsLayerItem( parent, name, path,
QgsProviderRegistry::instance()->encodeUri( QgsSensorThingsProvider::SENSORTHINGS_PROVIDER_KEY, uriParts ), type, provider )
209 , mUriParts( uriParts )
210 , mEntityType( entityType )
211 , mConnectionName( connectionName )
216QString QgsSensorThingsLayerEntityItem::layerName()
const
221 const QString geometryType = mUriParts.value( u
"geometryType"_s ).toString();
222 QString geometryNamePart;
223 if ( geometryType.compare(
"point"_L1, Qt::CaseInsensitive ) == 0 || geometryType.compare(
"multipoint"_L1, Qt::CaseInsensitive ) == 0 )
225 geometryNamePart = tr(
"Points" );
227 else if ( geometryType.compare(
"line"_L1, Qt::CaseInsensitive ) == 0 )
229 geometryNamePart = tr(
"Lines" );
231 else if ( geometryType.compare(
"polygon"_L1, Qt::CaseInsensitive ) == 0 )
233 geometryNamePart = tr(
"Polygons" );
236 if ( !geometryNamePart.isEmpty() )
257QString QgsSensorThingsDataItemProvider::name()
259 return u
"SensorThings"_s;
262QString QgsSensorThingsDataItemProvider::dataProviderKey()
const
264 return u
"sensorthings"_s;
272QgsDataItem *QgsSensorThingsDataItemProvider::createDataItem(
const QString &path,
QgsDataItem *parentItem )
274 if ( path.isEmpty() )
275 return new QgsSensorThingsRootItem( parentItem, QObject::tr(
"SensorThings" ), u
"sensorthings:"_s );
@ NetworkSources
Network/internet source.
@ Populated
Children created.
@ Collapse
The collapse/expand status for this items children should be ignored in order to avoid undesired netw...
@ Fast
CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms,...
QFlags< DataItemProviderCapability > DataItemProviderCapabilities
Capabilities for data item providers.
SensorThingsEntity
OGC SensorThings API entity types.
BrowserLayerType
Browser item layer types.
@ Point
Vector point layer.
@ Polygon
Vector polygon layer.
@ TableLayer
Vector non-spatial layer.
WkbType
The WKB type describes the number of dimensions a geometry has.
@ MultiPolygon
MultiPolygon.
@ MultiLineString
MultiLineString.
A browser item that represents a root group of connections from a single data provider.
A browser item for collections of data.
Base class for all items in the model.
Qgis::BrowserItemType type() const
A browser item that represents a layer that can be opened with one of the providers.
A registry / canonical manager of data providers.
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
static QString encodedLayerUri(const Data &data)
Returns connection data encoded as a string containing a URI for a SensorThings vector data provider.
static QStringList connectionList()
Returns a list of the stored connection names.
static Data connection(const QString &name)
Returns connection details for the stored connection with the specified name.
static Qgis::GeometryType geometryTypeForEntity(Qgis::SensorThingsEntity type)
Returns the geometry type for if the specified entity type.
static QString displayString(Qgis::SensorThingsEntity type, bool plural=false)
Converts a Qgis::SensorThingsEntity type to a user-friendly translated string.
static bool entityTypeHasGeometry(Qgis::SensorThingsEntity type)
Returns true if the specified entity type can have geometry attached.
static ServiceCapabilities determineServiceCapabilities(const QString &uri, QgsFeedback *feedback=nullptr, const QString &authCfg=QString())
Retrieves general service capabilities for a SensorThings server.
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Represents decoded data of a SensorThings connection.
SensorThings service capabilities.
QSet< Qgis::SensorThingsEntity > availableEntities
Available SensorThings entities.