mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Allow storing QgsProperty in QVariant
This commit is contained in:
parent
499a35d0c8
commit
3cd3e5d378
@ -137,6 +137,8 @@ class QgsProperty
|
||||
|
||||
bool convertToTransformer();
|
||||
|
||||
operator QVariant() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -434,6 +434,12 @@ class CORE_EXPORT QgsProperty
|
||||
*/
|
||||
bool convertToTransformer();
|
||||
|
||||
//! Allows direct construction of QVariants from properties.
|
||||
operator QVariant() const
|
||||
{
|
||||
return QVariant::fromValue( *this );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
mutable QExplicitlySharedDataPointer<QgsPropertyPrivate> d;
|
||||
@ -446,4 +452,6 @@ class CORE_EXPORT QgsProperty
|
||||
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( QgsProperty )
|
||||
|
||||
#endif // QGSPROPERTY_H
|
||||
|
@ -92,6 +92,7 @@ class TestQgsProperty : public QObject
|
||||
void propertyCollection(); //test for QgsPropertyCollection
|
||||
void collectionStack(); //test for QgsPropertyCollectionStack
|
||||
void curveTransform();
|
||||
void asVariant();
|
||||
|
||||
private:
|
||||
|
||||
@ -1764,6 +1765,20 @@ void TestQgsProperty::curveTransform()
|
||||
QGSCOMPARENEAR( dest2.y( 0.5 ), 0.1, 0.638672 );
|
||||
}
|
||||
|
||||
void TestQgsProperty::asVariant()
|
||||
{
|
||||
QgsProperty original = QgsProperty::fromField( QStringLiteral( "field1" ), true );
|
||||
|
||||
//convert to and from a QVariant
|
||||
QVariant var = QVariant::fromValue( original );
|
||||
QVERIFY( var.isValid() );
|
||||
|
||||
QgsProperty fromVar = qvariant_cast<QgsProperty>( var );
|
||||
QCOMPARE( fromVar.propertyType(), QgsProperty::FieldBasedProperty );
|
||||
QVERIFY( fromVar.isActive() );
|
||||
QCOMPARE( fromVar.field(), QStringLiteral( "field1" ) );
|
||||
}
|
||||
|
||||
void TestQgsProperty::checkCurveResult( const QList<QgsPoint> &controlPoints, const QVector<double> &x, const QVector<double> &y )
|
||||
{
|
||||
// build transform
|
||||
|
Loading…
x
Reference in New Issue
Block a user