-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsvectorlayerproperties.h
259 lines (193 loc) · 8.05 KB
/
qgsvectorlayerproperties.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/***************************************************************************
qgsdlgvectorlayerproperties.h
Unified property dialog for vector layers
-------------------
begin : 2004-01-28
copyright : (C) 2004 by Gary E.Sherman
email : sherman at mrcc.com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSVECTORLAYERPROPERTIES
#define QGSVECTORLAYERPROPERTIES
#include "qgsoptionsdialogbase.h"
#include "ui_qgsvectorlayerpropertiesbase.h"
#include "qgsguiutils.h"
#include "qgshelp.h"
#include "qgsmaplayerstylemanager.h"
#include "qgsvectorlayerjoininfo.h"
#include "layertree/qgslayertree.h"
#include "layertree/qgslayertreemodel.h"
#include "layertree/qgslayertreegroup.h"
#include "qgis_app.h"
class QgsMapLayer;
class QgsAttributeActionDialog;
class QgsApplyDialog;
class QgsVectorLayer;
class QgsLabelingWidget;
class QgsDiagramProperties;
class QgsSourceFieldsProperties;
class QgsAttributesFormProperties;
class QgsRendererPropertiesDialog;
class QgsMapLayerConfigWidgetFactory;
class QgsMapLayerConfigWidget;
class QgsMetadataWidget;
class QgsPanelWidget;
class QgsVectorLayer3DRendererWidget;
class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private Ui::QgsVectorLayerPropertiesBase, private QgsExpressionContextGenerator
{
Q_OBJECT
public:
enum StyleType
{
QML,
SLD,
DB,
};
Q_ENUM( StyleType )
QgsVectorLayerProperties( QgsVectorLayer *lyr = nullptr, QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
//! Returns the display name entered in the dialog
QString displayName()
{
return txtDisplayName->text();
}
/**
* Adds an attribute to the layer.
* The layer will need to be in edit mode. It will only be added to the provider when the edit buffer
* is committed.
* \param field the field to add
* \returns false in case of a name conflict, true in case of success
*/
bool addAttribute( const QgsField &field );
/**
* Deletes an attribute.
* The layer will need to be in edit mode. It will only be added to the provider when the edit buffer
* is committed.
* \param name attribute name
* \returns false in case of a non-existing attribute.
*/
bool deleteAttribute( int attr );
//! Adds a properties page factory to the vector layer properties dialog.
void addPropertiesPageFactory( QgsMapLayerConfigWidgetFactory *factory );
public slots:
void insertFieldOrExpression();
//! Reset to original (vector layer) values
void syncToLayer();
//! Gets metadata about the layer in nice formatted html
QString htmlMetadata();
//! Slot to update layer display name as original is edited
void mLayerOrigNameLineEdit_textEdited( const QString &text );
//! Called when apply button is pressed or dialog is accepted
void apply();
//! Called when cancel button is pressed
void onCancel();
//
//methods reimplemented from qt designer base class
//
void pbnQueryBuilder_clicked();
void pbnIndex_clicked();
void mCrsSelector_crsChanged( const QgsCoordinateReferenceSystem &crs );
void loadDefaultStyle_clicked();
void saveDefaultStyle_clicked();
void loadMetadata();
void saveMetadataAs();
void saveDefaultMetadata();
void loadDefaultMetadata();
void optionsStackedWidget_CurrentChanged( int index ) override;
void pbnUpdateExtents_clicked();
void mButtonAddJoin_clicked();
void mButtonEditJoin_clicked();
void mJoinTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
void mButtonRemoveJoin_clicked();
void mSimplifyDrawingGroupBox_toggled( bool checked );
signals:
//! Emitted when changes to layer were saved to update legend
void refreshLegend( const QString &layerID, bool expandItem );
void refreshLegend( const QString &layerID );
void toggleEditing( QgsMapLayer * );
private slots:
//! Toggle editing of layer
void toggleEditing();
//! Save the style
void saveStyleAs();
//! Load the style
void loadStyle();
void aboutToShowStyleMenu();
/**
* Updates the variable editor to reflect layer changes
*/
void updateVariableEditor();
void onAuxiliaryLayerNew();
void onAuxiliaryLayerClear();
void onAuxiliaryLayerDelete();
void onAuxiliaryLayerDeleteField();
void onAuxiliaryLayerAddField();
void onAuxiliaryLayerExport();
void urlClicked( const QUrl &url );
private:
enum PropertyType
{
Style = 0,
Metadata,
};
void updateSymbologyPage();
void setPbnQueryBuilderEnabled();
QgsVectorLayer *mLayer = nullptr;
bool mMetadataFilled = false;
QString mOriginalSubsetSQL;
QPushButton *mBtnStyle = nullptr;
QPushButton *mBtnMetadata = nullptr;
QAction *mActionLoadMetadata = nullptr;
QAction *mActionSaveMetadataAs = nullptr;
QMenu *mLoadStyleMenu = nullptr;
QAction *mActionLoadStyle = nullptr;
QAction *mActionSaveStyle = nullptr;
//! Renderer dialog which is shown
QgsRendererPropertiesDialog *mRendererDialog = nullptr;
//! Labeling dialog. If apply is pressed, options are applied to vector's QgsLabel
QgsLabelingWidget *labelingDialog = nullptr;
//! Actions dialog. If apply is pressed, the actions are stored for later use
QgsAttributeActionDialog *mActionDialog = nullptr;
//! Diagram dialog. If apply is pressed, options are applied to vector's diagrams
QgsDiagramProperties *diagramPropertiesDialog = nullptr;
//! SourceFields dialog. If apply is pressed, options are applied to vector's diagrams
QgsSourceFieldsProperties *mSourceFieldsPropertiesDialog = nullptr;
//! AttributesForm dialog. If apply is pressed, options are applied to vector's diagrams
QgsAttributesFormProperties *mAttributesFormPropertiesDialog = nullptr;
//! List of joins of a layer at the time of creation of the dialog. Used to return joins to previous state if dialog is canceled
QList< QgsVectorLayerJoinInfo > mOldJoins;
//! A list of additional pages provided by plugins
QList<QgsMapLayerConfigWidget *> mLayerPropertiesPages;
/**
* Previous layer style. Used to reset style to previous state if new style
* was loaded but dialog is canceled */
QgsMapLayerStyle mOldStyle;
void initDiagramTab();
//! Adds a new join to mJoinTreeWidget
void addJoinToTreeWidget( const QgsVectorLayerJoinInfo &join, int insertIndex = -1 );
void updateAuxiliaryStoragePage( bool reset = false );
void deleteAuxiliaryField( int index );
QgsExpressionContext mContext;
QgsExpressionContext createExpressionContext() const override;
std::unique_ptr<QgsLayerTree> mLayersDependenciesTreeGroup;
std::unique_ptr<QgsLayerTreeModel> mLayersDependenciesTreeModel;
void showHelp();
QgsMetadataWidget *mMetadataWidget = nullptr;
QAction *mAuxiliaryLayerActionNew = nullptr;
QAction *mAuxiliaryLayerActionClear = nullptr;
QAction *mAuxiliaryLayerActionDelete = nullptr;
QAction *mAuxiliaryLayerActionExport = nullptr;
QAction *mAuxiliaryLayerActionDeleteField = nullptr;
QAction *mAuxiliaryLayerActionAddField = nullptr;
QgsVectorLayer3DRendererWidget *mVector3DWidget = nullptr;
private slots:
void openPanel( QgsPanelWidget *panel );
friend class QgsAppScreenShots;
};
#endif