QGIS API Documentation 3.99.0-Master (09f76ad7019)
Loading...
Searching...
No Matches
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
18
19#include <QString>
20
21#include "moc_qgsvectortiledataitems.cpp"
22
23using namespace Qt::StringLiterals;
24
26
27QgsVectorTileRootItem::QgsVectorTileRootItem( QgsDataItem *parent, QString name, QString path )
28 : QgsConnectionsRootItem( parent, name, path, u"vectortile"_s )
29{
30 mCapabilities |= Qgis::BrowserItemCapability::Fast;
31 mIconName = u"mIconVectorTileLayer.svg"_s;
32 populate();
33}
34
35QVector<QgsDataItem *> QgsVectorTileRootItem::createChildren()
36{
37 QVector<QgsDataItem *> connections;
38 const auto connectionList = QgsVectorTileProviderConnection::connectionList();
39 for ( const QString &connName : connectionList )
40 {
41 const QString uri = QgsVectorTileProviderConnection::encodedLayerUri( QgsVectorTileProviderConnection::connection( connName ) );
42 QgsDataItem *conn = new QgsVectorTileLayerItem( this, connName, mPath + '/' + connName, uri );
43 connections.append( conn );
44 }
45 return connections;
46}
47
48
49// ---------------------------------------------------------------------------
50
51
52QgsVectorTileLayerItem::QgsVectorTileLayerItem( QgsDataItem *parent, QString name, QString path, const QString &encodedUri )
53 : QgsLayerItem( parent, name, path, encodedUri, Qgis::BrowserLayerType::VectorTile, QString() )
54{
56 mIconName = u"mIconVectorTileLayer.svg"_s;
57}
58
59
60// ---------------------------------------------------------------------------
61
62QString QgsVectorTileDataItemProvider::name()
63{
64 return u"Vector Tiles"_s;
65}
66
67QString QgsVectorTileDataItemProvider::dataProviderKey() const
68{
69 return u"vectortile"_s;
70}
71
72Qgis::DataItemProviderCapabilities QgsVectorTileDataItemProvider::capabilities() const
73{
75}
76
77QgsDataItem *QgsVectorTileDataItemProvider::createDataItem( const QString &path, QgsDataItem *parentItem )
78{
79 if ( path.isEmpty() )
80 return new QgsVectorTileRootItem( parentItem, QObject::tr( "Vector Tiles" ), u"vectortile:"_s );
81 return nullptr;
82}
83
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:59
@ NetworkSources
Network/internet source.
Definition qgis.h:1000
@ Populated
Children created.
Definition qgis.h:960
@ Fast
CreateChildren() is fast enough to be run in main thread when refreshing items, most root items (wms,...
Definition qgis.h:974
QFlags< DataItemProviderCapability > DataItemProviderCapabilities
Capabilities for data item providers.
Definition qgis.h:1011
A browser item that represents a root group of connections from a single data provider.
Base class for all items in the model.
Definition qgsdataitem.h:50
A browser item that represents a layer that can be opened with one of the providers.