Commit 8b8868ff authored by Karel Slaný's avatar Karel Slaný

There is no hidden access to globAccountsModelPtr in C++ code.

parent ca686d89
......@@ -95,7 +95,7 @@ Component {
statusBarText.text = ""
if (isds.syncAllAccounts(accountListModel)) {
settings.setLastUpdateToNow()
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
}
}
}
......@@ -245,7 +245,7 @@ Component {
onClicked: {
if (isds.syncOneAccount(accountListModel, rUserName)) {
settings.setLastUpdateToNow()
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
}
}
}
......
......@@ -164,11 +164,11 @@ Component {
files.deleteFileDb(userName)
} else if (index == 3) {
if (isds.changePassword(userName, acntName)) {
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
}
} else if (index == 4) {
if (accounts.removeAccount(accountListModel, userName, true)) {
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
pageView.pop(StackView.Immediate)
}
} else {
......
......@@ -205,7 +205,7 @@ Component {
if (msgType == MessageType.TYPE_RECEIVED) {
if (isds.syncSingleAccountReceived(accountListModel, messageModel, userName)) {
settings.setLastUpdateToNow()
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
}
} else if (msgType == MessageType.TYPE_SENT) {
isds.syncSingleAccountSent(accountListModel, messageModel, userName)
......
......@@ -319,11 +319,11 @@ Component {
testAccount.checked, rememberPassword.checked,
useLS.checked, certPathLabelId.text.toString())) {
if (isds.getAccountInfo(userNameTextField.text.toString(), true)) {
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
pageView.pop(StackView.Immediate)
} else {
if (accounts.removeAccount(accountListModel, userNameTextField.text.toString(), false)) {
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
}
}
}
......@@ -334,7 +334,7 @@ Component {
passwordTextField.text.toString(),
testAccount.checked, rememberPassword.checked,
useLS.checked, certPathLabelId.text.toString())) {
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
}
pageView.pop(StackView.Immediate)
}
......
......@@ -171,7 +171,7 @@ Component {
onSaveSettingsGeneralResponse: {
settings.updateSettingsGeneral(sLang,
fontSizeSpinBox.val().toString())
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
pageView.pop(StackView.Immediate)
}
}
......
......@@ -176,7 +176,7 @@ Component {
} else {
errLineText.visible = false
settings.updatePinSettings(pinConfirmField1.text.toString())
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
pageView.pop(StackView.Immediate)
}
/* change current pin code */
......@@ -198,7 +198,7 @@ Component {
} else {
errLineText.visible = false
settings.updatePinSettings(pinConfirmField1.text.toString())
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
pageView.pop(StackView.Immediate)
}
} else {
......@@ -212,7 +212,7 @@ Component {
if (pinValueField.text == currentPIN) {
errLineText.visible = false
settings.updatePinSettings("")
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
settings.setInactivityInterval(0)
locker.setInactivityInterval(0)
pageView.pop(StackView.Immediate)
......
......@@ -231,7 +231,7 @@ Component {
messageLifeSpinBox.val().toString(),
attachLifeSpinBox.val().toString(),
dbPathText.text.toString())
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
pageView.pop(StackView.Immediate)
}
}
......
......@@ -127,7 +127,7 @@ Component {
settings.updateSettingsSync(
idownloadOnlyNewMsgs.checked,
idownloadCompleteMsgs.checked)
settings.saveAllSettings()
settings.saveAllSettings(accountListModel)
pageView.pop(StackView.Immediate)
}
}
......
......@@ -418,7 +418,7 @@ int main(int argc, char *argv[])
* The PIN was set/recovered or
* incomplete data to check/recover the PIN were supplied.
*/
GlobalSettingsQmlWrapper::saveAllSettings();
GlobalSettingsQmlWrapper::saveAllSettings(globAccountsModelPtr);
}
delete globAccountsModelPtr;
......
......@@ -28,7 +28,6 @@
#include "src/common.h"
#include "src/io/filesystem.h"
#include "src/models/accountmodel.h" /* globAccountsModelPtr */
#include "src/settings.h"
Settings globSet;
......
......@@ -291,11 +291,18 @@ void GlobalSettingsQmlWrapper::setLastUpdateToNow(void)
globSet.setLastUpdate(Settings::nowStr());
}
void GlobalSettingsQmlWrapper::saveAllSettings(void)
void GlobalSettingsQmlWrapper::saveAllSettings(
const AccountListModel *accountModel)
{
if (accountModel == Q_NULLPTR) {
Q_ASSERT(0);
qCritical("%s", "Missing account model to read settings from.");
return;
}
QSettings settings(Settings::settingsPath(), QSettings::IniFormat);
settings.clear();
globSet.saveToSettings(settings);
globAccountsModelPtr->saveAccountsToSettings(globSet._pinVal, settings);
accountModel->saveAccountsToSettings(globSet._pinVal, settings);
settings.sync();
}
......@@ -27,6 +27,8 @@
#include <QObject>
#include <QString>
class AccountListModel; /* Forward declaration. */
/*
* This class provide wrapper between
* global settings class and QML settings page.
......@@ -162,9 +164,11 @@ public:
/*!
* @brief Gathers all settings and stores them into configuration file.
*
* @param[in] accountModel Account model to take data from.
*/
Q_INVOKABLE static
void saveAllSettings(void);
void saveAllSettings(const AccountListModel *accountModel);
signals:
/*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment