Skip to content

Commit 33abb78

Browse files
committedDec 22, 2016
Pass variable values as QVariant
1 parent 79f32ab commit 33abb78

14 files changed

+61
-157
lines changed
 

‎python/core/qgsapplication.sip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,9 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
406406
static QgsFieldFormatterRegistry* fieldFormatterRegistry();
407407
static QString nullRepresentation();
408408
static void setNullRepresentation( const QString& nullRepresentation );
409-
static QgsStringMap customVariables();
410-
static void setCustomVariables(const QgsStringMap& customVariables);
411-
static void setCustomVariable(const QString& name, const QString& value);
409+
static QVariantMap customVariables();
410+
static void setCustomVariables( const QVariantMap& customVariables );
411+
static void setCustomVariable( const QString& name, const QVariant& value );
412412
signals:
413413
//! @note not available in python bindings
414414
// void preNotify( QObject * receiver, QEvent * event, bool * done );

‎python/core/qgsexpressioncontext.sip

Lines changed: 5 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -482,46 +482,11 @@ class QgsExpressionContextUtils
482482
* @see setGlobalVariable()
483483
*/
484484
static QgsExpressionContextScope* globalScope() /Factory/;
485-
486-
/** Sets a global context variable. This variable will be contained within scopes retrieved via
487-
* globalScope().
488-
* @param name variable name
489-
* @param value variable value
490-
* @see setGlobalVariable()
491-
* @see globalScope()
492-
*/
493485
static void setGlobalVariable( const QString& name, const QVariant& value );
494-
495-
/** Sets all global context variables. Existing global variables will be removed and replaced
496-
* with the variables specified.
497-
* @param variables new set of global variables
498-
* @see setGlobalVariable()
499-
* @see globalScope()
500-
*/
501-
static void setGlobalVariables( const QgsStringMap& variables );
502-
503-
/** Creates a new scope which contains variables and functions relating to the current QGIS project.
504-
* For instance, project path and title, and variables specified through the project properties.
505-
* @see setProjectVariable()
506-
*/
486+
static void setGlobalVariables( const QVariantMap& variables );
507487
static QgsExpressionContextScope* projectScope() /Factory/;
508-
509-
/** Sets a project context variable. This variable will be contained within scopes retrieved via
510-
* projectScope().
511-
* @param name variable name
512-
* @param value variable value
513-
* @see setProjectVariables()
514-
* @see projectScope()
515-
*/
516488
static void setProjectVariable( const QString& name, const QVariant& value );
517-
518-
/** Sets all project context variables. Existing project variables will be removed and replaced
519-
* with the variables specified.
520-
* @param variables new set of project variables
521-
* @see setProjectVariable()
522-
* @see projectScope()
523-
*/
524-
static void setProjectVariables( const QgsStringMap& variables );
489+
static void setProjectVariables( const QVariantMap& variables );
525490

526491
/** Creates a new scope which contains variables and functions relating to a QgsMapLayer.
527492
* For instance, layer name, id and fields.
@@ -537,15 +502,7 @@ class QgsExpressionContextUtils
537502
* @see layerScope()
538503
*/
539504
static void setLayerVariable( QgsMapLayer* layer, const QString& name, const QVariant& value );
540-
541-
/** Sets all layer context variables. Existing layer variables will be removed and replaced
542-
* with the variables specified.
543-
* @param layer map layer
544-
* @param variables new set of layer variables
545-
* @see setLayerVariable()
546-
* @see layerScope()
547-
*/
548-
static void setLayerVariables( QgsMapLayer* layer, const QgsStringMap& variables );
505+
static void setLayerVariables( QgsMapLayer* layer, const QVariantMap& variables );
549506

