QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsprojectionselectionwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprojectionselectionwidget.h
3 --------------------------------------
4 Date : 05.01.2015
5 Copyright : (C) 2015 Denis Rouzaud
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16
17#ifndef QGSPROJECTIONSELECTIONWIDGET_H
18#define QGSPROJECTIONSELECTIONWIDGET_H
19
20#include <QWidget>
21#include "qgis_sip.h"
22#include <QLineEdit>
23#include <QToolButton>
24#include <QComboBox>
25#include <QPointer>
26#include <QConcatenateTablesProxyModel>
27
30#include "qgis_gui.h"
31
32class QgsMapLayer;
35class QLabel;
36class QgsMapLayer;
38class CombinedCoordinateReferenceSystemsProxyModel;
39
45class GUI_EXPORT QgsProjectionSelectionWidget : public QWidget
46{
47 Q_OBJECT
48 public:
53 {
54 Invalid = 1 << 0,
55 LayerCrs = 1 << 1,
56 ProjectCrs = 1 << 2,
57 CurrentCrs = 1 << 3,
58 DefaultCrs = 1 << 4,
59 RecentCrs = 1 << 5,
60 CrsNotSet = 1 << 6,
61 };
62
67 SIP_SKIP Q_DECLARE_FLAGS( CrsOptions, CrsOption )
68
69
77
83
90 void setOptionVisible( CrsOption option, bool visible );
91
96 bool optionVisible( CrsOption option ) const;
97
102 void setNotSetText( const QString &text );
103
109 void setMessage( const QString &text );
110
117 static QString crsOptionText( const QgsCoordinateReferenceSystem &crs ) SIP_SKIP;
118
126 bool showAccuracyWarnings() const;
127
135 void setShowAccuracyWarnings( bool show );
136
146 void setSourceEnsemble( const QString &ensemble );
147
157 QString sourceEnsemble() const;
158
164 void setDialogTitle( const QString &title );
165
171 QString dialogTitle() const;
172
178 void setFilter( const QList<QgsCoordinateReferenceSystem> &crses );
179
187
194 void setFilters( QgsCoordinateReferenceSystemProxyModel::Filters filters );
195
196 signals:
197
202
206 void cleared();
207
208 public slots:
209
214 void setCrs( const QgsCoordinateReferenceSystem &crs );
215
221 void setLayerCrs( const QgsCoordinateReferenceSystem &crs );
222
226 void selectCrs();
227
228 protected:
229 void dragEnterEvent( QDragEnterEvent *event ) override;
230 void dragLeaveEvent( QDragLeaveEvent *event ) override;
231 void dropEvent( QDropEvent *event ) override;
232
233 private:
234 CombinedCoordinateReferenceSystemsProxyModel *mModel = nullptr;
235
236 QgsHighlightableComboBox *mCrsComboBox = nullptr;
237 QToolButton *mButton = nullptr;
238
239 QString mMessage;
240
241 bool mShowAccuracyWarnings = false;
242 QString mSourceEnsemble;
243
244 QWidget *mWarningLabelContainer = nullptr;
245 QLabel *mWarningLabel = nullptr;
246
247 QPointer<QgsCrsSelectionWidget> mActivePanel;
248 int mIgnorePanelSignals = 0;
249
250 QString mDialogTitle;
251
252 void updateTooltip();
253
254 QgsMapLayer *mapLayerFromMimeData( const QMimeData *data ) const;
255
256 private slots:
257
258 void comboIndexChanged( int idx );
259 void updateWarning();
260};
261
263
265
266class StandardCoordinateReferenceSystemsModel : public QAbstractItemModel SIP_SKIP
267{
268 Q_OBJECT
269
270 public:
271 enum Role
272 {
273 // values copied from QgsRecentCoordinateReferenceSystemsModel
274 RoleCrs = Qt::UserRole,
275 // new values
276 RoleOption = RoleCrs + 100,
277 };
278
279 StandardCoordinateReferenceSystemsModel( QObject *parent SIP_TRANSFERTHIS = nullptr );
280
281 Qt::ItemFlags flags( const QModelIndex &index ) const override;
282 QVariant data( const QModelIndex &index, int role ) const override;
283 int rowCount( const QModelIndex &parent = QModelIndex() ) const override;
284 int columnCount( const QModelIndex & = QModelIndex() ) const override;
285 QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const override;
286 QModelIndex parent( const QModelIndex &index ) const override;
287
288 QgsCoordinateReferenceSystem crs( const QModelIndex &index ) const;
289 QgsProjectionSelectionWidget::CrsOption optionForIndex( const QModelIndex &index ) const;
290 QModelIndex indexForOption( QgsProjectionSelectionWidget::CrsOption option ) const;
291
292 void setLayerCrs( const QgsCoordinateReferenceSystem &crs );
293 void setCurrentCrs( const QgsCoordinateReferenceSystem &crs );
294 void setNotSetText( const QString &text );
295 QString notSetText() const { return mNotSetText; }
296 QgsCoordinateReferenceSystem currentCrs() const { return mCurrentCrs; }
297
298 private:
304
305 QString mNotSetText;
306};
307
308class CombinedCoordinateReferenceSystemsModel : public QConcatenateTablesProxyModel SIP_SKIP
309{
310 Q_OBJECT
311
312 public:
313 CombinedCoordinateReferenceSystemsModel( QObject *parent );
314 void setNotSetText( const QString &text );
315 QString notSetText() const;
316 QgsCoordinateReferenceSystem currentCrs() const;
317 StandardCoordinateReferenceSystemsModel *standardModel() { return mStandardModel; }
318
319 private:
320 StandardCoordinateReferenceSystemsModel *mStandardModel = nullptr;
321 QgsRecentCoordinateReferenceSystemsProxyModel *mRecentModel = nullptr;
322};
323
324class CombinedCoordinateReferenceSystemsProxyModel : public QSortFilterProxyModel SIP_SKIP
325{
326 Q_OBJECT
327
328 public:
329 CombinedCoordinateReferenceSystemsProxyModel( QObject *parent );
330 bool filterAcceptsRow( int sourceRow, const QModelIndex &sourceParent ) const override;
331 void setLayerCrs( const QgsCoordinateReferenceSystem &crs );
332 void setCurrentCrs( const QgsCoordinateReferenceSystem &crs );
333 void setFilters( QgsCoordinateReferenceSystemProxyModel::Filters filters );
335
336 void setFilteredCrs( const QList<QgsCoordinateReferenceSystem> &crses );
337 QList<QgsCoordinateReferenceSystem> filteredCrs() const { return mFilteredCrs; }
338
339 void setOption( QgsProjectionSelectionWidget::CrsOption option, bool enabled );
340 CombinedCoordinateReferenceSystemsModel *combinedModel() const { return mModel; }
341
342 private:
343 CombinedCoordinateReferenceSystemsModel *mModel = nullptr;
345
346 QList<QgsCoordinateReferenceSystem> mFilteredCrs;
347
349};
350
352
353#endif // QGSPROJECTIONSELECTIONWIDGET_H
@ FilterHorizontal
Include horizontal CRS (excludes compound CRS containing a horizontal component)
This class represents a coordinate reference system (CRS).
A generic widget allowing users to pick a Coordinate Reference System (or define their own).
A QComboBox subclass with the ability to "highlight" the edges of the widget.
Base class for all map layer types.
Definition qgsmaplayer.h:76
A widget for selecting a projection.
void cleared()
Emitted when the not set option is selected.
CrsOption
Predefined CRS options shown in widget.
void crsChanged(const QgsCoordinateReferenceSystem &crs)
Emitted when the selected CRS is changed.
QFlags< CrsOption > CrsOptions
Flags for predefined CRS options shown in widget.
A sort/filter proxy model for recent coordinate reference systems.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:278
#define SIP_SKIP
Definition qgis_sip.h:126
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsProjectionSelectionWidget::CrsOptions)
const QgsCoordinateReferenceSystem & crs