Skip to content

Commit

Permalink
Change indentation; Sipified; Fix class modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
suricactus committed Mar 14, 2020
1 parent dd9f397 commit bc23d86
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 34 deletions.
18 changes: 18 additions & 0 deletions python/gui/auto_generated/qgsexpressionbuilderwidget.sip.in
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion python/gui/auto_generated/qgsexpressionstoredialog.sip.in
Expand Up @@ -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``.
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsexpressionbuilderwidget.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
56 changes: 27 additions & 29 deletions src/gui/qgsexpressionbuilderwidget.h
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bc23d86

Please sign in to comment.