QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgslayermetadataresultsmodel.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayermetadataresultsmodel.h - QgsLayerMetadataResultsModel
3
4 ---------------------
5 begin : 1.9.2022
6 copyright : (C) 2022 by ale
7 email : [your-email-here]
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSLAYERMETADATARESULTSMODEL_H
17#define QGSLAYERMETADATARESULTSMODEL_H
18
19#include <QAbstractTableModel>
20#include <QObject>
21#include <QThread>
22#include "qgis_gui.h"
23#include "qgis_sip.h"
25
26class QgsFeedback;
27
28
30
31#ifndef SIP_RUN
32
37class QgsMetadataResultsFetcher: public QObject
38{
39 Q_OBJECT
40
41 public:
42
44 QgsMetadataResultsFetcher( const QgsAbstractLayerMetadataProvider *metadataProvider, const QgsMetadataSearchContext &searchContext, QgsFeedback *feedback );
45
47 void fetchMetadata( );
48
49 signals:
50
52 void resultsReady( const QgsLayerMetadataSearchResults &results );
53
54 private:
55
56 const QgsAbstractLayerMetadataProvider *mLayerMetadataProvider = nullptr;
57 QgsMetadataSearchContext mSearchContext;
58 QgsFeedback *mFeedback;
59};
60
61#endif
62
64
72class GUI_EXPORT QgsLayerMetadataResultsModel : public QAbstractTableModel
73{
74 Q_OBJECT
75
76 public:
77
82 explicit QgsLayerMetadataResultsModel( const QgsMetadataSearchContext &searchContext, QObject *parent = nullptr );
83
84 ~QgsLayerMetadataResultsModel();
85
86
87 // QAbstractTableModel interface
88
89 int rowCount( const QModelIndex &parent ) const override;
90 int columnCount( const QModelIndex &parent ) const override;
91 QVariant data( const QModelIndex &index, int role ) const override;
92 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
93
95 void reload( );
96
98 void reloadAsync( );
99
100 // *INDENT-OFF*
101
108 enum class CustomRole SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsLayerMetadataResultsModel, Roles ) : int
109 {
110 Metadata = Qt::ItemDataRole::UserRole,
111 };
112 Q_ENUM( CustomRole )
113 // *INDENT-ON*
114
115
118 enum Sections
119 {
121 Identifier,
123 Title,
125 Abstract,
127 DataProviderName,
129 GeometryType,
130 };
131
132 public slots:
133
137 void resultsReady( const QgsLayerMetadataSearchResults &results );
138
142 void cancel();
143
144 signals:
145
149 void progressChanged( int progress );
150
151 private:
152
153 std::unique_ptr<QgsFeedback> mFeedback;
155 QgsMetadataSearchContext mSearchContext;
156 std::vector<std::unique_ptr<QgsMetadataResultsFetcher>> mWorkers;
157 std::vector<std::unique_ptr<QThread>> mWorkerThreads;
158
159};
160
161#endif // QGSLAYERMETADATARESULTSMODEL_H
Layer metadata provider backend interface.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Container of result records from a layer metadata search.
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:271