QGIS API Documentation 3.99.0-Master (21b3aa880ba)
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:
79
88
90
96
102 void setShowNoProjection( bool show );
103
108 void setShowBoundsMap( bool show );
109
115 bool showNoProjection() const;
116
122 void setNotSetText( const QString &text );
123
128 bool showBoundsMap() const;
129
136 bool hasValidSelection() const;
137
143
151
159
160 public slots:
161
167
172 void setPreviewRect( const QgsRectangle &rect );
173
183 void setOgcWmsCrsFilter( const QSet<QString> &crsFilter );
184
190 Q_DECL_DEPRECATED void pushProjectionToFront() SIP_DEPRECATED;
191
197 void clearRecentCrs();
198
199 signals:
200
205
210 Q_DECL_DEPRECATED void initialized() SIP_DEPRECATED;
211
216
222 void hasValidSelectionChanged( bool isValid );
223
224 protected:
225 // Used to manage column sizes
226 void resizeEvent( QResizeEvent *event ) override;
227
228 // Used to catch key presses on the recent projections list
229 bool eventFilter( QObject *obj, QEvent *ev ) override;
230
231 private:
232 void loadUnknownCrs( const QgsCoordinateReferenceSystem &crs );
233
234 void selectCrsByAuthId( const QString &authid );
235
236 enum Roles
237 {
238 RoleDeprecated = Qt::UserRole,
239 RoleWkt,
240 RoleProj
241 };
242
243 QgsCoordinateReferenceSystemProxyModel *mCrsModel = nullptr;
244 QgsRecentCoordinateReferenceSystemTableModel *mRecentCrsModel = nullptr;
245
246 enum Columns
247 {
248 NameColumn,
249 AuthidColumn,
250 ClearColumn
251 };
252
253 bool mShowMap = true;
254
255 bool mBlockSignals = false;
256
257 private slots:
258
259 void updateBoundsPreview();
260
262 void lstCoordinateSystemsDoubleClicked( const QModelIndex &index );
263 void lstRecentDoubleClicked( const QModelIndex &index );
264 void lstRecentClicked( const QModelIndex &index );
265 void lstCoordinateSystemsSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
266 void lstRecentSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
267
268 void removeRecentCrsItem( const QModelIndex &index );
269};
270
271#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