QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgsfilebaseddataitemprovider.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsfilebaseddataitemprovider.h
3 --------------------------------------
4 Date : July 2021
5 Copyright : (C) 2021 by Nyall Dawson
6 Email : nyall dot dawson 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 ***************************************************************************/
15
16#ifndef QGSFILEBASEDDATAITEMPROVIDER_H
17#define QGSFILEBASEDDATAITEMPROVIDER_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgsdataitemprovider.h"
23#include "qgslayeritem.h"
26#include <QString>
27#include <QVector>
28
30
31#define SIP_NO_FILE
32
33class QgsDataItem;
34
45class CORE_EXPORT QgsProviderSublayerItem final: public QgsLayerItem
46{
47 Q_OBJECT
48 public:
49
57 QgsProviderSublayerItem( QgsDataItem *parent, const QString &name, const QgsProviderSublayerDetails &details, const QString &filePath );
58 QString layerName() const override;
59 QVector<QgsDataItem *> createChildren() override;
61
67 QgsProviderSublayerDetails sublayerDetails() const;
68
69 private:
70
71 static Qgis::BrowserLayerType layerTypeFromSublayer( const QgsProviderSublayerDetails &sublayer );
72
74
75};
76
77
85{
86 Q_OBJECT
87 public:
88
95 QgsFileDataCollectionGroupItem( QgsDataItem *parent, const QString &groupName, const QString &path );
96
100 void appendSublayer( const QgsProviderSublayerDetails &sublayer );
101
102 bool hasDragEnabled() const override;
103 QgsMimeDataUtils::UriList mimeUris() const override;
104
105 private:
106
107 QList< QgsProviderSublayerDetails > mSublayers;
108};
109
120{
121 Q_OBJECT
122 public:
123
135 const QString &name,
136 const QString &path,
137 const QList< QgsProviderSublayerDetails> &sublayers,
138 const QVariantMap &extraUriParts = QVariantMap() );
139
140 QVector<QgsDataItem *> createChildren() override;
141 bool hasDragEnabled() const override;
142
158 bool canAddVectorLayers() const;
159
160 QgsMimeDataUtils::UriList mimeUris() const override;
162
169 QgsAbstractDatabaseProviderConnection::Capabilities databaseConnectionCapabilities() const;
170
177 Qgis::DatabaseProviderConnectionCapabilities2 databaseConnectionCapabilities2() const;
178
183 QList<QgsProviderSublayerDetails> sublayers() const;
184
185 private:
186
187 QList< QgsProviderSublayerDetails> mSublayers;
188 QVariantMap mExtraUriParts;
189 mutable bool mHasCachedCapabilities = false;
190 mutable QgsAbstractDatabaseProviderConnection::Capabilities mCachedCapabilities;
191 mutable Qgis::DatabaseProviderConnectionCapabilities2 mCachedCapabilities2;
192 mutable bool mHasCachedDropSupport = false;
193 mutable bool mCachedSupportsDrop = false;
194};
195
196
207{
208 public:
209
210 QString name() override;
211 Qgis::DataItemProviderCapabilities capabilities() const override;
212 QgsDataItem *createDataItem( const QString &path, QgsDataItem *parentItem ) override SIP_FACTORY;
213
227 static QgsDataItem *createLayerItemForPath( const QString &path, QgsDataItem *parentItem, const QStringList &providers,
228 const QVariantMap &extraUriParts,
229 Qgis::SublayerQueryFlags queryFlags );
230
231 bool handlesDirectoryPath( const QString &path ) override;
232
233 private:
234
235 static QgsDataItem *createDataItemForPathPrivate( const QString &path, QgsDataItem *parentItem, const QStringList *allowedProviders,
236 Qgis::SublayerQueryFlags queryFlags,
237 const QVariantMap &extraUriParts );
238};
239
240#endif // QGSFILEBASEDDATAITEMPROVIDER_H
QFlags< DataItemProviderCapability > DataItemProviderCapabilities
Capabilities for data item providers.
Definition qgis.h:926
BrowserLayerType
Browser item layer types.
Definition qgis.h:935
QFlags< SublayerQueryFlag > SublayerQueryFlags
Sublayer query flags.
Definition qgis.h:1309
QFlags< DatabaseProviderConnectionCapability2 > DatabaseProviderConnectionCapabilities2
Definition qgis.h:5015
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
A Collection: logical collection of layers or subcollections, e.g.
This is the interface for those who want to add custom data items to the browser tree.
Base class for all items in the model.
Definition qgsdataitem.h:46
virtual QVector< QgsDataItem * > createChildren()
Create children.
QString name() const
Returns the name of the item (the displayed text for the item).
A data item provider for file based data sources.
A data collection item for grouping of the content in file based data collections (e....
A data collection item for file based data collections (e.g.
Item that represents a layer that can be opened with one of the providers.
QgsAbstractDatabaseProviderConnection * databaseConnection() const override
For data items that represent a DB connection or one of its children, this method returns a connectio...
bool hasDragEnabled() const override
Returns true if the item may be dragged.
QgsMimeDataUtils::UriList mimeUris() const override
Returns mime URIs for the data item, most data providers will only return a single URI but some data ...
virtual QString layerName() const
QList< QgsMimeDataUtils::Uri > UriList
Contains details about a sub layer available from a dataset.
A generic data item for file based layers.
#define SIP_FACTORY
Definition qgis_sip.h:76