QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
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 "moc_qgstiledscenedataitems.cpp"
17#include "qgsprovidermetadata.h"
19#include "qgsdataprovider.h"
20#include "qgsproviderregistry.h"
21
23
24QgsTiledSceneRootItem::QgsTiledSceneRootItem( QgsDataItem *parent, QString name, QString path )
25 : QgsConnectionsRootItem( parent, name, path, QStringLiteral( "tiled-scene" ) )
26{
27 mCapabilities |= Qgis::BrowserItemCapability::Fast;
28 mIconName = QStringLiteral( "mIconTiledScene.svg" );
29 populate();
30}
31
32QVector<QgsDataItem *> QgsTiledSceneRootItem::createChildren()
33{
34 QVector<QgsDataItem *> connections;
35 const auto connectionList = QgsTiledSceneProviderConnection::connectionList();
36 for ( const QString &connName : connectionList )
37 {
39 const QString uri = QgsTiledSceneProviderConnection::encodedLayerUri( connectionData );
40 QgsDataItem *conn = new QgsTiledSceneLayerItem( this, connName, mPath + '/' + connName, uri, connectionData.provider );
41 connections.append( conn );
42 }
43 return connections;
44}
45
46
47// ---------------------------------------------------------------------------
48
49
50QgsTiledSceneLayerItem::QgsTiledSceneLayerItem( QgsDataItem *parent, QString name, QString path, const QString &encodedUri, const QString &provider )
51 : QgsLayerItem( parent, name, path, encodedUri, Qgis::BrowserLayerType::TiledScene, provider )
52{
54
55 if ( QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata( provider ) )
56 {
57 mIcon = metadata->icon();
58 }
59 else
60 {
61 mIconName = QStringLiteral( "mIconTiledSceneLayer.svg" );
62 }
63}
64
65
66// ---------------------------------------------------------------------------
67
68QString QgsTiledSceneDataItemProvider::name()
69{
70 return QStringLiteral( "Scenes" );
71}
72
73QString QgsTiledSceneDataItemProvider::dataProviderKey() const
74{
75 return QStringLiteral( "tiled-scene" );
76}
77
78Qgis::DataItemProviderCapabilities QgsTiledSceneDataItemProvider::capabilities() const
79{
81}
82
83QgsDataItem *QgsTiledSceneDataItemProvider::createDataItem( const QString &path, QgsDataItem *parentItem )
84{
85 if ( path.isEmpty() )
86 return new QgsTiledSceneRootItem( parentItem, QObject::tr( "Scenes" ), QStringLiteral( "tiled-scene:" ) );
87
88 return nullptr;
89}
90
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.