QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsmetadatawidget.h
Go to the documentation of this file.
1/***************************************************************************
2 QgsAbstractMetadataBasewidget.h - description
3 -------------------
4 begin : 17/05/2017
5 copyright : (C) 2017 by Etienne Trimaille
6 email : etienne at kartoza.com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QgsAbstractMetadataBaseWIDGET_H
18#define QgsAbstractMetadataBaseWIDGET_H
19
20#include <QStandardItemModel>
21#include <QStyledItemDelegate>
22#include <QStringListModel>
23
24#include "qgis_gui.h"
26#include "qgsdataprovider.h"
27#include "qgslayermetadata.h"
28#include "ui_qgsmetadatawidget.h"
29
30class QgsMapLayer;
31class QgsMapCanvas;
32
40class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidgetBase
41{
42 Q_OBJECT
43 Q_PROPERTY( QString title READ title WRITE setTitle NOTIFY titleChanged )
44
45 public:
46
51 enum Mode
52 {
53 LayerMetadata = 0,
55 };
56
65 QgsMetadataWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, QgsMapLayer *layer = nullptr );
66
72 void setMode( Mode mode );
73
79 Mode mode() const { return mMode; }
80
92 void setMetadata( const QgsAbstractMetadataBase *metadata );
93
102
109 void saveMetadata( QgsAbstractMetadataBase *metadata );
110
115 bool checkMetadata();
116
120 void crsChanged();
121
125 void acceptMetadata();
126
130 static QMap<QString, QString> parseLanguages();
131
135 static QStringList parseLicenses();
136
141 static QStringList parseLinkTypes();
142
147 static QStringList parseMimeTypes();
148
152 static QMap<QString, QString> parseTypes();
153
157 void setMapCanvas( QgsMapCanvas *canvas );
158
167 QString title() const;
168
169 public slots:
170
179 void setTitle( const QString &title );
180
181 signals:
182
191 void titleChanged( const QString &title );
192
193 private slots:
194 void removeSelectedCategories();
195 void updatePanel();
196 void fillSourceFromLayer();
197 void fillCrsFromLayer();
198 void fillCrsFromProvider();
199 void addDefaultCategories();
200 void addNewCategory();
201 void addVocabulary();
202 void removeSelectedVocabulary();
203 void addLicence();
204 void removeSelectedLicence();
205 void addRight();
206 void removeSelectedRight();
207 void addConstraint();
208 void removeSelectedConstraint();
209 void addAddress();
210 void removeSelectedAddress();
211 void addLink();
212 void removeSelectedLink();
213 void addHistory();
214 void removeSelectedHistory();
215
216 private:
217
218 void fillComboBox();
219 void setUiFromMetadata();
220 void syncFromCategoriesTabToKeywordsTab();
221
222 Mode mMode = LayerMetadata;
223
224 QStringList mDefaultCategories;
225 QgsMapLayer *mLayer = nullptr;
227 std::unique_ptr< QgsAbstractMetadataBase > mMetadata;
228 QStandardItemModel *mConstraintsModel = nullptr;
229 QStandardItemModel *mLinksModel = nullptr;
230 QStringListModel *mCategoriesModel = nullptr;
231 QStringListModel *mDefaultCategoriesModel = nullptr;
232 QStringListModel *mRightsModel = nullptr;
233 QStringListModel *mHistoryModel = nullptr;
234};
235
236#ifndef SIP_RUN
237
239
246class LinkItemDelegate : public QStyledItemDelegate
247{
248
249 Q_OBJECT
250
251 public:
252
257 explicit LinkItemDelegate( QObject *parent = nullptr );
258
262 QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
263};
264
271class ConstraintItemDelegate : public QStyledItemDelegate
272{
273
274 Q_OBJECT
275
276 public:
277
282 explicit ConstraintItemDelegate( QObject *parent = nullptr );
283
287 QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
288};
289
290
292
293#endif
294#endif
An abstract base class for metadata stores.
This class represents a coordinate reference system (CRS).
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:93
Base class for all map layer types.
Definition: qgsmaplayer.h:75
A wizard to edit metadata on a map layer.
@ ProjectMetadata
Show project metadata.
Mode mode() const
Returns the widget's current mode.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:73
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_FACTORY
Definition: qgis_sip.h:76