QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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 QWidget *parent SIP_TRANSFERTHIS = nullptr,
89 );
90
92
98
104 void setShowNoProjection( bool show );
105
110 void setShowBoundsMap( bool show );
111
117 bool showNoProjection() const;
118
124 void setNotSetText( const QString &text );
125
130 bool showBoundsMap() const;
131
138 bool hasValidSelection() const;
139
145
153
161
162 public slots:
163
169
174 void setPreviewRect( const QgsRectangle &rect );
175
185 void setOgcWmsCrsFilter( const QSet<QString> &crsFilter );
186
192 Q_DECL_DEPRECATED void pushProjectionToFront() SIP_DEPRECATED;
193
199 void clearRecentCrs();
200
201 signals:
202
207
212 Q_DECL_DEPRECATED void initialized() SIP_DEPRECATED;
213
218
224 void hasValidSelectionChanged( bool isValid );
225
226 protected:
227 // Used to manage column sizes
228 void resizeEvent( QResizeEvent *event ) override;
229
230 // Used to catch key presses on the recent projections list
231 bool eventFilter( QObject *obj, QEvent *ev ) override;
232
233 private:
234 void loadUnknownCrs( const QgsCoordinateReferenceSystem &crs );
235
236 void selectCrsByAuthId( const QString &authid );
237
238 enum Roles
239 {
240 RoleDeprecated = Qt::UserRole,
241 RoleWkt,
242 RoleProj
243 };
244
245 QgsCoordinateReferenceSystemProxyModel *mCrsModel = nullptr;
246 QgsRecentCoordinateReferenceSystemTableModel *mRecentCrsModel = nullptr;
247
248 enum Columns
249 {
250 NameColumn,
251 AuthidColumn,
252 ClearColumn
253 };
254
255 bool mShowMap = true;
256
257 bool mBlockSignals = false;
258
259 private slots:
260
261 void updateBoundsPreview();
262
264 void lstCoordinateSystemsDoubleClicked( const QModelIndex &index );
265 void lstRecentDoubleClicked( const QModelIndex &index );
266 void lstRecentClicked( const QModelIndex &index );
267 void lstCoordinateSystemsSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
268 void lstRecentSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
269
270 void removeRecentCrsItem( const QModelIndex &index );
271};
272
273#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:113
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_SKIP
Definition qgis_sip.h:133