[app] Added BooksSaveTimer::saveNow() method

This commit is contained in:
Slava Monich 2015-11-30 23:18:53 +02:00
parent a89e489f7a
commit 9f1261a822
2 changed files with 10 additions and 4 deletions

View file

@ -70,6 +70,13 @@ void BooksSaveTimer::cancelSave()
iInactivityTimer->stop(); iInactivityTimer->stop();
} }
void BooksSaveTimer::saveNow()
{
iMandatarySaveTimer->stop();
iInactivityTimer->stop();
Q_EMIT save();
}
bool BooksSaveTimer::saveRequested() const bool BooksSaveTimer::saveRequested() const
{ {
return iMandatarySaveTimer->isActive(); return iMandatarySaveTimer->isActive();
@ -77,14 +84,12 @@ bool BooksSaveTimer::saveRequested() const
void BooksSaveTimer::onTimeout() void BooksSaveTimer::onTimeout()
{ {
iMandatarySaveTimer->stop(); saveNow();
iInactivityTimer->stop();
Q_EMIT save();
} }
void BooksSaveTimer::onAboutToQuit() void BooksSaveTimer::onAboutToQuit()
{ {
if (saveRequested()) { if (saveRequested()) {
onTimeout(); saveNow();
} }
} }

View file

@ -48,6 +48,7 @@ public:
void requestSave(); void requestSave();
void cancelSave(); void cancelSave();
bool saveRequested() const; bool saveRequested() const;
void saveNow();
Q_SIGNALS: Q_SIGNALS:
void save(); void save();