Skip to content
Permalink
Browse files

Make using recent expressions API simpler and add doxygen comment

  • Loading branch information
m-kuhn committed Jul 7, 2016
1 parent 56a0af5 commit febcabb0da8dd5f47b07a466ecfef3cfc28022fe
@@ -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
*/
@@ -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,21 +414,21 @@ 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 );
node->removeRows( 0, node->rowCount() );
}

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 )
@@ -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
*/

0 comments on commit febcabb

Please sign in to comment.
You can’t perform that action at this time.