QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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
BrowserLayerType
Browser item layer types.
Definition: qgis.h:314
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).
Definition: qgsdataitem.h:345
A data item provider for file based data sources.
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.
Definition: qgslayeritem.h:30
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.
Definition: qgslayeritem.h:52
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
Definition: qgslayeritem.h:142
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