QGIS API Documentation 3.41.0-Master (d5b93354e9c)
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_sip.h"
21#include "qgis_core.h"
22#include "qgis.h"
23#include "qgsdataitem.h"
24#include "qgslayermetadata.h"
25
30class CORE_EXPORT QgsLayerItem : public QgsDataItem
31{
32 Q_OBJECT
33
34 public:
35
39 QgsLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, Qgis::BrowserLayerType layerType, const QString &providerKey );
40
41#ifdef SIP_RUN
42 SIP_PYOBJECT __repr__();
43 % MethodCode
44 QString str = QStringLiteral( "<QgsLayerItem: \"%1\" %2>" ).arg( sipCpp->name(), sipCpp->path() );
45 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
46 % End
47#endif
48
49 // --- reimplemented from QgsDataItem ---
50
51 bool equal( const QgsDataItem *other ) override;
52
53 bool hasDragEnabled() const override { return true; }
54
55 QgsMimeDataUtils::UriList mimeUris() const override;
56
57 // --- New virtual methods for layer item derived classes ---
58
62 Qgis::LayerType mapLayerType() const;
63
68 static Qgis::BrowserLayerType typeFromMapLayer( QgsMapLayer *layer );
69
71 QString uri() const { return mUri; }
72
76 QStringList supportedCrs() const { return mSupportedCRS; }
77
81 QStringList supportedFormats() const { return mSupportFormats; }
82
86 virtual QString comments() const { return QString(); }
87
92 static QString layerTypeAsString( Qgis::BrowserLayerType layerType );
93
98 static QString iconName( Qgis::BrowserLayerType layerType );
99
106 Q_DECL_DEPRECATED virtual bool deleteLayer() SIP_DEPRECATED;
107
108 protected:
110 QString mUri;
112 Qgis::BrowserLayerType mLayerType;
114 QStringList mSupportedCRS;
116 QStringList mSupportFormats;
117
118 public:
119
124 static QIcon iconForWkbType( Qgis::WkbType type );
125
126 static QIcon iconPoint();
127 static QIcon iconLine();
128 static QIcon iconPolygon();
129 static QIcon iconTable();
130 static QIcon iconRaster();
131 static QIcon iconDefault();
133 static QIcon iconMesh();
135 static QIcon iconVectorTile();
137 static QIcon iconPointCloud();
139 virtual QString layerName() const { return name(); }
141
147 const QgsLayerMetadata &layerMetadata() const;
148
153 void setLayerMetadata( const QgsLayerMetadata &metadata );
154
155 private:
156
157 QgsLayerMetadata mLayerMetadata;
158
159};
160
161#endif // QGSLAYERITEM_H
162
163
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
BrowserLayerType
Browser item layer types.
Definition qgis.h:935
LayerType
Types of layers that can be added to a map.
Definition qgis.h:169
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
Base class for all items in the model.
Definition qgsdataitem.h:46
virtual QgsAbstractDatabaseProviderConnection * databaseConnection() const
For data items that represent a DB connection or one of its children, this method returns a connectio...
QString name() const
Returns the name of the item (the displayed text for the item).
virtual QgsMimeDataUtils::UriList mimeUris() const
Returns mime URIs for the data item, most data providers will only return a single URI but some data ...
virtual bool equal(const QgsDataItem *other)
Returns true if this item is equal to another item (by testing item type and path).
Item that represents a layer that can be opened with one of the providers.
QStringList supportedFormats() const
Returns the supported formats.
QString uri() const
Returns layer uri or empty string if layer cannot be created.
QStringList supportedCrs() const
Returns the supported CRS.
virtual QString comments() const
Returns comments of the layer.
bool hasDragEnabled() const override
Returns true if the item may be dragged.
A structured metadata store for a map layer.
Base class for all map layer types.
Definition qgsmaplayer.h:76
QList< QgsMimeDataUtils::Uri > UriList
#define SIP_DEPRECATED
Definition qgis_sip.h:106