Skip to content

Commit 3ca0b90

Browse files
committed
Update sip bindings
1 parent c78f940 commit 3ca0b90

6 files changed

+57
-15
lines changed

doc/api_break.dox

+1
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
272272
- QgsPseudoColorShader. This shader has been broken for some time and was replaced by QgsSingleBandPseudoColorRenderer.
273273
- QgsProjectBadLayerGuiHandler was removed. It was unused in QGIS code and barely useful. Implement your own QgsProjectBadLayerHandler subclass if needed.
274274
- QgsRendererV2DataDefinedMenus was removed. Use QgsDataDefinedButton instead.
275+
- QgsSizeScaleWidget. Use QgsPropertyAssistantWidget instead.
275276
- QgsLegacyHelpers.
276277
- QgsProviderCountCalcEvent and QgsProviderExtentCalcEvent. These classes were unused in QGIS core and unmaintained.
277278
- QgsWebviewWidgetWrapper was removed. Use QgsExternalResourceWidgetWrapper instead.

python/core/qgspropertytransformer.sip

+43-10
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/;
@@ -50,11 +52,42 @@ class QgsPropertyTransformer
5052
static QgsPropertyTransformer* fromExpression( const QString& expression, QString& baseExpression /Out/, QString& fieldName /Out/ ) /Factory/;
5153

5254
};
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 );
5385

86+
};
5487
class QgsSizeScaleTransformer : QgsPropertyTransformer
5588
{
5689
%TypeHeaderCode
57-
#include <qgsproperty.h>
90+
#include <qgspropertytransformer.h>
5891
%End
5992
public:
6093

@@ -111,7 +144,7 @@ class QgsSizeScaleTransformer : QgsPropertyTransformer
111144
class QgsColorRampTransformer : QgsPropertyTransformer
112145
{
113146
%TypeHeaderCode
114-
#include <qgsproperty.h>
147+
#include <qgspropertytransformer.h>
115148
%End
116149
public:
117150

python/gui/qgspropertyassistantwidget.sip

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ class QgsPropertyAssistantWidget : public QgsPanelWidget
66

77
public:
88

9-
QgsPropertyAssistantWidget( QWidget* parent /TransferThis/ = nullptr );
9+
QgsPropertyAssistantWidget( QWidget* parent /TransferThis/ = 0, const QgsPropertyDefinition& definition = QgsPropertyDefinition(),
10+
const QgsProperty& initialState = QgsProperty(),
11+
const QgsVectorLayer* layer = 0 );
1012

11-
};
13+
void registerExpressionContextGenerator( QgsExpressionContextGenerator* generator );
14+
15+
void updateProperty( QgsProperty& property );
1216

17+
void setDockMode( bool dockMode );
18+
};

src/gui/qgspropertyassistantwidget.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ QgsPropertyAssistantWidget::QgsPropertyAssistantWidget( QWidget* parent ,
6161
mRoot.addChildNode( mLayerTreeLayer ); // takes ownership
6262
}
6363
mLegendPreview->setModel( &mPreviewList );
64-
mLegendPreview->setItemDelegate( new ItemDelegate( &mPreviewList ) );
64+
mLegendPreview->setItemDelegate( new QgsAssistantPreviewItemDelegate( &mPreviewList ) );
6565
mLegendPreview->setHeaderHidden( true );
6666
mLegendPreview->expandAll();
6767
mLegendVerticalFrame->setLayout( new QVBoxLayout() );

src/gui/qgspropertyassistantwidget.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ class GUI_EXPORT QgsPropertyAssistantWidget : public QgsPanelWidget, private Ui:
140140
/**
141141
* Sets a symbol which can be used for previews inside the widget. If not specified, default
142142
* created symbols will be used instead.
143+
* @note not available in Python bindings
143144
*/
144145
void setSymbol( std::shared_ptr< QgsSymbol > symbol ) { mSymbol = symbol; updatePreview(); }
145146

@@ -170,12 +171,12 @@ class GUI_EXPORT QgsPropertyAssistantWidget : public QgsPanelWidget, private Ui:
170171

171172

172173
/// @cond PRIVATE
173-
class ItemDelegate : public QItemDelegate
174+
class QgsAssistantPreviewItemDelegate : public QItemDelegate
174175
{
175176
Q_OBJECT
176177

177178
public:
178-
explicit ItemDelegate( QStandardItemModel* model ) : mModel( model ) {}
179+
explicit QgsAssistantPreviewItemDelegate( QStandardItemModel* model ) : mModel( model ) {}
179180

180181
QSize sizeHint( const QStyleOptionViewItem& /*option*/, const QModelIndex & index ) const override
181182
{

src/gui/qgspropertyoverridebutton.h

+1
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class GUI_EXPORT QgsPropertyOverrideButton: public QToolButton
159159
/**
160160
* Sets a symbol which can be used for previews inside the widget or in any dialog created
161161
* by the widget. If not specified, a default created symbol will be used instead.
162+
* @note not available in Python bindings
162163
*/
163164
void setSymbol( std::shared_ptr< QgsSymbol > symbol ) { mSymbol = symbol; }
164165

0 commit comments

Comments
 (0)