QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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 <QSet>
17#include <QStringList>
18
19#include "qgis_sip.h"
20#include "qgis_gui.h"
24
25#include <QIdentityProxyModel>
26#include <QStyledItemDelegate>
27
28class QResizeEvent;
29class QTreeWidgetItem;
30
32// proxy to expand base recent crs model to three column model
33class QgsRecentCoordinateReferenceSystemTableModel : public QgsRecentCoordinateReferenceSystemsProxyModel SIP_SKIP
34{
35 Q_OBJECT
36 public:
37 QgsRecentCoordinateReferenceSystemTableModel( QObject *parent );
38 QVariant headerData( int section, Qt::Orientation orientation, int role ) const override;
39 QVariant data( const QModelIndex &index, int role ) const override;
40};
41
42class RemoveRecentCrsDelegate : public QStyledItemDelegate SIP_SKIP
43{
44 Q_OBJECT
45
46 public:
47 RemoveRecentCrsDelegate( QObject *parent );
48 bool eventFilter( QObject *obj, QEvent *event ) override;
49 protected:
50 void paint( QPainter *painter,
51 const QStyleOptionViewItem &option, const QModelIndex &index ) const override;
52 private:
53 void setHoveredIndex( const QModelIndex &index );
54
55 QModelIndex mHoveredIndex;
56};
57
58
60
74class GUI_EXPORT QgsProjectionSelectionTreeWidget : public QWidget, private Ui::QgsProjectionSelectorBase
75{
76 Q_OBJECT
77
78 public:
79
87 QgsProjectionSelectionTreeWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr,
89
91
97
103 void setShowNoProjection( bool show );
104
109 void setShowBoundsMap( bool show );
110
116 bool showNoProjection() const;
117
123 void setNotSetText( const QString &text );
124
129 bool showBoundsMap() const;
130
137 bool hasValidSelection() const;
138
143 QgsRectangle previewRect() const;
144
152
159 void setFilters( QgsCoordinateReferenceSystemProxyModel::Filters filters );
160
161 public slots:
162
167 void setCrs( const QgsCoordinateReferenceSystem &crs );
168
173 void setPreviewRect( const QgsRectangle &rect );
174
184 void setOgcWmsCrsFilter( const QSet<QString> &crsFilter );
185
191 Q_DECL_DEPRECATED void pushProjectionToFront() SIP_DEPRECATED;
192
198 void clearRecentCrs();
199
200 signals:
201
206
211 Q_DECL_DEPRECATED void initialized() SIP_DEPRECATED;
212
216 void projectionDoubleClicked();
217
223 void hasValidSelectionChanged( bool isValid );
224
225 protected:
226
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
235 void loadUnknownCrs( const QgsCoordinateReferenceSystem &crs );
236
237 void selectCrsByAuthId( const QString &authid );
238
239 enum Roles
240 {
241 RoleDeprecated = Qt::UserRole,
242 RoleWkt,
243 RoleProj
244 };
245
246 QgsCoordinateReferenceSystemProxyModel *mCrsModel = nullptr;
247 QgsRecentCoordinateReferenceSystemTableModel *mRecentCrsModel = nullptr;
248
249 enum Columns { NameColumn, AuthidColumn, ClearColumn };
250
251 bool mShowMap = true;
252
253 bool mBlockSignals = false;
254
255 private slots:
256
257 void updateBoundsPreview();
258
260 void lstCoordinateSystemsDoubleClicked( const QModelIndex &index );
261 void lstRecentDoubleClicked( const QModelIndex &index );
262 void lstRecentClicked( const QModelIndex &index );
263 void lstCoordinateSystemsSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
264 void lstRecentSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );
265
266 void removeRecentCrsItem( const QModelIndex &index );
267};
268
269#endif
A sort/filter proxy model for coordinate reference systems.
@ FilterHorizontal
Include horizontal CRS (excludes compound CRS containing a horizontal component)
This class represents a coordinate reference system (CRS).
A widget for selecting a coordinate reference system from a tree.
void crsSelected()
Emitted when a projection is selected in the widget.
Q_DECL_DEPRECATED void initialized()
Notifies others that the widget is now fully initialized, including deferred selection of projection.
A sort/filter proxy model for recent coordinate reference systems.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126
const QgsCoordinateReferenceSystem & crs