550507
/** Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
551508
* For instance, map scale and rotation.
@@ -575,26 +532,8 @@ class QgsExpressionContextUtils
575532
* @see compositionScope()
576533
*/
577534
static void setCompositionVariable( QgsComposition* composition, const QString& name, const QVariant& value );
578-
579-
/** Sets all composition context variables. Existing composition variables will be removed and replaced
580-
* with the variables specified.
581-
* @param composition target composition
582-
* @param variables new set of layer variables
583-
* @see setCompositionVariable()
584-
* @see compositionScope()
585-
*/
586-
static void setCompositionVariables( QgsComposition* composition, const QgsStringMap& variables );
587-
588-
/** Creates a new scope which contains variables and functions relating to a QgsAtlasComposition.
589-
* For instance, current page name and number.
590-
* @param atlas source atlas. If null, a set of default atlas variables will be added to the scope.
591-
*/
535+
static void setCompositionVariables( QgsComposition* composition, const QVariantMap& variables );
592536
static QgsExpressionContextScope* atlasScope( const QgsAtlasComposition* atlas ) /Factory/;
593-
594-
/** Creates a new scope which contains variables and functions relating to a QgsComposerItem.
595-
* For instance, item size and position.
596-
* @param composerItem source composer item
597-
*/
598537
static QgsExpressionContextScope* composerItemScope( const QgsComposerItem *composerItem ) /Factory/;
599538

600539
/** Sets a composer item context variable. This variable will be contained within scopes retrieved via
@@ -606,20 +545,7 @@ class QgsExpressionContextUtils
606545
* @see composerItemScope()
607546
*/
608547
static void setComposerItemVariable( QgsComposerItem* composerItem, const QString& name, const QVariant& value );
609-
610-
/** Sets all composition context variables. Existing compositoin variables will be removed and replaced
611-
* with the variables specified.
612-
* @param composerItem target composer item
613-
* @param variables new set of layer variables
614-
* @see setComposerItemVariable()
615-
* @see composerItemScope()
616-
*/
617-
static void setComposerItemVariables( QgsComposerItem* composerItem, const QgsStringMap& variables );
618-
619-
/** Helper function for creating an expression context which contains just a feature and fields
620-
* collection. Generally this method should not be used as the created context does not include
621-
* standard scopes such as the global and project scopes.
622-
*/
548+
static void setComposerItemVariables( QgsComposerItem* composerItem, const QVariantMap& variables );
623549
static QgsExpressionContext createFeatureBasedContext( const QgsFeature& feature, const QgsFields& fields );
624550

625551
/** Registers all known core functions provided by QgsExpressionContextScope objects.

‎python/core/qgsproject.sip

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -420,25 +420,8 @@ class QgsProject : QObject, QgsExpressionContextGenerator
420420
* @note Added in QGIS 3.0
421421
*/
422422
void setAvoidIntersectionsList( const QStringList& avoidIntersectionsList );
423-
424-
/**
425-
* A map of custom project variables.
426-
* To get all available variables including generated ones
427-
* use QgsExpressionContextUtils::projectScope() instead.
428-
*/
429-
QgsStringMap customVariables() const;
430-
431-
/**
432-
* A map of custom project variables.
433-
* Be careful not to set generated variables.
434-
*/
435-
void setCustomVariables( const QgsStringMap& customVariables );
436-
437-
//
438-
// Functionality from QgsMapLayerRegistry
439-
//
440-
441-
//! Returns the number of registered layers.
423+
QVariantMap customVariables() const;
424+
void setCustomVariables( const QVariantMap& customVariables );
442425
int count() const;
443426

444427
/** Retrieve a pointer to a registered layer by layer ID.

‎python/gui/qgsvariableeditorwidget.sip

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,7 @@ class QgsVariableEditorWidget : QWidget
7070
* @see setSettingGroup()
7171
*/
7272
QString settingGroup() const;
73-
74-
/** Returns a map variables set within the editable scope. Read only variables are not
75-
* returned. This method can be used to retrieve the variables edited an added by
76-
* users via the widget.
77-
*/
78-
QgsStringMap variablesInActiveScope() const;
73+
QVariantMap variablesInActiveScope() const;
7974

8075
signals:
8176

‎src/core/qgsapplication.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,12 +1258,12 @@ void QgsApplication::copyPath( const QString& src, const QString& dst )
12581258
}
12591259
}
12601260

1261-
QgsStringMap QgsApplication::customVariables()
1261+
QVariantMap QgsApplication::customVariables()
12621262
{
12631263
//read values from QSettings
12641264
QSettings settings;
12651265

1266-
QgsStringMap variables;
1266+
QVariantMap variables;
12671267

12681268
//check if settings contains any variables
12691269
if ( settings.contains( QStringLiteral( "/variables/values" ) ) )
@@ -1282,35 +1282,35 @@ QgsStringMap QgsApplication::customVariables()
12821282
QVariant value = ( *it );
12831283
QString name = customVariableNames.at( variableIndex ).toString();
12841284

1285-
variables.insert( name, value.toString() );
1285+
variables.insert( name, value );
12861286
variableIndex++;
12871287
}
12881288
}
12891289

