-
Notifications
You must be signed in to change notification settings - Fork 18
/
CBoolProperty.cpp
61 lines (42 loc) · 1.03 KB
/
CBoolProperty.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "CBoolProperty.h"
CBoolProperty::CBoolProperty(const QByteArray &id, const QString &name, bool value, bool defaultValue):
CBaseProperty(id, name),
m_value(value),
m_defaultValue(defaultValue)
{
setValue(value);
}
CBoolProperty::CBoolProperty(CBaseProperty *top, const QByteArray &id, const QString &name, bool value, bool defaultValue):
CBaseProperty(top, id, name),
m_value(value),
m_defaultValue(defaultValue)
{
setValue(value);
}
void CBoolProperty::setValue(bool value)
{
m_value = value;
CBaseProperty::setValue();
}
bool CBoolProperty::getValue() const
{
m_value = (checkState(1) == Qt::Checked);
return m_value;
}
QVariant CBoolProperty::getVariantValue() const
{
return getValue();
}
void CBoolProperty::displayValue()
{
setCheckState(1, m_value ? Qt::Checked : Qt::Unchecked);
}
bool CBoolProperty::onKeyPressed(QKeyEvent *event, QWidget *)
{
if (event->key() == Qt::Key_Return)
{
setValue(!m_value);
return true;
}
return false;
}