Skip to content

Commit e4d45e4

Browse files
authored
Merge pull request #4141 from nyalldawson/props_gui
Properties framework part 2 - gui component
2 parents edb30a2 + efb0c40 commit e4d45e4

File tree

61 files changed

+2603
-4247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2603
-4247
lines changed

doc/api_break.dox

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ Use QgsComposerAttributeTableV2 instead.
250250
- QgsCRSCache was removed. QgsCoordinateReferenceSystem now internally uses a cache for CRS creation,
251251
so there is no longer a need for the separate cache class. Code which previously called QgsCRSCache::updateCRSCache()
252252
should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinateTransformCache::instance()->invalidateCrs( authid ).
253+
- QgsDataDefined was removed. Use the QgsProperty framework instead.
254+
- QgsDataDefinedButton was removed. Use QgsPropertyOverrideButton instead.
253255
- QgsFileNameWidgetWrapper was removed. Use QgsExternalResourceWidgetWrapper instead.
254256
- QgsFormAnnotationItem. Use QgsFormAnnotation instead.
255257
- QgsHtmlAnnotationItem. Use QgsHtmlAnnotation instead.
@@ -270,10 +272,12 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
270272
- QgsPseudoColorShader. This shader has been broken for some time and was replaced by QgsSingleBandPseudoColorRenderer.
271273
- QgsProjectBadLayerGuiHandler was removed. It was unused in QGIS code and barely useful. Implement your own QgsProjectBadLayerHandler subclass if needed.
272274
- QgsRendererV2DataDefinedMenus was removed. Use QgsDataDefinedButton instead.
275+
- QgsSizeScaleWidget. Use QgsPropertyAssistantWidget instead.
273276
- QgsLegacyHelpers.
274277
- QgsProviderCountCalcEvent and QgsProviderExtentCalcEvent. These classes were unused in QGIS core and unmaintained.
275278
- QgsWebviewWidgetWrapper was removed. Use QgsExternalResourceWidgetWrapper instead.
276279
- QgsEditorWidgetConfig was removed. Use QVariantMap instead.
280+
- QgsScaleExpression. Use QgsProperty with a QgsSizeScalePropertyTransformer instead.
277281
- QgsSvgAnnotationItem. Use QgsSvgAnnotation instead.
278282
- QgsSymbologyV2Conversion was removed. Reading of renderers from pre-1.0 versions is not supported anymore.
279283
- QgsTextAnnotationItem. Use QgsTextAnnotation instead.

python/core/core.sip

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
%Include qgscoordinatetransform.sip
3434
%Include qgscredentials.sip
3535
%Include qgscrscache.sip
36-
%Include qgsdatadefined.sip
3736
%Include qgsdataitem.sip
3837
%Include qgsdataitemprovider.sip
3938
%Include qgsdataitemproviderregistry.sip
@@ -131,7 +130,6 @@
131130
%Include qgsrunprocess.sip
132131
%Include qgsruntimeprofiler.sip
133132
%Include qgsscalecalculator.sip
134-
%Include qgsscaleexpression.sip
135133
%Include qgsscaleutils.sip
136134
%Include qgssimplifymethod.sip
137135
%Include qgssnapper.sip

python/core/qgsdatadefined.sip

Lines changed: 0 additions & 179 deletions
This file was deleted.

python/core/qgsproperty.sip

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class QgsPropertyDefinition
1414
Double,
1515
DoublePositive,
1616
Double0To1,
17+
Rotation,
1718
String,
1819
Transparency,
1920
RenderUnits,
@@ -25,6 +26,7 @@ class QgsPropertyDefinition
2526
Size,
2627
Size2D,
2728
LineStyle,
29+
StrokeWidth,
2830
FillStyle,
2931
CapStyle,
3032
HorizontalAnchor,
@@ -57,6 +59,7 @@ class QgsPropertyDefinition
5759

5860
StandardPropertyTemplate standardTemplate() const;
5961

62+
bool supportsAssistant() const;
6063
};
6164

6265
class QgsProperty
@@ -87,6 +90,9 @@ class QgsProperty
8790

8891
operator bool() const;
8992

93+
bool operator==( const QgsProperty& other ) const;
94+
bool operator!=( const QgsProperty& other ) const;
95+
9096
Type propertyType() const;
9197

9298
bool isActive() const;
@@ -131,6 +137,8 @@ class QgsProperty
131137

132138
const QgsPropertyTransformer* transformer() const;
133139

140+
bool convertToTransformer();
141+
134142
};
135143

136144

