QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsprojectionselectiontreewidget.h
Go to the documentation of this file.
1/***************************************************************************
2 * qgsprojectionselector.h *
3 * Copyright (C) 2005 by Tim Sutton *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 ***************************************************************************/
11#ifndef QGSCRSSELECTOR_H
12#define QGSCRSSELECTOR_H
13
14#include "ui_qgsprojectionselectorbase.h"
15
16#include "qgis_gui.h"
17#include "qgis_sip.h"
21
22#include <QIdentityProxyModel>
23#include <QSet>
24#include <QStringList>
25#include <QStyledItemDelegate>
26
27class QResizeEvent;
28class QTreeWidgetItem;
29
31// proxy to expand base recent crs model to three column model
32class QgsRecentCoordinateReferenceSystemTableModel : public QgsRecentCoordinateReferenceSystemsProxyModel SIP_SKIP
33{
34 Q_OBJECT
35 public:
36 QgsRecentCoordinateReferenceSystemTableModel( QObject *parent );
37 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
38 QVariant data( const QModelIndex &index, int role ) const override;
39};
40
41class RemoveRecentCrsDelegate : public QStyledItemDelegate SIP_SKIP
42{
43 Q_OBJECT
44
45 public:
46 RemoveRecentCrsDelegate( QObject *parent );
47 bool eventFilter( QObject *obj, QEvent *event ) override;
48
49 protected:
50 void paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
51
52 private:
53 void setHoveredIndex( const QModelIndex &index );
54
55 QModelIndex mHoveredIndex;
56};
57
58
60
73
74class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::QgsProjectionSelectorBase
75{
76 Q_OBJECT
77
78 public:
87
89
95
101 void setShowNoProjection( bool show );
102
107 void setShowBoundsMap( bool show );
108
114 bool showNoProjection() const;
115
121 void setNotSetText( const QString &text );
122
127 bool showBoundsMap() const;
128
135 bool hasValidSelection() const;
136
142
150
158
159 public slots:
160
166
171 void setPreviewRect( const QgsRectangle &rect );
172
182 void setOgcWmsCrsFilter( const QSet<QString> &crsFilter );
183
189 Q_DECL_DEPRECATED void pushProjectionToFront() SIP_DEPRECATED;
190
196 void clearRecentCrs();
197
198 signals:
199
204
209 Q_DECL_DEPRECATED void initialized() SIP_DEPRECATED;
210
215
221 void hasValidSelectionChanged( bool isValid );
222
223 protected:
224 // Used to manage column sizes
225 void resizeEvent( QResizeEvent *event ) override;
226
227 // Used to catch key presses on the recent projections list
228 bool eventFilter( QObject *obj, QEvent *ev ) override;
229
230 private:
231 void loadUnknownCrs( const QgsCoordinateReferenceSystem &crs );
232
233 void selectCrsByAuthId( const QString &authid );
234
235 enum Roles
236 {
237 RoleDeprecated = Qt::UserRole,
238 RoleWkt,
239 RoleProj
240 };
241
242 QgsCoordinateReferenceSystemProxyModel *mCrsModel = nullptr;
243 QgsRecentCoordinateReferenceSystemTableModel *mRecentCrsModel = nullptr;
244
245 enum Columns
246 {
247 NameColumn,
248 AuthidColumn,
249 ClearColumn
250 };
251
252 bool mShowMap = true;
253
254 bool mBlockSignals = false;
255
256 private slots:
257
258 void updateBoundsPreview();
259
261 void lstCoordinateSystemsDoubleClicked( const QModelIndex &index );
262 void lstRecentDoubleClicked( const QModelIndex &index );
263 void lstRecentClicked( const QModelIndex &index );
264 void lstCoordinateSystemsSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
265 void lstRecentSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
266
267 void removeRecentCrsItem( const QModelIndex &index );
268};
269
270#endif
A sort/filter proxy model for coordinate reference systems.
@ FilterHorizontal
Include horizontal CRS (excludes compound CRS containing a horizontal component).
Represents a coordinate reference system (CRS).
void resizeEvent(QResizeEvent *event) override
void setPreviewRect(const QgsRectangle &rect)
Sets the initial "preview" rectangle for the bounds overview map.
void setShowBoundsMap(bool show)
Sets whether to show the bounds preview map.
void crsSelected()
Emitted when a projection is selected in the widget.
Q_DECL_DEPRECATED void pushProjectionToFront()
Marks the current selected projection for push to front of recent projections list.
QgsCoordinateReferenceSystem crs() const
Returns the CRS currently selected in the widget.
bool showNoProjection() const
Returns whether the "no/invalid" projection option is shown.
void setShowNoProjection(bool show)
Sets whether a "no/invalid" projection option should be shown.
bool showBoundsMap() const
Returns whether the bounds preview map is shown.
QgsRectangle previewRect() const
The initial "preview" rectangle for the bounds overview map.
void projectionDoubleClicked()
Emitted when a projection is double clicked in the list.
bool hasValidSelection() const
Returns true if the current selection in the widget is a valid choice.
QgsCoordinateReferenceSystemProxyModel::Filters filters() const
Returns the filters set on the available CRS.
void setOgcWmsCrsFilter(const QSet< QString > &crsFilter)
Filters this widget by the given CRSs.
void setFilters(QgsCoordinateReferenceSystemProxyModel::Filters filters)
Sets filters for the available CRS.
Q_DECL_DEPRECATED void initialized()
Notifies others that the widget is now fully initialized, including deferred selection of projection.
bool eventFilter(QObject *obj, QEvent *ev) override
void setNotSetText(const QString &text)
Sets the text to show for the not set option.
void clearRecentCrs()
Clear the list of recent projections.
QgsProjectionSelectionTreeWidget(QWidget *parent=nullptr, QgsCoordinateReferenceSystemProxyModel::Filters filters=QgsCoordinateReferenceSystemProxyModel::FilterHorizontal|QgsCoordinateReferenceSystemProxyModel::FilterCompound)
Constructor for QgsProjectionSelectionTreeWidget, with the specified parent widget.
void hasValidSelectionChanged(bool isValid)
Emitted when the selection in the tree is changed from a valid selection to an invalid selection,...
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the initial crs to show within the dialog.
A sort/filter proxy model for recent coordinate reference systems.
A rectangle specified with double values.
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:134