QGIS API Documentation 3.41.0-Master (d5b93354e9c)
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#include "moc_qgsvectortiledataitems.cpp"
18
20
21QgsVectorTileRootItem::QgsVectorTileRootItem( QgsDataItem *parent, QString name, QString path )
22 : QgsConnectionsRootItem( parent, name, path, QStringLiteral( "vectortile" ) )
23{
24 mCapabilities |= Qgis::BrowserItemCapability::Fast;
25 mIconName = QStringLiteral( "mIconVectorTileLayer.svg" );
26 populate();
27}
28
29QVector<QgsDataItem *> QgsVectorTileRootItem::createChildren()
30{
31 QVector<QgsDataItem *> connections;
32 const auto connectionList = QgsVectorTileProviderConnection::connectionList();
33 for ( const QString &connName : connectionList )
34 {
35 const QString uri = QgsVectorTileProviderConnection::encodedLayerUri( QgsVectorTileProviderConnection::connection( connName ) );
36 QgsDataItem *conn = new QgsVectorTileLayerItem( this, connName, mPath + '/' + connName, uri );
37 connections.append( conn );
38 }
39 return connections;
40}
41
42
43// ---------------------------------------------------------------------------
44
45
46QgsVectorTileLayerItem::QgsVectorTileLayerItem( QgsDataItem *parent, QString name, QString path, const QString &encodedUri )
47 : QgsLayerItem( parent, name, path, encodedUri, Qgis::BrowserLayerType::VectorTile, QString() )
48{
50 mIconName = QStringLiteral( "mIconVectorTileLayer.svg" );
51}
52
53
54// ---------------------------------------------------------------------------
55
56QString QgsVectorTileDataItemProvider::name()
57{
58 return QStringLiteral( "Vector Tiles" );
59}
60
61QString QgsVectorTileDataItemProvider::dataProviderKey() const
62{
63 return QStringLiteral( "vectortile" );
64}
65
66Qgis::DataItemProviderCapabilities QgsVectorTileDataItemProvider::capabilities() const
67{
69}
70
71QgsDataItem *QgsVectorTileDataItemProvider::createDataItem( const QString &path, QgsDataItem *parentItem )
72{
73 if ( path.isEmpty() )
74 return new QgsVectorTileRootItem( parentItem, QObject::tr( "Vector Tiles" ), QStringLiteral( "vectortile:" ) );
75 return nullptr;
76}
77
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.