QGIS API Documentation 4.3.0-Master (0cfde48c85b)
Loading...
Searching...
No Matches
qgslayeritem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayeritem.h
3 -------------------
4 begin : 2011-04-01
5 copyright : (C) 2011 Radim Blazek
6 email : radim dot blazek at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QGSLAYERITEM_H
18#define QGSLAYERITEM_H
19
20#include "qgis.h"
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgsdataitem.h"
24#include "qgslayermetadata.h"
25
26#include <QString>
27
28using namespace Qt::StringLiterals;
29
34class CORE_EXPORT QgsLayerItem : public QgsDataItem
35{
36 Q_OBJECT
37
38 public:
42 QgsLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, Qgis::BrowserLayerType layerType, const QString &providerKey );
43
44#ifdef SIP_RUN
45 // clang-format off
46 SIP_PYOBJECT __repr__();
47 % MethodCode
48 QString str = u"<QgsLayerItem: \"%1\" %2>"_s.arg( sipCpp->name(), sipCpp->path() );
49 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
50 % End
51// clang-format on
52#endif
53
54 // --- reimplemented from QgsDataItem ---
55
56 bool equal( const QgsDataItem *other ) override;
57
58 bool hasDragEnabled() const override { return true; }
59
60 QgsMimeDataUtils::UriList mimeUris() const override;
61
62 // --- New virtual methods for layer item derived classes ---
63
64#ifndef SIP_RUN
79
89 virtual QList< LayerUriWithDetails > layerUrisWithDetails() const;
90#endif
91
96
102
104 QString uri() const { return mUri; }
105
109 QStringList supportedCrs() const { return mSupportedCRS; }
110
114 QStringList supportedFormats() const { return mSupportFormats; }
115
119 virtual QString comments() const { return QString(); }
120
126
131 static QString layerTypeAsString( Qgis::BrowserLayerType layerType );
132
137 static QString iconName( Qgis::BrowserLayerType layerType );
138
145 Q_DECL_DEPRECATED virtual bool deleteLayer() SIP_DEPRECATED;
146
147 protected:
149 QString mUri;
151 Qgis::BrowserLayerType mLayerType;
153 QStringList mSupportedCRS;
155 QStringList mSupportFormats;
156
157 public:
162 static QIcon iconForWkbType( Qgis::WkbType type );
163
164 static QIcon iconPoint();
165 static QIcon iconLine();
166 static QIcon iconPolygon();
167 static QIcon iconTable();
168 static QIcon iconRaster();
169 static QIcon iconDefault();
171 static QIcon iconMesh();
173 static QIcon iconVectorTile();
175 static QIcon iconPointCloud();
177 virtual QString layerName() const { return name(); }
179
185 const QgsLayerMetadata &layerMetadata() const;
186
191 void setLayerMetadata( const QgsLayerMetadata &metadata );
192
193 private:
194 QgsLayerMetadata mLayerMetadata;
195};
196
197#endif // QGSLAYERITEM_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
@ AddComments
Comments can be added to the layer item.
Definition qgis.h:254
BrowserLayerType
Browser item layer types.
Definition qgis.h:1102
LayerType
Types of layers that can be added to a map.
Definition qgis.h:206
QFlags< LayerItemCapability > LayerItemCapabilities
Flags for layer item capabilities.
Definition qgis.h:263
Provides common functionality for database based connections.
virtual QgsAbstractDatabaseProviderConnection * databaseConnection() const
For data items that represent a DB connection or one of its children, this method returns a connectio...
Qgis::BrowserItemType type() const
QgsDataItem(Qgis::BrowserItemType type, QgsDataItem *parent, const QString &name, const QString &path, const QString &providerKey=QString())
Constructor for QgsDataItem, with the specified parent item.
QString name() const
Returns the name of the item (the displayed text for the item).
QString path() const
QgsDataItem * parent() const
Gets item parent.
virtual QgsMimeDataUtils::UriList mimeUris() const
Returns mime URIs for the data item, most data providers will only return a single URI but some data ...
QString providerKey() const
Returns the provider key that created this item (e.g.
virtual bool equal(const QgsDataItem *other)
Returns true if this item is equal to another item (by testing item type and path).
QStringList supportedFormats() const
Returns the supported formats.
static QIcon iconPoint()
QString uri() const
Returns layer uri or empty string if layer cannot be created.
static Qgis::BrowserLayerType typeFromMapLayer(QgsMapLayer *layer)
Returns the layer item type corresponding to a QgsMapLayer layer.
QStringList mSupportedCRS
The list of supported CRS.
static QIcon iconLine()
QString mUri
The URI.
QStringList supportedCrs() const
Returns the supported CRS.
virtual QList< LayerUriWithDetails > layerUrisWithDetails() const
Returns a list of layer mime URIs, with additional details.
static QIcon iconTable()
static QIcon iconDefault()
virtual QString comments() const
Returns comments of the layer.
static QIcon iconRaster()
static QIcon iconMesh()
Returns icon for mesh layer type.
QgsLayerItem(QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, Qgis::BrowserLayerType layerType, const QString &providerKey)
Constructor for QgsLayerItem.
Qgis::BrowserLayerType mLayerType
The layer type.
QStringList mSupportFormats
The list of supported formats.
static QIcon iconForWkbType(Qgis::WkbType type)
Returns the icon for a vector layer whose geometry type is provided.
virtual Qgis::LayerItemCapabilities layerCapabilities() const
Returns the layer item cpabilities.
bool hasDragEnabled() const override
Returns true if the item may be dragged.
Qgis::LayerType mapLayerType() const
Returns the associated map layer type.
static QIcon iconPolygon()
static QIcon iconPointCloud()
Returns icon for point cloud layer.
static QIcon iconVectorTile()
Returns icon for vector tile layer.
virtual QString layerName() const
Returns the layer name.
A structured metadata store for a map layer.
Base class for all map layer types.
Definition qgsmaplayer.h:83
QList< QgsMimeDataUtils::Uri > UriList
#define SIP_DEPRECATED
Definition qgis_sip.h:113
Encapsulates a layer mime URI, with additional details.
QString userFriendlyDescription
A user-friendly, translated description of the layer type.
QgsMimeDataUtils::Uri uri
Layer URI.