diff --git a/python/gui/qgsexpressionbuilderwidget.sip b/python/gui/qgsexpressionbuilderwidget.sip index 5663a7a5bdd..c49502cf0cf 100644 --- a/python/gui/qgsexpressionbuilderwidget.sip +++ b/python/gui/qgsexpressionbuilderwidget.sip @@ -141,9 +141,17 @@ class QgsExpressionBuilderWidget : QWidget bool isExpressionValid(); - void saveToRecent( const QString& key ); + /** + * Adds the current expression to the given collection. + * By default it is saved to the collection "generic". + */ + void saveToRecent( const QString& collection = "generic" ); - void loadRecent( const QString& key ); + /** + * Loads the recent expressions from the given collection. + * By default it is loaded from the collection "generic". + */ + void loadRecent( const QString& collection = "generic" ); /** Create a new file in the function editor */ diff --git a/src/gui/qgsexpressionbuilderwidget.cpp b/src/gui/qgsexpressionbuilderwidget.cpp index 0f6c07c08da..f3aa094d24e 100644 --- a/src/gui/qgsexpressionbuilderwidget.cpp +++ b/src/gui/qgsexpressionbuilderwidget.cpp @@ -399,10 +399,10 @@ bool QgsExpressionBuilderWidget::isExpressionValid() return mExpressionValid; } -void QgsExpressionBuilderWidget::saveToRecent( const QString& key ) +void QgsExpressionBuilderWidget::saveToRecent( const QString& collection ) { QSettings settings; - QString location = QString( "/expressions/recent/%1" ).arg( key ); + QString location = QString( "/expressions/recent/%1" ).arg( collection ); QStringList expressions = settings.value( location ).toStringList(); expressions.removeAll( this->expressionText() ); @@ -414,13 +414,13 @@ void QgsExpressionBuilderWidget::saveToRecent( const QString& key ) } settings.setValue( location, expressions ); - this->loadRecent( key ); + this->loadRecent( collection ); } -void QgsExpressionBuilderWidget::loadRecent( const QString& key ) +void QgsExpressionBuilderWidget::loadRecent( const QString& collection ) { - mRecentKey = key; - QString name = tr( "Recent (%1)" ).arg( key ); + mRecentKey = collection; + QString name = tr( "Recent (%1)" ).arg( collection ); if ( mExpressionGroups.contains( name ) ) { QgsExpressionItem* node = mExpressionGroups.value( name ); @@ -428,7 +428,7 @@ void QgsExpressionBuilderWidget::loadRecent( const QString& key ) } QSettings settings; - QString location = QString( "/expressions/recent/%1" ).arg( key ); + QString location = QString( "/expressions/recent/%1" ).arg( collection ); QStringList expressions = settings.value( location ).toStringList(); int i = 0; Q_FOREACH ( const QString& expression, expressions ) diff --git a/src/gui/qgsexpressionbuilderwidget.h b/src/gui/qgsexpressionbuilderwidget.h index 03089589595..7ea188b0830 100644 --- a/src/gui/qgsexpressionbuilderwidget.h +++ b/src/gui/qgsexpressionbuilderwidget.h @@ -186,9 +186,17 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp bool isExpressionValid(); - void saveToRecent( const QString& key ); + /** + * Adds the current expression to the given collection. + * By default it is saved to the collection "generic". + */ + void saveToRecent( const QString& collection = "generic" ); - void loadRecent( const QString& key ); + /** + * Loads the recent expressions from the given collection. + * By default it is loaded from the collection "generic". + */ + void loadRecent( const QString& collection = "generic" ); /** Create a new file in the function editor */