QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
qgspropertyoverridebutton.h
Go to the documentation of this file.
1/***************************************************************************
2 qgspropertyoverridebutton.h
3 ---------------------------
4 Date : January 2017
5 Copyright : (C) 2017 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
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#ifndef QGSPROPERTYOVERRIDEBUTTON_H
16#define QGSPROPERTYOVERRIDEBUTTON_H
17
18#include "qgis_gui.h"
19#include "qgis_sip.h"
20#include <QDialog>
21#include <QFlags>
22#include <QMap>
23#include <QPointer>
24#include <QToolButton>
25#include "qgsproperty.h"
28
29class QgsVectorLayer;
30class QgsMapCanvas;
31class QgsSymbol;
32
48class GUI_EXPORT QgsPropertyOverrideButton: public QToolButton
49{
50 Q_OBJECT
51 Q_PROPERTY( QString usageInfo READ usageInfo WRITE setUsageInfo )
52 Q_PROPERTY( bool active READ isActive WRITE setActive )
53
54 public:
55
61 QgsPropertyOverrideButton( QWidget *parent SIP_TRANSFERTHIS = nullptr,
62 const QgsVectorLayer *layer = nullptr );
63
72 void init( int propertyKey,
73 const QgsProperty &property,
74 const QgsPropertiesDefinition &definitions,
75 const QgsVectorLayer *layer = nullptr,
76 bool auxiliaryStorageEnabled = false );
77
86 void init( int propertyKey,
87 const QgsProperty &property,
88 const QgsPropertyDefinition &definition,
89 const QgsVectorLayer *layer = nullptr,
90 bool auxiliaryStorageEnabled = false );
91
100 void init( int propertyKey,
101 const QgsAbstractPropertyCollection &collection,
102 const QgsPropertiesDefinition &definitions,
103 const QgsVectorLayer *layer = nullptr,
104 bool auxiliaryStorageEnabled = false );
105
111 QgsProperty toProperty() const;
112
116 void setToProperty( const QgsProperty &property );
117
121 int propertyKey() const { return mPropertyKey; }
122
126 bool isActive() const { return mProperty && mProperty.isActive(); }
127
133 QgsPropertyDefinition::DataType validDataType() const { return mDataTypes; }
134
139 QString fullDescription() const { return mFullDescription; }
140
145 QString usageInfo() const { return mUsageInfo; }
146
151 void setUsageInfo( const QString &info ) { mUsageInfo = info; updateGui(); }
152
158 void setVectorLayer( const QgsVectorLayer *layer );
159
165 const QgsVectorLayer *vectorLayer() const { return mVectorLayer; }
166
172 void registerCheckedWidget( QWidget *widget, bool natural = true );
173
179 void registerEnabledWidget( QWidget *widget, bool natural = true );
180
186 void registerVisibleWidget( QWidget *widget, bool natural = true );
187
192 void registerExpressionWidget( QWidget *widget );
193
198 void registerExpressionContextGenerator( QgsExpressionContextGenerator *generator );
199
209 void registerLinkedWidget( QWidget *widget );
210
215 void updateFieldLists();
216
222 void setSymbol( std::shared_ptr< QgsSymbol > symbol ) { mSymbol = symbol; } SIP_SKIP
223
224 public slots:
225
229 void setActive( bool active );
230
231
233
234 // exposed to Python for testing only
235 void aboutToShowMenu();
236 void menuActionTriggered( QAction *action );
237
239
240 signals:
241
243 void changed();
244
246 void activated( bool isActive );
247
250
251 protected:
252 void mouseReleaseEvent( QMouseEvent *event ) override;
253
254 private:
255
256 void showDescriptionDialog();
257 void showExpressionDialog();
258 void showAssistant();
259 void updateGui();
260
265 void setActivePrivate( bool active );
266
267
268 int mPropertyKey = -1;
269
270 const QgsVectorLayer *mVectorLayer = nullptr;
271
272 QStringList mFieldNameList;
273 QStringList mFieldDisplayNameList;
274 QList< QIcon > mFieldIcons;
275
276 QString mExpressionString;
277 QString mFieldName;
278
279 QMenu *mDefineMenu = nullptr;
280 QAction *mActionDataTypes = nullptr;
281 QMenu *mFieldsMenu = nullptr;
282 QMenu *mVariablesMenu = nullptr;
283 QAction *mActionVariables = nullptr;
284 QMenu *mColorsMenu = nullptr;
285 QAction *mActionColors = nullptr;
286
287 QAction *mActionActive = nullptr;
288 QAction *mActionDescription = nullptr;
289 QAction *mActionExpDialog = nullptr;
290 QAction *mActionExpression = nullptr;
291 QAction *mActionPasteExpr = nullptr;
292 QAction *mActionCopyExpr = nullptr;
293 QAction *mActionClearExpr = nullptr;
294 QAction *mActionAssistant = nullptr;
295 QAction *mActionCreateAuxiliaryField = nullptr;
296
297 QgsPropertyDefinition mDefinition;
298
300 QString mDataTypesString;
301 QString mInputDescription;
302 QString mFullDescription;
303 QString mUsageInfo;
304
305 QgsExpressionContextGenerator *mExpressionContextGenerator = nullptr;
306
307 enum SiblingType
308 {
309 SiblingCheckState,
310 SiblingEnableState,
311 SiblingVisibility,
312 SiblingExpressionText,
313 SiblingLinkedWidget,
314 };
315 struct SiblingWidget
316 {
317 SiblingWidget( const QPointer<QWidget> &widgetPointer, SiblingType siblingType, bool natural = true )
318 : mWidgetPointer( widgetPointer )
319 , mSiblingType( siblingType )
320 , mNatural( natural )
321 {}
322 QPointer<QWidget> mWidgetPointer;
323 SiblingType mSiblingType;
324 bool mNatural;
325 };
326 QList< SiblingWidget > mSiblingWidgets;
327
329 QgsProperty mProperty;
330
331 bool mAuxiliaryStorageEnabled = false;
332
333 std::shared_ptr< QgsSymbol > mSymbol;
334
335 private slots:
336
337 void showHelp();
338 void updateSiblingWidgets( bool state );
339};
340
341#endif // QGSPROPERTYOVERRIDEBUTTON_H
Abstract base class for QgsPropertyCollection like objects.
Abstract interface for generating an expression context.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition for a property.
Definition qgsproperty.h:45
DataType
Valid data types required by property.
Definition qgsproperty.h:83
@ DataTypeString
Property requires a string value.
Definition qgsproperty.h:90
A button for controlling property overrides which may apply to a widget.
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the button.
void setUsageInfo(const QString &info)
Set the usage information for the property.
bool isActive() const
Returns true if the button has an active property.
void changed()
Emitted when property definition changes.
void activated(bool isActive)
Emitted when the activated status of the widget changes.
void setSymbol(std::shared_ptr< QgsSymbol > symbol)
Sets a symbol which can be used for previews inside the widget or in any dialog created by the widget...
QgsPropertyDefinition::DataType validDataType() const
Returns the data type which the widget will accept.
void createAuxiliaryField()
Emitted when creating a new auxiliary field.
QString fullDescription() const
Returns the full definition description and current definition (internally generated on a contextual ...
QString usageInfo() const
Returns usage information for the property.
A store for object properties.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:94
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:126
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.