QGIS API Documentation 3.35.0-Master (ffb31addd7f)
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
49class GUI_EXPORT QgsPropertyOverrideButton: public QToolButton
50{
51 Q_OBJECT
52 Q_PROPERTY( QString usageInfo READ usageInfo WRITE setUsageInfo )
53 Q_PROPERTY( bool active READ isActive WRITE setActive )
54
55 public:
56
62 QgsPropertyOverrideButton( QWidget *parent SIP_TRANSFERTHIS = nullptr,
63 const QgsVectorLayer *layer = nullptr );
64
73 void init( int propertyKey,
74 const QgsProperty &property,
75 const QgsPropertiesDefinition &definitions,
76 const QgsVectorLayer *layer = nullptr,
77 bool auxiliaryStorageEnabled = false );
78
87 void init( int propertyKey,
88 const QgsProperty &property,
89 const QgsPropertyDefinition &definition,
90 const QgsVectorLayer *layer = nullptr,
91 bool auxiliaryStorageEnabled = false );
92
101 void init( int propertyKey,
102 const QgsAbstractPropertyCollection &collection,
103 const QgsPropertiesDefinition &definitions,
104 const QgsVectorLayer *layer = nullptr,
105 bool auxiliaryStorageEnabled = false );
106
112 QgsProperty toProperty() const;
113
117 void setToProperty( const QgsProperty &property );
118
122 int propertyKey() const { return mPropertyKey; }
123
127 bool isActive() const { return mProperty && mProperty.isActive(); }
128
134 QgsPropertyDefinition::DataType validDataType() const { return mDataTypes; }
135
140 QString fullDescription() const { return mFullDescription; }
141
146 QString usageInfo() const { return mUsageInfo; }
147
152 void setUsageInfo( const QString &info ) { mUsageInfo = info; updateGui(); }
153
159 void setVectorLayer( const QgsVectorLayer *layer );
160
166 const QgsVectorLayer *vectorLayer() const { return mVectorLayer; }
167
173 void registerCheckedWidget( QWidget *widget, bool natural = true );
174
180 void registerEnabledWidget( QWidget *widget, bool natural = true );
181
187 void registerVisibleWidget( QWidget *widget, bool natural = true );
188
193 void registerExpressionWidget( QWidget *widget );
194
199 void registerExpressionContextGenerator( QgsExpressionContextGenerator *generator );
200
210 void registerLinkedWidget( QWidget *widget );
211
217 void updateFieldLists();
218
224 void setSymbol( std::shared_ptr< QgsSymbol > symbol ) { mSymbol = symbol; } SIP_SKIP
225
226 public slots:
227
231 void setActive( bool active );
232
233
235
236 // exposed to Python for testing only
237 void aboutToShowMenu();
238 void menuActionTriggered( QAction *action );
239
241
242 signals:
243
245 void changed();
246
248 void activated( bool isActive );
249
252
253 protected:
254 void mouseReleaseEvent( QMouseEvent *event ) override;
255
256 private:
257
258 void showDescriptionDialog();
259 void showExpressionDialog();
260 void showAssistant();
261 void updateGui();
262
267 void setActivePrivate( bool active );
268
269
270 int mPropertyKey = -1;
271
272 const QgsVectorLayer *mVectorLayer = nullptr;
273
274 QStringList mFieldNameList;
275 QStringList mFieldDisplayNameList;
276 QList< QIcon > mFieldIcons;
277
278 QString mExpressionString;
279 QString mFieldName;
280
281 QMenu *mDefineMenu = nullptr;
282 QAction *mActionDataTypes = nullptr;
283 QMenu *mFieldsMenu = nullptr;
284 QMenu *mVariablesMenu = nullptr;
285 QAction *mActionVariables = nullptr;
286 QMenu *mColorsMenu = nullptr;
287 QAction *mActionColors = nullptr;
288
289 QAction *mActionActive = nullptr;
290 QAction *mActionDescription = nullptr;
291 QAction *mActionExpDialog = nullptr;
292 QAction *mActionExpression = nullptr;
293 QAction *mActionPasteExpr = nullptr;
294 QAction *mActionCopyExpr = nullptr;
295 QAction *mActionClearExpr = nullptr;
296 QAction *mActionAssistant = nullptr;
297 QAction *mActionCreateAuxiliaryField = nullptr;
298
299 QgsPropertyDefinition mDefinition;
300
302 QString mDataTypesString;
303 QString mInputDescription;
304 QString mFullDescription;
305 QString mUsageInfo;
306
307 QgsExpressionContextGenerator *mExpressionContextGenerator = nullptr;
308
309 enum SiblingType
310 {
311 SiblingCheckState,
312 SiblingEnableState,
313 SiblingVisibility,
314 SiblingExpressionText,
315 SiblingLinkedWidget,
316 };
317 struct SiblingWidget
318 {
319 SiblingWidget( const QPointer<QWidget> &widgetPointer, SiblingType siblingType, bool natural = true )
320 : mWidgetPointer( widgetPointer )
321 , mSiblingType( siblingType )
322 , mNatural( natural )
323 {}
324 QPointer<QWidget> mWidgetPointer;
325 SiblingType mSiblingType;
326 bool mNatural;
327 };
328 QList< SiblingWidget > mSiblingWidgets;
329
331 QgsProperty mProperty;
332
333 bool mAuxiliaryStorageEnabled = false;
334
335 std::shared_ptr< QgsSymbol > mSymbol;
336
337 private slots:
338
339 void showHelp();
340 void updateSiblingWidgets( bool state );
341};
342
343#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:46
DataType
Valid data types required by property.
Definition qgsproperty.h:84
@ DataTypeString
Property requires a string value.
Definition qgsproperty.h:91
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.