Change indentation; Sipified; Fix class modifiers

This commit is contained in:
Ivan Ivanov 2020-03-12 12:15:32 +02:00
parent dd9f397573
commit bc23d86253
4 changed files with 50 additions and 34 deletions

View File

@ -386,6 +386,24 @@ the selected expression must be a user stored expression.
Edits the selected expression from the stored user expressions,
the selected expression must be a user stored expression.
.. versionadded:: 3.14
%End
QJsonDocument exportUserExpressions();
%Docstring
Create the expressions JSON document storing all the user expressions to be exported.
:return: the created expressions JSON file
.. versionadded:: 3.14
%End
void loadExpressionsFromJson( const QJsonDocument &expressionsDocument );
%Docstring
Load and permanently store the expressions from the expressions JSON document.
:param expressionsDocument: the parsed expressions JSON file
.. versionadded:: 3.14
%End

View File

@ -26,7 +26,7 @@ A generic dialog for editing expression text, label and help text.
QgsExpressionStoreDialog( const QString &label,
const QString &expression,
const QString &helpText,
const QStringList &existingLabels,
const QStringList &existingLabels = QStringList(),
QWidget *parent = 0 );
%Docstring
Creates a QgsExpressionStoreDialog with given ``label``, ``expression`` and ``helpText``.

View File

@ -1432,20 +1432,20 @@ void QgsExpressionBuilderWidget::exportUserExpressions_pressed()
settings.setValue( QStringLiteral( "lastExportExpressionsDir" ), saveFileInfo.absolutePath(), QgsSettings::App );
std::unique_ptr< QJsonDocument > exportJson = exportUserExpressions();
QJsonDocument exportJson = exportUserExpressions();
QFile jsonFile( saveFileName );
if ( !jsonFile.open( QFile::WriteOnly | QIODevice::Truncate ) )
QMessageBox::warning( this, tr( "Export user expressions" ), tr( "Error while creating the expressions file." ) );
if ( ! jsonFile.write( exportJson->toJson() ) )
if ( ! jsonFile.write( exportJson.toJson() ) )
QMessageBox::warning( this, tr( "Export user expressions" ), tr( "Error while creating the expressions file." ) );
else
jsonFile.close();
}
std::unique_ptr< QJsonDocument > QgsExpressionBuilderWidget::exportUserExpressions()
QJsonDocument QgsExpressionBuilderWidget::exportUserExpressions()
{
const QString group = QStringLiteral( "user" );
QgsSettings settings;
@ -1482,7 +1482,7 @@ std::unique_ptr< QJsonDocument > QgsExpressionBuilderWidget::exportUserExpressio
}
exportObject["expressions"] = exportList;
std::unique_ptr< QJsonDocument > exportJson = qgis::make_unique< QJsonDocument >( exportObject );
QJsonDocument exportJson = QJsonDocument( exportObject );
return exportJson;
}

View File

@ -387,26 +387,12 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp
*/
void editSelectedUserExpression();
/**
* Display a file dialog to choose where to store the exported expressions JSON file
* and saves them to the selected destination.
* \since QGIS 3.14
*/
void exportUserExpressions_pressed();
/**
* Create the expressions JSON document storing all the user expressions to be exported.
* \returns the created expressions JSON file
* \since QGIS 3.14
*/
std::unique_ptr< QJsonDocument > exportUserExpressions();
/**
* Display a file dialog to choose where to load the expression JSON file from
* and adds them to user expressions group.
* \since QGIS 3.14
*/
void importUserExpressions_pressed();
QJsonDocument exportUserExpressions();
/**
* Load and permanently store the expressions from the expressions JSON document.
@ -415,20 +401,6 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp
*/
void loadExpressionsFromJson( const QJsonDocument &expressionsDocument );
/**
* Display a message box to ask the user what to do when an expression
* with the same \a label already exists. Answering "Yes" will replace
* the old expression with the one from the file, while "No" will keep
* the old expression.
* \since QGIS 3.14
* \param isApplyToAll whether the decision of the user should be applied to any future label collision
* \param isOkToOverwrite whether to overwrite the old expression with the new one in case of label collision
* \param label the label of the expression
* \param oldExpression the old expression for a given label
* \param newExpression the new expression for a given label
*/
void showMessageBoxConfirmExpressionOverwrite( bool &isApplyToAll, bool &isOkToOverwrite, const QString &label, const QString &oldExpression, const QString &newExpression );
/**
* Returns the list of expression items matching a \a label.
* \since QGIS 3.12
@ -444,6 +416,18 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp
void operatorButtonClicked();
void btnRun_pressed();
void btnNewFile_pressed();
/**
* Display a file dialog to choose where to store the exported expressions JSON file
* and saves them to the selected destination.
* \since QGIS 3.14
*/
void exportUserExpressions_pressed();
/**
* Display a file dialog to choose where to load the expression JSON file from
* and adds them to user expressions group.
* \since QGIS 3.14
*/
void importUserExpressions_pressed();
void cmbFileNames_currentItemChanged( QListWidgetItem *item, QListWidgetItem *lastitem );
void expressionTree_doubleClicked( const QModelIndex &index );
void txtExpressionString_textChanged();
@ -565,6 +549,20 @@ class GUI_EXPORT QgsExpressionBuilderWidget : public QWidget, private Ui::QgsExp
void loadFieldsAndValues( const QMap<QString, QVariantMap> &fieldValues );
/**
* Display a message box to ask the user what to do when an expression
* with the same \a label already exists. Answering "Yes" will replace
* the old expression with the one from the file, while "No" will keep
* the old expression.
* \param isApplyToAll whether the decision of the user should be applied to any future label collision
* \param isOkToOverwrite whether to overwrite the old expression with the new one in case of label collision
* \param label the label of the expression
* \param oldExpression the old expression for a given label
* \param newExpression the new expression for a given label
* \since QGIS 3.14
*/
void showMessageBoxConfirmExpressionOverwrite( bool &isApplyToAll, bool &isOkToOverwrite, const QString &label, const QString &oldExpression, const QString &newExpression );
bool mAutoSave = true;
QString mFunctionsPath;
QgsVectorLayer *mLayer = nullptr;