mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-15 00:02:52 -04:00
Make using recent expressions API simpler and add doxygen comment
This commit is contained in:
parent
56a0af5bd8
commit
febcabb0da
@ -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,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 )
|
||||
|
@ -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
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user