QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgstiledscenedataitems.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgstiledscenedataitems.cpp
3 ---------------------
4 begin : June 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
16#include "qgsprovidermetadata.h"
18#include "qgsdataprovider.h"
19#include "qgsproviderregistry.h"
20
22
23QgsTiledSceneRootItem::QgsTiledSceneRootItem( QgsDataItem *parent, QString name, QString path )
24 : QgsConnectionsRootItem( parent, name, path, QStringLiteral( "tiled-scene" ) )
25{
26 mCapabilities |= Qgis::BrowserItemCapability::Fast;
27 mIconName = QStringLiteral( "mIconTiledScene.svg" );
28 populate();
29}
30
31QVector<QgsDataItem *> QgsTiledSceneRootItem::createChildren()
32{
33 QVector<QgsDataItem *> connections;
34 const auto connectionList = QgsTiledSceneProviderConnection::connectionList();
35 for ( const QString &connName : connectionList )
36 {
38 const QString uri = QgsTiledSceneProviderConnection::encodedLayerUri( connectionData );
39 QgsDataItem *conn = new QgsTiledSceneLayerItem( this, connName, mPath + '/' + connName, uri, connectionData.provider );
40 connections.append( conn );
41 }
42 return connections;
43}
44
45
46// ---------------------------------------------------------------------------
47
48
49QgsTiledSceneLayerItem::QgsTiledSceneLayerItem( QgsDataItem *parent, QString name, QString path, const QString &encodedUri, const QString &provider )
50 : QgsLayerItem( parent, name, path, encodedUri, Qgis::BrowserLayerType::TiledScene, provider )
51{
53
54 if ( QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata( provider ) )
55 {
56 mIcon = metadata->icon();
57 }
58 else
59 {
60 mIconName = QStringLiteral( "mIconTiledSceneLayer.svg" );
61 }
62}
63
64
65// ---------------------------------------------------------------------------
66
67QString QgsTiledSceneDataItemProvider::name()
68{
69 return QStringLiteral( "Scenes" );
70}
71
72QString QgsTiledSceneDataItemProvider::dataProviderKey() const
73{
74 return QStringLiteral( "tiled-scene" );
75}
76
77Qgis::DataItemProviderCapabilities QgsTiledSceneDataItemProvider::capabilities() const
78{
80}
81
82QgsDataItem *QgsTiledSceneDataItemProvider::createDataItem( const QString &path, QgsDataItem *parentItem )
83{
84 if ( path.isEmpty() )
85 return new QgsTiledSceneRootItem( parentItem, QObject::tr( "Scenes" ), QStringLiteral( "tiled-scene:" ) );
86
87 return nullptr;
88}
89
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
@ NetworkSources
Network/internet source.
@ Populated
Children created.
@ 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.
Definition qgis.h:926
A Collection that represents a root group of connections from a single data provider.
Base class for all items in the model.
Definition qgsdataitem.h:46
Item that represents a layer that can be opened with one of the providers.
Holds data provider key, description, and associated shared library file or function pointer informat...
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
static Data connection(const QString &name)
Returns connection details for the stored connection with the specified name.
static QStringList connectionList()
Returns a list of the stored connection names.
static QString encodedLayerUri(const Data &data)
Returns connection data encoded as a string containing a URI for a QgsTiledSceneLayer.
Represents decoded data of a tiled scene connection.