FlightGear
next
DialogStateController.cxx
Go to the documentation of this file.
1
// Copyright (C) 2020 James Turner <james@flightgear.org>
2
//
3
// This program is free software; you can redistribute it and/or
4
// modify it under the terms of the GNU General Public License as
5
// published by the Free Software Foundation; either version 2 of the
6
// License, or (at your option) any later version.
7
//
8
// This program is distributed in the hope that it will be useful, but
9
// WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
// General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with this program; if not, write to the Free Software
15
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
17
#include "config.h"
18
19
#include "
DialogStateController.hxx
"
20
21
#include <QDebug>
22
23
void
DialogStateController::add
(QString key, QJSValue cb)
24
{
25
bool
wasEmpty = m_changes.isEmpty();
26
if
(!cb.isCallable()) {
27
qWarning() <<
"tried to insert non-callable into state key:"
<< key;
28
return
;
29
}
30
31
m_changes.insert(key, cb);
32
33
if
(wasEmpty) {
34
emit
canApplyChanged
(
true
);
35
}
36
}
37
38
void
DialogStateController::apply
()
39
{
40
auto
it = m_changes.begin();
41
for
(; it != m_changes.end(); ++it) {
42
QJSValueList args;
43
args.append(QJSValue(it.key()));
44
it.value().call(args);
45
}
46
}
47
48
void
DialogStateController::cancel
()
49
{
50
m_changes.clear();
51
emit
canApplyChanged
(
false
);
52
}
53
54
void
DialogStateController::restoreDefaults
()
55
{
56
}
57
58
void
DialogStateController::setCanRestoreDefaults
(
bool
canRestoreDefaults
)
59
{
60
if
(m_canRestoreDefaults ==
canRestoreDefaults
)
61
return
;
62
63
m_canRestoreDefaults =
canRestoreDefaults
;
64
emit
canRestoreDefaultsChanged
(m_canRestoreDefaults);
65
}
DialogStateController.hxx
DialogStateController::canApplyChanged
void canApplyChanged(bool canApply)
DialogStateController::cancel
void cancel()
Definition
DialogStateController.cxx:48
DialogStateController::setCanRestoreDefaults
void setCanRestoreDefaults(bool canRestoreDefaults)
Definition
DialogStateController.cxx:58
DialogStateController::canRestoreDefaults
bool canRestoreDefaults
Definition
DialogStateController.hxx:28
DialogStateController::apply
void apply()
Definition
DialogStateController.cxx:38
DialogStateController::restoreDefaults
void restoreDefaults()
Definition
DialogStateController.cxx:54
DialogStateController::add
Q_INVOKABLE void add(QString key, QJSValue cb)
Definition
DialogStateController.cxx:23
DialogStateController::canRestoreDefaultsChanged
void canRestoreDefaultsChanged(bool canRestoreDefaults)
src
GUI
DialogStateController.cxx
Generated on Tue Jun 3 2025 12:58:39 for FlightGear by
1.13.2