QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
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"
24
25class QgsFeedback;
26
27
29
30#ifndef SIP_RUN
31
36class QgsMetadataResultsFetcher: public QObject
37{
38 Q_OBJECT
39
40 public:
41
43 QgsMetadataResultsFetcher( const QgsAbstractLayerMetadataProvider *metadataProvider, const QgsMetadataSearchContext &searchContext, QgsFeedback *feedback );
44
46 void fetchMetadata( );
47
48 signals:
49
51 void resultsReady( const QgsLayerMetadataSearchResults &results );
52
53 private:
54
55 const QgsAbstractLayerMetadataProvider *mLayerMetadataProvider = nullptr;
56 QgsMetadataSearchContext mSearchContext;
57 QgsFeedback *mFeedback;
58};
59
60#endif
61
63
71class GUI_EXPORT QgsLayerMetadataResultsModel : public QAbstractTableModel
72{
73 Q_OBJECT
74
75 public:
76
81 explicit QgsLayerMetadataResultsModel( const QgsMetadataSearchContext &searchContext, QObject *parent = nullptr );
82
83 ~QgsLayerMetadataResultsModel();
84
85
86 // QAbstractTableModel interface
87
88 int rowCount( const QModelIndex &parent ) const override;
89 int columnCount( const QModelIndex &parent ) const override;
90 QVariant data( const QModelIndex &index, int role ) const override;
91 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
92
94 void reload( );
95
97 void reloadAsync( );
98
102 enum Roles
103 {
105 Metadata = Qt::ItemDataRole::UserRole
106 };
107
111 enum Sections
112 {
114 Identifier,
116 Title,
118 Abstract,
120 DataProviderName,
122 GeometryType,
123 };
124
125 public slots:
126
130 void resultsReady( const QgsLayerMetadataSearchResults &results );
131
135 void cancel();
136
137 signals:
138
142 void progressChanged( int progress );
143
144 private:
145
146 std::unique_ptr<QgsFeedback> mFeedback;
148 QgsMetadataSearchContext mSearchContext;
149 std::vector<std::unique_ptr<QgsMetadataResultsFetcher>> mWorkers;
150 std::vector<std::unique_ptr<QThread>> mWorkerThreads;
151
152};
153
154#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:45
Container of result records from a layer metadata search.