QGIS API Documentation  3.2.0-Bonn (bc43194)
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 
23 #include "qgis_gui.h"
25 #include "qgsdataprovider.h"
26 #include "qgsmaplayer.h"
27 #include "qgslayermetadata.h"
28 #include "ui_qgsmetadatawidget.h"
29 
38 class GUI_EXPORT QgsMetadataWidget : public QWidget, private Ui::QgsMetadataWidgetBase
39 {
40  Q_OBJECT
41  Q_PROPERTY( QString title READ title WRITE setTitle NOTIFY titleChanged )
42 
43  public:
44 
49  enum Mode
50  {
51  LayerMetadata = 0,
53  };
54 
63  QgsMetadataWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, QgsMapLayer *layer = nullptr );
64 
70  void setMode( Mode mode );
71 
77  Mode mode() const { return mMode; }
78 
90  void setMetadata( const QgsAbstractMetadataBase *metadata );
91 
100 
107  void saveMetadata( QgsAbstractMetadataBase *metadata );
108 
113  bool checkMetadata();
114 
118  void crsChanged();
119 
123  void acceptMetadata();
124 
128  static QMap<QString, QString> parseLanguages();
129 
133  static QStringList parseLicenses();
134 
139  static QStringList parseLinkTypes();
140 
145  static QStringList parseMimeTypes();
146 
150  static QMap<QString, QString> parseTypes();
151 
155  void setMapCanvas( QgsMapCanvas *canvas );
156 
165  QString title() const;
166 
167  public slots:
168 
177  void setTitle( const QString &title );
178 
179  signals:
180 
189  void titleChanged( const QString &title );
190 
191  private slots:
192  void removeSelectedCategories();
193  void updatePanel();
194  void fillSourceFromLayer();
195  void fillCrsFromLayer();
196  void fillCrsFromProvider();
197  void addDefaultCategories();
198  void addNewCategory();
199  void addVocabulary();
200  void removeSelectedVocabulary();
201  void addLicence();
202  void removeSelectedLicence();
203  void addRight();
204  void removeSelectedRight();
205  void addConstraint();
206  void removeSelectedConstraint();
207  void addAddress();
208  void removeSelectedAddress();
209  void addLink();
210  void removeSelectedLink();
211  void addHistory();
212  void removeSelectedHistory();
213 
214  private:
215 
216  void fillComboBox();
217  void setUiFromMetadata();
218  void syncFromCategoriesTabToKeywordsTab();
219 
220  Mode mMode = LayerMetadata;
221 
222  QStringList mDefaultCategories;
223  QgsMapLayer *mLayer = nullptr;
225  std::unique_ptr< QgsAbstractMetadataBase > mMetadata;
226  QStandardItemModel *mConstraintsModel = nullptr;
227  QStandardItemModel *mLinksModel = nullptr;
228  QStringListModel *mCategoriesModel = nullptr;
229  QStringListModel *mDefaultCategoriesModel = nullptr;
230  QStringListModel *mRightsModel = nullptr;
231  QStringListModel *mHistoryModel = nullptr;
232 };
233 
234 #ifndef SIP_RUN
235 
236 
245 class LinkItemDelegate : public QStyledItemDelegate
246 {
247 
248  Q_OBJECT
249 
250  public:
251 
256  explicit LinkItemDelegate( QObject *parent = nullptr );
257 
261  QWidget *createEditor( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
262 };
263 
271 class 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 
294 #endif
295 #endif
Base class for all map layer types.
Definition: qgsmaplayer.h:61
#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:74
#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.