QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsvectortiledataitems.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectortiledataitems.cpp
3 ---------------------
4 begin : March 2020
5 copyright : (C) 2020 by Martin Dobias
6 email : wonder dot sk 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 ***************************************************************************/
17
19
20QgsVectorTileRootItem::QgsVectorTileRootItem( QgsDataItem *parent, QString name, QString path )
21 : QgsConnectionsRootItem( parent, name, path, QStringLiteral( "vectortile" ) )
22{
23 mCapabilities |= Qgis::BrowserItemCapability::Fast;
24 mIconName = QStringLiteral( "mIconVectorTileLayer.svg" );
25 populate();
26}
27
28QVector<QgsDataItem *> QgsVectorTileRootItem::createChildren()
29{
30 QVector<QgsDataItem *> connections;
31 const auto connectionList = QgsVectorTileProviderConnection::connectionList();
32 for ( const QString &connName : connectionList )
33 {
34 const QString uri = QgsVectorTileProviderConnection::encodedLayerUri( QgsVectorTileProviderConnection::connection( connName ) );
35 QgsDataItem *conn = new QgsVectorTileLayerItem( this, connName, mPath + '/' + connName, uri );
36 connections.append( conn );
37 }
38 return connections;
39}
40
41
42// ---------------------------------------------------------------------------
43
44
45QgsVectorTileLayerItem::QgsVectorTileLayerItem( QgsDataItem *parent, QString name, QString path, const QString &encodedUri )
46 : QgsLayerItem( parent, name, path, encodedUri, Qgis::BrowserLayerType::VectorTile, QString() )
47{
49 mIconName = QStringLiteral( "mIconVectorTileLayer.svg" );
50}
51
52
53// ---------------------------------------------------------------------------
54
55QString QgsVectorTileDataItemProvider::name()
56{
57 return QStringLiteral( "Vector Tiles" );
58}
59
60QString QgsVectorTileDataItemProvider::dataProviderKey() const
61{
62 return QStringLiteral( "vectortile" );
63}
64
65Qgis::DataItemProviderCapabilities QgsVectorTileDataItemProvider::capabilities() const
66{
68}
69
70QgsDataItem *QgsVectorTileDataItemProvider::createDataItem( const QString &path, QgsDataItem *parentItem )
71{
72 if ( path.isEmpty() )
73 return new QgsVectorTileRootItem( parentItem, QStringLiteral( "Vector Tiles" ), QStringLiteral( "vectortile:" ) );
74 return nullptr;
75}
76
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:727
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.
Definition: qgslayeritem.h:31