QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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 
29 class CORE_EXPORT QgsLayerItem : public QgsDataItem
30 {
31  Q_OBJECT
32 
33  public:
34 
38  QgsLayerItem( QgsDataItem *parent, const QString &name, const QString &path, const QString &uri, Qgis::BrowserLayerType layerType, const QString &providerKey );
39 
40 #ifdef SIP_RUN
41  SIP_PYOBJECT __repr__();
42  % MethodCode
43  QString str = QStringLiteral( "<QgsLayerItem: \"%1\" %2>" ).arg( sipCpp->name(), sipCpp->path() );
44  sipRes = PyUnicode_FromString( str.toUtf8().constData() );
45  % End
46 #endif
47 
48  // --- reimplemented from QgsDataItem ---
49 
50  bool equal( const QgsDataItem *other ) override;
51 
52  bool hasDragEnabled() const override { return true; }
53 
54  QgsMimeDataUtils::UriList mimeUris() const override;
55 
56  // --- New virtual methods for layer item derived classes ---
57 
59  QgsMapLayerType mapLayerType() const;
60 
65  static Qgis::BrowserLayerType typeFromMapLayer( QgsMapLayer *layer );
66 
68  QString uri() const { return mUri; }
69 
71  QString providerKey() const { return mProviderKey; }
72 
77  QStringList supportedCrs() const { return mSupportedCRS; }
78 
83  QStringList supportedFormats() const { return mSupportFormats; }
84 
89  virtual QString comments() const { return QString(); }
90 
95  static QString layerTypeAsString( Qgis::BrowserLayerType layerType );
96 
101  static QString iconName( Qgis::BrowserLayerType layerType );
102 
109  Q_DECL_DEPRECATED virtual bool deleteLayer() SIP_DEPRECATED;
110 
111  protected:
113  QString mUri;
115  Qgis::BrowserLayerType mLayerType;
117  QStringList mSupportedCRS;
119  QStringList mSupportFormats;
120 
121  public:
122 
127  static QIcon iconForWkbType( QgsWkbTypes::Type type );
128 
129  static QIcon iconPoint();
130  static QIcon iconLine();
131  static QIcon iconPolygon();
132  static QIcon iconTable();
133  static QIcon iconRaster();
134  static QIcon iconDefault();
136  static QIcon iconMesh();
138  static QIcon iconVectorTile();
140  static QIcon iconPointCloud();
142  virtual QString layerName() const { return name(); }
144 
145 };
146 
147 #endif // QGSLAYERITEM_H
148 
149 
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:63
BrowserLayerType
Browser item layer types.
Definition: qgis.h:300
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).
Definition: qgsdataitem.h:345
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 mProviderKey
Definition: qgsdataitem.h:450
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.
Definition: qgslayeritem.h:30
QStringList supportedFormats() const
Returns the supported formats.
Definition: qgslayeritem.h:83
QString uri() const
Returns layer uri or empty string if layer cannot be created.
Definition: qgslayeritem.h:68
QStringList supportedCrs() const
Returns the supported CRS.
Definition: qgslayeritem.h:77
virtual QString comments() const
Returns comments of the layer.
Definition: qgslayeritem.h:89
QString providerKey() const
Returns provider key.
Definition: qgslayeritem.h:71
bool hasDragEnabled() const override
Returns true if the item may be dragged.
Definition: qgslayeritem.h:52
Base class for all map layer types.
Definition: qgsmaplayer.h:73
QList< QgsMimeDataUtils::Uri > UriList
Handles storage of information regarding WKB types and their properties.
Definition: qgswkbtypes.h:42
QgsMapLayerType
Types of layers that can be added to a map.
Definition: qgis.h:47
#define str(x)
Definition: qgis.cpp:37
#define SIP_DEPRECATED
Definition: qgis_sip.h:106