Commit 814f9df2 authored by Karel Slaný's avatar Karel Slaný

Moved setLastUpdateToNow() to GlobalSettingsQmlWrapper.

parent a55ccb8f
......@@ -92,8 +92,11 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
statusBarText.text = ""
isds.syncAllAccounts(accountListModel)
statusBarText.text = ""
if (isds.syncAllAccounts(accountListModel)) {
settings.setLastUpdateToNow()
settings.saveAllSettings()
}
}
}
}
......@@ -240,7 +243,10 @@ Component {
MouseArea {
anchors.fill: parent
onClicked: {
isds.syncOneAccount(accountListModel, rUserName)
if (isds.syncOneAccount(accountListModel, rUserName)) {
settings.setLastUpdateToNow()
settings.saveAllSettings()
}
}
}
}
......
......@@ -203,7 +203,10 @@ Component {
if (downloadStart) {
downloadStart = false
if (msgType == MessageType.TYPE_RECEIVED) {
isds.syncSingleAccountReceived(accountListModel, messageModel, userName)
if (isds.syncSingleAccountReceived(accountListModel, messageModel, userName)) {
settings.setLastUpdateToNow()
settings.saveAllSettings()
}
} else if (msgType == MessageType.TYPE_SENT) {
isds.syncSingleAccountSent(accountListModel, messageModel, userName)
}
......
......@@ -39,25 +39,34 @@ IsdsWrapper::~IsdsWrapper(void)
{
}
void IsdsWrapper::syncAllAccounts(const QVariant &acntModelVariant)
bool IsdsWrapper::syncAllAccounts(const QVariant &acntModelVariant)
{
qDebug("%s()", __func__);
bool ret = false;
QList<QString> userNameList = AccountListModel::globAccounts.keys();
foreach (const QString userName, userNameList) {
syncOneAccount(acntModelVariant, userName);
if (syncOneAccount(acntModelVariant, userName)) {
ret = true;
}
}
return ret;
}
void IsdsWrapper::syncOneAccount(const QVariant &acntModelVariant,
bool IsdsWrapper::syncOneAccount(const QVariant &acntModelVariant,
const QString &userName)
{
qDebug("%s()", __func__);
if (syncSingleAccountSent(acntModelVariant, QVariant(), userName)) {
/* Download received only when sent successfully downloaded. */
syncSingleAccountReceived(acntModelVariant, QVariant(), userName);
return syncSingleAccountReceived(acntModelVariant, QVariant(),
userName);
}
return false;
}
bool IsdsWrapper::syncSingleAccountReceived(const QVariant &acntModelVariant,
......@@ -94,9 +103,6 @@ bool IsdsWrapper::syncSingleAccountReceived(const QVariant &acntModelVariant,
false, true);
}
globSet.setLastUpdateToNow();
GlobalSettingsQmlWrapper::saveAllSettings();
if (globSet.downloadCompleteMsgs) {
MessageListModel *messageModel =
MessageListModel::fromVariant(msgModelVariant);
......@@ -162,8 +168,6 @@ bool IsdsWrapper::syncSingleAccountSent(const QVariant &acntModelVariant,
false, true);
}
/* Don't store last update time when downloading sent messages. */
if (globSet.downloadCompleteMsgs) {
MessageListModel *messageModel =
MessageListModel::fromVariant(msgModelVariant);
......
......@@ -47,9 +47,11 @@ public:
*
* @param[in,out] acntModelVariant QVariant holding account model
* to be altered.
* @return True if at least one account has been successfully
* synchronised.
*/
Q_INVOKABLE
void syncAllAccounts(const QVariant &acntModelVariant);
bool syncAllAccounts(const QVariant &acntModelVariant);
/*!
* @brief Download message list of one account.
......@@ -57,9 +59,10 @@ public:
* @param[in,out] acntModelVariant QVariant holding account model
* to be altered.
* @param[in] userName Account username string.
* @return True on success.
*/
Q_INVOKABLE
void syncOneAccount(const QVariant &acntModelVariant,
bool syncOneAccount(const QVariant &acntModelVariant,
const QString &userName);
/*!
......
......@@ -170,9 +170,9 @@ void Settings::setLastUpdate(const QString &str)
}
}
void Settings::setLastUpdateToNow(void)
QString Settings::nowStr(void)
{
m_lastUpdate = QDateTime::currentDateTime().toString(Qt::ISODate);
return QDateTime::currentDateTime().toString(Qt::ISODate);
}
QString Settings::lastUpdateStr(void) const
......
......@@ -95,9 +95,12 @@ public:
void setLastUpdate(const QString &str);
/*!
* @brief Set last update time to current time.
* @brief Return current time as a string.
*
* @return Current time as stored by this structure.
*/
void setLastUpdateToNow(void);
static
QString nowStr(void);
/*!
* @brief Returns last update time string.
......
......@@ -291,6 +291,11 @@ void GlobalSettingsQmlWrapper::setInactivityInterval(int secs)
globSet.pinInactTimeoutInSecs = (secs > 0) ? secs : 0;
}
void GlobalSettingsQmlWrapper::setLastUpdateToNow(void)
{
globSet.setLastUpdate(Settings::nowStr());
}
void GlobalSettingsQmlWrapper::saveAllSettings(void)
{
QSettings settings(Settings::settingsPath(), QSettings::IniFormat);
......
......@@ -154,6 +154,12 @@ public:
Q_INVOKABLE
void setInactivityInterval(int secs);
/*!
* @brief Set last update time to current time.
*/
Q_INVOKABLE static
void setLastUpdateToNow(void);
/*!
* @brief Gathers all settings and stores them into configuration file.
*/
......
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