Merge branch 'master' of https://vcs.maemo.org/git/qwerkisync
[qwerkisync] / DBBackends / RtcomEventLoggerComponents / TriggerDisabler.h
1 /*
2  * Copyright (C) 2011, Jamie Thompson
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public
6  * License as published by the Free Software Foundation; either
7  * version 3 of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public
15  * License along with this program; If not, see
16  * <http://www.gnu.org/licenses/>.
17  */
18
19 #ifndef DBBACKENDS_RTCOMEVENTLOGGERCOMPONENTS_TRIGGERDISABLER_H
20 #define DBBACKENDS_RTCOMEVENTLOGGERCOMPONENTS_TRIGGERDISABLER_H
21
22 class Settings;
23
24 #include <QHash>
25 class QSqlDatabase;
26 #include <QString>
27
28 namespace DBBackends
29 {
30         namespace RtcomEventLoggerComponents
31         {
32                 class TriggerDisabler
33                 {
34                 public:
35                         TriggerDisabler(const Settings &settings);
36                         ~TriggerDisabler();
37
38                         void Reenable();
39
40                 protected:
41                         const Settings &CurrentSettings() const { return m_Settings; }
42
43                         const QHash<QString, QString> &Triggers() const { return m_Triggers; }
44
45                         const bool Reenabled() const { return m_Reenabled; }
46
47                         void RestoreTriggers(QSqlDatabase &db);
48                         void UpdateGroupCache(QSqlDatabase &db);
49
50                 private:
51                         const Settings &m_Settings;
52
53                         QHash<QString, QString> &Triggers() { return m_Triggers; }
54                         QHash<QString, QString> m_Triggers;
55
56                         void Reenabled(bool reenabled) { m_Reenabled = reenabled; }
57                         bool m_Reenabled;
58                 };
59         }
60 }
61
62 #endif // DBBACKENDS_RTCOMEVENTLOGGERCOMPONENTS_TRIGGERDISABLER_H