QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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"
22 #include "qgsdatacollectionitem.h"
23 #include "qgslayeritem.h"
25 #include <QString>
26 #include <QVector>
27 
29 
30 #define SIP_NO_FILE
31 
32 class QgsDataItem;
33 
44 class CORE_EXPORT QgsProviderSublayerItem final: public QgsLayerItem
45 {
46  Q_OBJECT
47  public:
48 
56  QgsProviderSublayerItem( QgsDataItem *parent, const QString &name, const QgsProviderSublayerDetails &details, const QString &filePath );
57  QString layerName() const override;
58  QVector<QgsDataItem *> createChildren() override;
59 
60  private:
61 
62  static Qgis::BrowserLayerType layerTypeFromSublayer( const QgsProviderSublayerDetails &sublayer );
63 
65 
66 };
67 
77 class CORE_EXPORT QgsFileDataCollectionItem final: public QgsDataCollectionItem
78 {
79  Q_OBJECT
80  public:
81 
91  QgsFileDataCollectionItem( QgsDataItem *parent, const QString &name, const QString &path, const QList< QgsProviderSublayerDetails> &sublayers );
92 
93  QVector<QgsDataItem *> createChildren() override;
94  bool hasDragEnabled() const override;
95  QgsMimeDataUtils::UriList mimeUris() const override;
97 
98  private:
99 
100  QList< QgsProviderSublayerDetails> mSublayers;
101 };
102 
103 
114 {
115  public:
116 
117  QString name() override;
118  int capabilities() const override;
119  QgsDataItem *createDataItem( const QString &path, QgsDataItem *parentItem ) override SIP_FACTORY;
120  bool handlesDirectoryPath( const QString &path ) override;
121 };
122 
123 #endif // QGSFILEBASEDDATAITEMPROVIDER_H
QgsDataItemProvider::capabilities
virtual int capabilities() const =0
Returns combination of flags from QgsDataProvider::DataCapabilities.
QgsDataCollectionItem
A Collection: logical collection of layers or subcollections, e.g. GRASS location/mapset,...
Definition: qgsdatacollectionitem.h:28
QgsDataItemProvider::handlesDirectoryPath
virtual bool handlesDirectoryPath(const QString &path)
Returns true if the provider will handle the directory at the specified path.
Definition: qgsdataitemprovider.cpp:27
QgsProviderSublayerItem
A generic data item for file based layers.
Definition: qgsfilebaseddataitemprovider.h:44
QgsDataItemProvider::createDataItem
virtual QgsDataItem * createDataItem(const QString &path, QgsDataItem *parentItem)=0
Create a new instance of QgsDataItem (or nullptr) for given path and parent item.
QgsMimeDataUtils::UriList
QList< QgsMimeDataUtils::Uri > UriList
Definition: qgsmimedatautils.h:164
Qgis::BrowserLayerType
BrowserLayerType
Browser item layer types.
Definition: qgis.h:402
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsDataItemProvider::name
virtual QString name()=0
Human-readable name of the provider name.
QgsFileDataCollectionItem
A data collection item for file based data collections (e.g. NetCDF files).
Definition: qgsfilebaseddataitemprovider.h:77
qgslayeritem.h
QgsDataCollectionItem::databaseConnection
QgsAbstractDatabaseProviderConnection * databaseConnection() const override
For data items that represent a DB connection or one of its children, this method returns a connectio...
Definition: qgsdatacollectionitem.cpp:70
QgsDataItemProvider
This is the interface for those who want to add custom data items to the browser tree.
Definition: qgsdataitemprovider.h:44
qgis_sip.h
QgsProviderSublayerDetails
Contains details about a sub layer available from a dataset.
Definition: qgsprovidersublayerdetails.h:44
QgsDataItem::hasDragEnabled
virtual bool hasDragEnabled() const
Returns true if the item may be dragged.
Definition: qgsdataitem.h:253
QgsFileBasedDataItemProvider
A data item provider for file based data sources.
Definition: qgsfilebaseddataitemprovider.h:113
qgsdataitemprovider.h
qgsdatacollectionitem.h
QgsLayerItem
Item that represents a layer that can be opened with one of the providers.
Definition: qgslayeritem.h:29
QgsDataItem::mimeUris
virtual QgsMimeDataUtils::UriList mimeUris() const
Returns mime URIs for the data item, most data providers will only return a single URI but some data ...
Definition: qgsdataitem.cpp:523
qgsprovidersublayerdetails.h
QgsLayerItem::layerName
virtual QString layerName() const
Definition: qgslayeritem.h:155
QgsDataItem
Base class for all items in the model.
Definition: qgsdataitem.h:45
QgsAbstractDatabaseProviderConnection
The QgsAbstractDatabaseProviderConnection class provides common functionality for DB based connection...
Definition: qgsabstractdatabaseproviderconnection.h:44
QgsDataItem::createChildren
virtual QVector< QgsDataItem * > createChildren()
Create children.
Definition: qgsdataitem.cpp:184