12901290
return variables;
12911291
}
12921292

1293-
void QgsApplication::setCustomVariables( const QgsStringMap& variables )
1293+
void QgsApplication::setCustomVariables( const QVariantMap& variables )
12941294
{
12951295
QSettings settings;
12961296

1297-
QList< QVariant > customVariableVariants;
1297+
QList< QVariant > customVariableValues;
12981298
QList< QVariant > customVariableNames;
12991299

1300-
QMap< QString, QString >::const_iterator it = variables.constBegin();
1300+
QVariantMap::const_iterator it = variables.constBegin();
13011301
for ( ; it != variables.constEnd(); ++it )
13021302
{
13031303
customVariableNames << it.key();
1304-
customVariableVariants << it.value();
1304+
customVariableValues << it.value();
13051305
}
13061306

13071307
settings.setValue( QStringLiteral( "/variables/names" ), customVariableNames );
1308-
settings.setValue( QStringLiteral( "/variables/values" ), customVariableVariants );
1308+
settings.setValue( QStringLiteral( "/variables/values" ), customVariableValues );
13091309

13101310
emit instance()->customVariablesChanged();
13111311
}
13121312

1313-
void QgsApplication::setCustomVariable( const QString& name, const QString& value )
1313+
void QgsApplication::setCustomVariable( const QString& name, const QVariant& value )
13141314
{
13151315
// save variable to settings
13161316
QSettings settings;

‎src/core/qgsapplication.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ class CORE_EXPORT QgsApplication : public QApplication
424424
* \see QgsExpressionContextUtils::globalVariables().
425425
* \note Added in QGIS 3.0
426426
*/
427-
static QgsStringMap customVariables();
427+
static QVariantMap customVariables();
428428

429429
/**
430430
* Custom expression variables for this application.
@@ -433,15 +433,15 @@ class CORE_EXPORT QgsApplication : public QApplication
433433
* \see QgsExpressionContextUtils::globalVariables().
434434
* \note Added in QGIS 3.0
435435
*/
436-
static void setCustomVariables( const QgsStringMap& customVariables );
436+
static void setCustomVariables( const QVariantMap& customVariables );
437437

438438

439439
/**
440440
* Set a single custom expression variable.
441441
*
442442
* \note Added in QGIS 3.0
443443
*/
444-
static void setCustomVariable( const QString& name, const QString& value );
444+
static void setCustomVariable( const QString& name, const QVariant& value );
445445

446446
signals:
447447
//! @note not available in python bindings

‎src/core/qgsexpressioncontext.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,9 @@ QgsExpressionContextScope* QgsExpressionContextUtils::globalScope()
501501
{
502502
QgsExpressionContextScope* scope = new QgsExpressionContextScope( QObject::tr( "Global" ) );
503503

504-
QgsStringMap customVariables = QgsApplication::customVariables();
504+
QVariantMap customVariables = QgsApplication::customVariables();
505505

506-
for ( QgsStringMap::const_iterator it = customVariables.constBegin(); it != customVariables.constEnd(); ++it )
506+
for ( QVariantMap::const_iterator it = customVariables.constBegin(); it != customVariables.constEnd(); ++it )
507507
{
508508
scope->setVariable( it.key(), it.value() );
509509
}
@@ -522,10 +522,10 @@ QgsExpressionContextScope* QgsExpressionContextUtils::globalScope()
522522

523523
void QgsExpressionContextUtils::setGlobalVariable( const QString& name, const QVariant& value )
524524
{
525-
QgsApplication::setCustomVariable( name, value.toString() );
525+
QgsApplication::setCustomVariable( name, value );
526526
}
527527

528-
void QgsExpressionContextUtils::setGlobalVariables( const QgsStringMap &variables )
528+
void QgsExpressionContextUtils::setGlobalVariables( const QVariantMap &variables )
529529
{
530530
QgsApplication::setCustomVariables( variables );
531531
}
@@ -589,9 +589,9 @@ QgsExpressionContextScope* QgsExpressionContextUtils::projectScope()
589589

590590
QgsExpressionContextScope* scope = new QgsExpressionContextScope( QObject::tr( "Project" ) );
591591

592-
const QgsStringMap vars = QgsProject::instance()->customVariables();
592+
const QVariantMap vars = QgsProject::instance()->customVariables();
593593

594-
QgsStringMap::const_iterator it = vars.constBegin();
594+
QVariantMap::const_iterator it = vars.constBegin();
595595

596596
for ( ; it != vars.constEnd(); ++it )
597597
{
@@ -615,14 +615,14 @@ void QgsExpressionContextUtils::setProjectVariable( const QString& name, const Q
615615
{
616616
QgsProject* project = QgsProject::instance();
617617

618-
QgsStringMap vars = project->customVariables();
618+
QVariantMap vars = project->customVariables();
619619

620-
vars.insert( name, value.toString() );
620+
vars.insert( name, value );
621621

622622
project->setCustomVariables( vars );
623623
}
624624

625-
void QgsExpressionContextUtils::setProjectVariables( const QgsStringMap& variables )
625+
void QgsExpressionContextUtils::setProjectVariables( const QVariantMap& variables )
626626
{
627627
QgsProject::instance()->setCustomVariables( variables );
628628
}
@@ -684,19 +684,19 @@ void QgsExpressionContextUtils::setLayerVariable( QgsMapLayer* layer, const QStr
684684
layer->setCustomProperty( QStringLiteral( "variableValues" ), variableValues );
685685
}
686686

687-
void QgsExpressionContextUtils::setLayerVariables( QgsMapLayer* layer, const QgsStringMap& variables )
687+
void QgsExpressionContextUtils::setLayerVariables( QgsMapLayer* layer, const QVariantMap& variables )
688688
{
689689
if ( !layer )
690690
return;
691691

692692
QStringList variableNames;
693693
QStringList variableValues;
694694

695-
QMap< QString, QString >::const_iterator it = variables.constBegin();
695+
QVariantMap::const_iterator it = variables.constBegin();
696696
for ( ; it != variables.constEnd(); ++it )
697697
{
698698
variableNames << it.key();
699-
variableValues << it.value();
699+
variableValues << it.value().toString();
700700
}
701701

702702
layer->setCustomProperty( QStringLiteral( "variableNames" ), variableNames );
@@ -790,19 +790,19 @@ void QgsExpressionContextUtils::setCompositionVariable( QgsComposition* composit
790790
composition->setCustomProperty( QStringLiteral( "variableValues" ), variableValues );
791791
}
792792

793-
void QgsExpressionContextUtils::setCompositionVariables( QgsComposition* composition, const QgsStringMap& variables )
793+
void QgsExpressionContextUtils::setCompositionVariables( QgsComposition* composition, const QVariantMap& variables )
794794
{
795795
if ( !composition )
796796
return;
797797

798798
QStringList variableNames;
799799
QStringList variableValues;
800800

801-
QMap< QString, QString >::const_iterator it = variables.constBegin();
801+
QVariantMap::const_iterator it = variables.constBegin();
802802
for ( ; it != variables.constEnd(); ++it )
803803
{
804804
variableNames << it.key();
805-
variableValues << it.value();
805+
variableValues << it.value().toString();
806806
}
807807

808808
composition->setCustomProperty( QStringLiteral( "variableNames" ), variableNames );
@@ -893,19 +893,19 @@ void QgsExpressionContextUtils::setComposerItemVariable( QgsComposerItem* compos
893893
composerItem->setCustomProperty( QStringLiteral( "variableValues" ), variableValues );
894894
}
895895

896-
void QgsExpressionContextUtils::setComposerItemVariables( QgsComposerItem* composerItem, const QgsStringMap& variables )
896+
void QgsExpressionContextUtils::setComposerItemVariables( QgsComposerItem* composerItem, const QVariantMap& variables )
897897
{
898898
if ( !composerItem )
899899
return;
900900

901901
QStringList variableNames;
902902
QStringList variableValues;
903903

904-
QMap< QString, QString >::const_iterator it = variables.constBegin();
904+
QVariantMap::const_iterator it = variables.constBegin();
905905
for ( ; it != variables.constEnd(); ++it )
906906
{
907907
variableNames << it.key();
908-
variableValues << it.value();
908+
variableValues << it.value().toString();
909909
}
910910

911911
composerItem->setCustomProperty( QStringLiteral( "variableNames" ), variableNames );

‎src/core/qgsexpressioncontext.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ class CORE_EXPORT QgsExpressionContextUtils
564564
* @see setGlobalVariable()
565565
* @see globalScope()
566566
*/
567-
static void setGlobalVariables( const QgsStringMap& variables );
567+
static void setGlobalVariables( const QVariantMap& variables );
568568

569569
/** Creates a new scope which contains variables and functions relating to the current QGIS project.
570570
* For instance, project path and title, and variables specified through the project properties.
@@ -587,7 +587,7 @@ class CORE_EXPORT QgsExpressionContextUtils
587587
* @see setProjectVariable()
588588
* @see projectScope()
589589
*/
590-
static void setProjectVariables( const QgsStringMap& variables );
590+
static void setProjectVariables( const QVariantMap& variables );
591591

592592
/** Creates a new scope which contains variables and functions relating to a QgsMapLayer.
593593
* For instance, layer name, id and fields.
@@ -611,7 +611,7 @@ class CORE_EXPORT QgsExpressionContextUtils
611611
* @see setLayerVariable()
612612
* @see layerScope()
613613
*/
614-
static void setLayerVariables( QgsMapLayer* layer, const QgsStringMap& variables );
614+
static void setLayerVariables( QgsMapLayer* layer, const QVariantMap& variables );
615615

616616
/** Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
617617
* For instance, map scale and rotation.
@@ -649,7 +649,7 @@ class CORE_EXPORT QgsExpressionContextUtils
649649
* @see setCompositionVariable()
650650
* @see compositionScope()
651651
*/
652-
static void setCompositionVariables( QgsComposition* composition, const QgsStringMap& variables );
652+
static void setCompositionVariables( QgsComposition* composition, const QVariantMap& variables );
653653

654654
/** Creates a new scope which contains variables and functions relating to a QgsAtlasComposition.
655655
* For instance, current page name and number.
@@ -680,7 +680,7 @@ class CORE_EXPORT QgsExpressionContextUtils
680680
* @see setComposerItemVariable()
681681
* @see composerItemScope()
682682
*/
683-
static void setComposerItemVariables( QgsComposerItem* composerItem, const QgsStringMap& variables );
683+
static void setComposerItemVariables( QgsComposerItem* composerItem, const QVariantMap& variables );
684684

685685
/** Helper function for creating an expression context which contains just a feature and fields
686686
* collection. Generally this method should not be used as the created context does not include

‎src/core/qgsproject.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -994,12 +994,12 @@ void QgsProject::loadEmbeddedNodes( QgsLayerTreeGroup *group )
994994
}
995995
}
996996

997-
QgsStringMap QgsProject::customVariables() const
997+
QVariantMap QgsProject::customVariables() const
998998
{
999999
return mCustomVariables;
10001000
}
10011001

1002-
void QgsProject::setCustomVariables( const QgsStringMap& variables )
1002+
void QgsProject::setCustomVariables( const QVariantMap& variables )
10031003
{
10041004
if ( variables == mCustomVariables )
10051005
return;
@@ -1008,11 +1008,11 @@ void QgsProject::setCustomVariables( const QgsStringMap& variables )
10081008
QStringList variableNames;
10091009
QStringList variableValues;
10101010

1011-
QMap< QString, QString >::const_iterator it = variables.constBegin();
1011+
QVariantMap::const_iterator it = variables.constBegin();
10121012
for ( ; it != variables.constEnd(); ++it )
10131013
{
10141014
variableNames << it.key();
1015-
variableValues << it.value();
1015+
variableValues << it.value().toString();
10161016
}
10171017

10181018
writeEntry( QStringLiteral( "Variables" ), QStringLiteral( "/variableNames" ), variableNames );

‎src/core/qgsproject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,13 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
504504
* To get all available variables including generated ones
505505
* use QgsExpressionContextUtils::projectScope() instead.
506506
*/
507-
QgsStringMap customVariables() const;
507+
QVariantMap customVariables() const;
508508

509509
/**
510510
* A map of custom project variables.
511511
* Be careful not to set generated variables.
512512
*/
513-
void setCustomVariables( const QgsStringMap& customVariables );
513+
void setCustomVariables( const QVariantMap& customVariables );
514514

515515
//
516516
// Functionality from QgsMapLayerRegistry
@@ -994,7 +994,7 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
994994

995995
QScopedPointer<QgsMapThemeCollection> mMapThemeCollection;
996996

997-
QgsStringMap mCustomVariables;
997+
QVariantMap mCustomVariables;
998998

999999
QFile mFile; // current physical project file
10001000
mutable QgsPropertyKey mProperties; // property hierarchy, TODO: this shouldn't be mutable

‎src/gui/qgsvariableeditorwidget.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,9 @@ QgsExpressionContextScope* QgsVariableEditorWidget::editableScope() const
132132
return mContext->scope( mEditableScopeIndex );
133133
}
134134

135-
QgsStringMap QgsVariableEditorWidget::variablesInActiveScope() const
135+
QVariantMap QgsVariableEditorWidget::variablesInActiveScope() const
136136
{
137-
QgsStringMap variables;
137+
QVariantMap variables;
138138
if ( !mContext || mEditableScopeIndex < 0 || mEditableScopeIndex >= mContext->scopeCount() )
139139
{
140140
return variables;
@@ -146,7 +146,7 @@ QgsStringMap QgsVariableEditorWidget::variablesInActiveScope() const
146146
if ( scope->isReadOnly( variable ) )
147147
continue;
148148

149-
variables.insert( variable, scope->variable( variable ).toString() );
149+
variables.insert( variable, scope->variable( variable ) );
150150
}
151151

152152
return variables;

‎src/gui/qgsvariableeditorwidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class GUI_EXPORT QgsVariableEditorWidget : public QWidget
9999
* returned. This method can be used to retrieve the variables edited an added by
100100
* users via the widget.
101101
*/
102-
QgsStringMap variablesInActiveScope() const;
102+
QVariantMap variablesInActiveScope() const;
103103

104104
public slots:
105105

‎tests/src/core/testqgsexpressioncontext.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ void TestQgsExpressionContext::globalScope()
516516
QCOMPARE( expPlatform.evaluate( &context ).toString(), QgsApplication::platform() );
517517

518518
//test setGlobalVariables
519-
QgsStringMap vars;
519+
QVariantMap vars;
520520
vars.insert( QStringLiteral( "newvar1" ), QStringLiteral( "val1" ) );
521521
vars.insert( QStringLiteral( "newvar2" ), QStringLiteral( "val2" ) );
522522
QgsExpressionContextUtils::setGlobalVariables( vars );
@@ -561,7 +561,7 @@ void TestQgsExpressionContext::projectScope()
561561
delete projectScope;
562562

563563
//test setProjectVariables
564-
QgsStringMap vars;
564+
QVariantMap vars;
565565
vars.insert( QStringLiteral( "newvar1" ), QStringLiteral( "val1" ) );
566566
vars.insert( QStringLiteral( "newvar2" ), QStringLiteral( "val2" ) );
567567
QgsExpressionContextUtils::setProjectVariables( vars );
@@ -624,7 +624,7 @@ void TestQgsExpressionContext::layerScope()
624624
layerScope = QgsExpressionContextUtils::layerScope( vectorLayer.data() );
625625
QCOMPARE( layerScope->variable( "testvar" ).toString(), QString( "testval" ) );
626626

627-
QgsStringMap variables;
627+
QVariantMap variables;
628628
variables.insert( QStringLiteral( "var1" ), QStringLiteral( "val1" ) );
629629
variables.insert( QStringLiteral( "var2" ), QStringLiteral( "val2" ) );
630630
QgsExpressionContextUtils::setLayerVariables( vectorLayer.data(), variables );

‎tests/src/core/testqgsproject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void TestQgsProject::variablesChanged()
132132
{
133133
QgsProject* prj = new QgsProject;
134134
QSignalSpy spyVariablesChanged( prj, &QgsProject::customVariablesChanged );
135-
QgsStringMap vars;
135+
QVariantMap vars;
136136
vars.insert( QStringLiteral( "variable" ), QStringLiteral( "1" ) );
137137
prj->setCustomVariables( vars );
138138
QVERIFY( spyVariablesChanged.count() == 1 );

0 commit comments

Comments
 (0)
Please sign in to comment.