QGIS API Documentation 3.41.0-Master (cea29feecf2)
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:
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 const QgsAbstractLayerMetadataProvider *mLayerMetadataProvider = nullptr;
55 QgsMetadataSearchContext mSearchContext;
56 QgsFeedback *mFeedback;
57};
58
59#endif
60
62
70class GUI_EXPORT QgsLayerMetadataResultsModel : public QAbstractTableModel
71{
72 Q_OBJECT
73
74 public:
79 explicit QgsLayerMetadataResultsModel( const QgsMetadataSearchContext &searchContext, QObject *parent = nullptr );
80
81 ~QgsLayerMetadataResultsModel();
82
83
84 // QAbstractTableModel interface
85
86 int rowCount( const QModelIndex &parent ) const override;
87 int columnCount( const QModelIndex &parent ) const override;
88 QVariant data( const QModelIndex &index, int role ) const override;
89 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
90
92 void reload();
93
95 void reloadAsync();
96
97 // *INDENT-OFF*
98
105 enum class CustomRole SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsLayerMetadataResultsModel, Roles ) : int
106 {
107 Metadata = Qt::ItemDataRole::UserRole,
108 };
109 Q_ENUM( CustomRole )
110 // *INDENT-ON*
111
112
115 enum Sections
116 {
118 Identifier,
120 Title,
122 Abstract,
124 DataProviderName,
126 GeometryType,
127 };
128
129 public slots:
130
134 void resultsReady( const QgsLayerMetadataSearchResults &results );
135
139 void cancel();
140
141 signals:
142
146 void progressChanged( int progress );
147
148 private:
149 std::unique_ptr<QgsFeedback> mFeedback;
151 QgsMetadataSearchContext mSearchContext;
152 std::vector<std::unique_ptr<QgsMetadataResultsFetcher>> mWorkers;
153 std::vector<std::unique_ptr<QThread>> mWorkerThreads;
154};
155
156#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