QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 
30 class QgsMapLayer;
31 class QgsMapCanvas;
32 
41 class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidgetBase
42 {
43  Q_OBJECT
44  Q_PROPERTY( QString title READ title WRITE setTitle NOTIFY titleChanged )
45 
46  public:
47 
52  enum Mode
53  {
54  LayerMetadata = 0,
56  };
57 
66  QgsMetadataWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, QgsMapLayer *layer = nullptr );
67 
73  void setMode( Mode mode );
74 
80  Mode mode() const { return mMode; }
81 
93  void setMetadata( const QgsAbstractMetadataBase *metadata );
94 
103 
110  void saveMetadata( QgsAbstractMetadataBase *metadata );
111 
116  bool checkMetadata();
117 
121  void crsChanged();
122 
126  void acceptMetadata();
127 
131  static QMap<QString, QString> parseLanguages();
132 
136  static QStringList parseLicenses();
137 
142  static QStringList parseLinkTypes();
143 
148  static QStringList parseMimeTypes();
149 
153  static QMap<QString, QString> parseTypes();
154 
158  void setMapCanvas( QgsMapCanvas *canvas );
159 
168  QString title() const;
169 
170  public slots:
171 
180  void setTitle( const QString &title );
181 
182  signals:
183 
192  void titleChanged( const QString &title );
193 
194  private slots:
195  void removeSelectedCategories();
196  void updatePanel();
197  void fillSourceFromLayer();
198  void fillCrsFromLayer();
199  void fillCrsFromProvider();
200  void addDefaultCategories();
201  void addNewCategory();
202  void addVocabulary();
203  void removeSelectedVocabulary();
204  void addLicence();
205  void removeSelectedLicence();
206  void addRight();
207  void removeSelectedRight();
208  void addConstraint();
209  void removeSelectedConstraint();
210  void addAddress();
211  void removeSelectedAddress();
212  void addLink();
213  void removeSelectedLink();
214  void addHistory();
215  void removeSelectedHistory();
216 
217  private:
218 
219  void fillComboBox();
220  void setUiFromMetadata();
221  void syncFromCategoriesTabToKeywordsTab();
222 
223  Mode mMode = LayerMetadata;
224 
225  QStringList mDefaultCategories;
226  QgsMapLayer *mLayer = nullptr;
228  std::unique_ptr< QgsAbstractMetadataBase > mMetadata;
229  QStandardItemModel *mConstraintsModel = nullptr;
230  QStandardItemModel *mLinksModel = nullptr;
231  QStringListModel *mCategoriesModel = nullptr;
232  QStringListModel *mDefaultCategoriesModel = nullptr;
233  QStringListModel *mRightsModel = nullptr;
234  QStringListModel *mHistoryModel = nullptr;
235 };
236 
237 #ifndef SIP_RUN
238 
239 
248 class LinkItemDelegate : public QStyledItemDelegate
249 {
250 
251  Q_OBJECT
252 
253  public:
254 
259  explicit LinkItemDelegate( QObject *parent = nullptr );
260 
264  QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
265 };
266 
274 class ConstraintItemDelegate : public QStyledItemDelegate
275 {
276 
277  Q_OBJECT
278 
279  public:
280 
285  explicit ConstraintItemDelegate( QObject *parent = nullptr );
286 
290  QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
291 };
292 
297 #endif
298 #endif
Base class for all map layer types.
Definition: qgsmaplayer.h:78
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
\@cond PRIVATE
A wizard to edit metadata on a map layer.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:73
#define SIP_FACTORY
Definition: qgis_sip.h:69
This class represents a coordinate reference system (CRS).
Mode mode() const
Returns the widget&#39;s current mode.
An abstract base class for metadata stores.
Special delegate for the constraint view in the metadata wizard.
Mode
Widget modes.