python/core/qgspropertytransformer.sip

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
class QgsPropertyTransformer
22
{
33
%TypeHeaderCode
4-
#include <qgsproperty.h>
4+
#include <qgspropertytransformer.h>
55
%End
66

77
%ConvertToSubClassCode
8-
if (sipCpp->transformerType() == QgsPropertyTransformer::SizeScaleTransformer)
9-
sipType = sipType_QgsSizeScaleTransformer;
8+
if (sipCpp->transformerType() == QgsPropertyTransformer::GenericNumericTransformer)
9+
sipType = sipType_QgsGenericNumericTransformer;
10+
else if (sipCpp->transformerType() == QgsPropertyTransformer::SizeScaleTransformer)
11+
sipType = sipType_QgsSizeScaleTransformer;
1012
else if (sipCpp->transformerType() == QgsPropertyTransformer::ColorRampTransformer)
11-
sipType = sipType_QgsColorRampTransformer;
13+
sipType = sipType_QgsColorRampTransformer;
1214
else
13-
sipType = sipType_QgsPropertyTransformer;
15+
sipType = sipType_QgsPropertyTransformer;
1416
%End
1517

1618
public:
1719

18-
//! Transformer types
1920
enum Type
2021
{
21-
SizeScaleTransformer, /*!< Size scaling transformer (QgsSizeScaleTransformer) */
22-
ColorRampTransformer, /*!< Color ramp transformer (QgsColorRampTransformer) */
22+
GenericNumericTransformer,
23+
SizeScaleTransformer,
24+
ColorRampTransformer,
2325
};
2426

2527
static QgsPropertyTransformer* create( Type type ) /Factory/;
@@ -47,12 +49,45 @@ class QgsPropertyTransformer
4749
virtual QVariant transform( const QgsExpressionContext& context, const QVariant& value ) const = 0;
4850
virtual QString toExpression( const QString& baseExpression ) const = 0;
4951

52+
static QgsPropertyTransformer* fromExpression( const QString& expression, QString& baseExpression /Out/, QString& fieldName /Out/ ) /Factory/;
53+
5054
};
55+
class QgsGenericNumericTransformer : QgsPropertyTransformer
56+
{
57+
%TypeHeaderCode
58+
#include <qgspropertytransformer.h>
59+
%End
60+
61+
public:
62+
QgsGenericNumericTransformer( double minValue = 0.0,
63+
double maxValue = 1.0,
64+
double minOutput = 0.0,
65+
double maxOutput = 1.0,
66+
double nullOutput = 0.0,
67+
double exponent = 1.0 );
68+
69+
virtual Type transformerType() const;
70+
virtual QgsGenericNumericTransformer* clone() /Factory/;
71+
virtual bool writeXml( QDomElement& transformerElem, QDomDocument& doc ) const;
72+
virtual bool readXml( const QDomElement& transformerElem, const QDomDocument& doc );
73+
virtual QVariant transform( const QgsExpressionContext& context, const QVariant& value ) const;
74+
virtual QString toExpression( const QString& baseExpression ) const;
75+
static QgsGenericNumericTransformer* fromExpression( const QString& expression, QString& baseExpression, QString& fieldName ) /Factory/;
76+
double value( double input ) const;
77+
double minOutputValue() const;
78+
void setMinOutputValue( double size );
79+
double maxOutputValue() const;
80+
void setMaxOutputValue( double size );
81+
double nullOutputValue() const;
82+
void setNullOutputValue( double size );
83+
double exponent() const;
84+
void setExponent( double exponent );
5185

86+
};
5287
class QgsSizeScaleTransformer : QgsPropertyTransformer
5388
{
5489
%TypeHeaderCode
55-
#include <qgsproperty.h>
90+
#include <qgspropertytransformer.h>
5691
%End
5792
public:
5893

@@ -80,6 +115,8 @@ class QgsSizeScaleTransformer : QgsPropertyTransformer
80115
virtual QVariant transform( const QgsExpressionContext& context, const QVariant& value ) const;
81116
virtual QString toExpression( const QString& baseExpression ) const;
82117

118+
static QgsSizeScaleTransformer* fromExpression( const QString& expression, QString& baseExpression /Out/, QString& fieldName /Out/ ) /Factory/;
119+
83120
double size( double value ) const;
84121

85122
double minSize() const;
@@ -107,7 +144,7 @@ class QgsSizeScaleTransformer : QgsPropertyTransformer
107144
class QgsColorRampTransformer : QgsPropertyTransformer
108145
{
109146
%TypeHeaderCode
110-
#include <qgsproperty.h>
147+
#include <qgspropertytransformer.h>
111148
%End
112149
public:
113150

0 commit comments

Comments
 (0)