QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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 ***************************************************************************/
16
17#include "qgssettings.h"
19#include "qgsdataprovider.h"
20
22
23QgsVectorTileRootItem::QgsVectorTileRootItem( QgsDataItem *parent, QString name, QString path )
24 : QgsConnectionsRootItem( parent, name, path, QStringLiteral( "vectortile" ) )
25{
26 mCapabilities |= Qgis::BrowserItemCapability::Fast;
27 mIconName = QStringLiteral( "mIconVectorTileLayer.svg" );
28 populate();
29}
30
31QVector<QgsDataItem *> QgsVectorTileRootItem::createChildren()
32{
33 QVector<QgsDataItem *> connections;
34 const auto connectionList = QgsVectorTileProviderConnection::connectionList();
35 for ( const QString &connName : connectionList )
36 {
37 const QString uri = QgsVectorTileProviderConnection::encodedLayerUri( QgsVectorTileProviderConnection::connection( connName ) );
38 QgsDataItem *conn = new QgsVectorTileLayerItem( this, connName, mPath + '/' + connName, uri );
39 connections.append( conn );
40 }
41 return connections;
42}
43
44
45// ---------------------------------------------------------------------------
46
47
48QgsVectorTileLayerItem::QgsVectorTileLayerItem( QgsDataItem *parent, QString name, QString path, const QString &encodedUri )
49 : QgsLayerItem( parent, name, path, encodedUri, Qgis::BrowserLayerType::VectorTile, QString() )
50{
52 mIconName = QStringLiteral( "mIconVectorTileLayer.svg" );
53}
54
55
56// ---------------------------------------------------------------------------
57
58QString QgsVectorTileDataItemProvider::name()
59{
60 return QStringLiteral( "Vector Tiles" );
61}
62
63QString QgsVectorTileDataItemProvider::dataProviderKey() const
64{
65 return QStringLiteral( "vectortile" );
66}
67
68int QgsVectorTileDataItemProvider::capabilities() const
69{
71}
72
73QgsDataItem *QgsVectorTileDataItemProvider::createDataItem( const QString &path, QgsDataItem *parentItem )
74{
75 if ( path.isEmpty() )
76 return new QgsVectorTileRootItem( parentItem, QStringLiteral( "Vector Tiles" ), QStringLiteral( "vectortile:" ) );
77 return nullptr;
78}
79
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:72
@ Populated
Children created.
@ Fast
CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms,...
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