QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgsgeometrywidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgeometrywidget.h
3 --------------------------------------
4 Date : March 2015
5 Copyright : (C) 2015 Nyall Dawson
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#ifndef QGSGEOMETRYWIDGET_H
17#define QGSGEOMETRYWIDGET_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
22
23#include <QList>
24#include <QWidget>
25
26class QLineEdit;
27class QToolButton;
28class QMenu;
29
41class GUI_EXPORT QgsGeometryWidget : public QWidget
42{
43 Q_OBJECT
44
46
47 public:
51 explicit QgsGeometryWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );
52
62 void setGeometryValue( const QgsReferencedGeometry &geometry );
63
74
80 void setAcceptedWkbTypes( const QList<Qgis::WkbType> &types );
81
87 QList<Qgis::WkbType> acceptedWkbTypes() const;
88
94 bool isReadOnly() const;
95
96 public slots:
97
103 void setReadOnly( bool readOnly );
104
108 void clearGeometry();
109
115 void copyAsWkt();
116
122 void copyAsGeoJson();
123
124 signals:
125
133
134 private slots:
135
139 void pasteTriggered();
140
141 private:
142 QLineEdit *mLineEdit = nullptr;
143 QToolButton *mButton = nullptr;
144 QMenu *mMenu = nullptr;
145 QAction *mClearAction = nullptr;
146 QAction *mCopyWktAction = nullptr;
147 QAction *mCopyGeoJsonAction = nullptr;
148 QAction *mPasteAction = nullptr;
149 QgsReferencedGeometry mGeometry;
150 QgsReferencedGeometry mPastedGeom;
151 QList<Qgis::WkbType> mAcceptedTypes;
152 bool mReadOnly = false;
153
154 void fetchGeomFromClipboard();
155 bool typeIsAcceptable( Qgis::WkbType type ) const;
156
157 private slots:
158
159 void prepareMenu();
160 void updateLineEdit();
161};
162
163#endif // QGSGEOMETRYWIDGET_H
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:277
void setGeometryValue(const QgsReferencedGeometry &geometry)
Sets the current geometry value for the widget.
QgsReferencedGeometry geometryValue
void setReadOnly(bool readOnly)
Sets whether the widget should be in a read-only state.
QgsGeometryWidget(QWidget *parent=nullptr)
Constructor for QgsGeometryWidget, with the specified parent widget.
void copyAsWkt()
Copies the current geometry value to the clipboard, as a WKT string.
void setAcceptedWkbTypes(const QList< Qgis::WkbType > &types)
Sets the list of WKB geometry types which are permitted for the widget.
QList< Qgis::WkbType > acceptedWkbTypes() const
Returns the list of WKB geometry types which are permitted for the widget.
void clearGeometry()
Clears the current geometry value stored in the widget.
void geometryValueChanged(const QgsReferencedGeometry &value)
Emitted whenever the geometry value of the widget is changed.
bool isReadOnly() const
Returns whether the widget is in a read-only state.
void copyAsGeoJson()
Copies the current geometry value to the clipboard, as a GeoJSON string.
A QgsGeometry with associated coordinate reference system.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53