Debian Codegraph @

Source/Config/CBooleanConfigType.cpp

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "CBooleanConfigType.h"
22
23
24 namespace Konclude {
25
26 namespace Config {
27
28 CBooleanConfigType::CBooleanConfigType(bool value) {
29 boolValue = value;
30 }
31
32
33 CBooleanConfigType::~CBooleanConfigType() {
34 }
35
36
37 CBooleanConfigType *CBooleanConfigType::getTypeCopy() {
38 return new CBooleanConfigType(boolValue);
39 }
40
41 bool CBooleanConfigType::supportsVariant() {
42 return true;
43 }
44
45 CBooleanConfigType *CBooleanConfigType::readFrom(const QVariant &var) {
46 boolValue = var.toBool();
47 return this;
48 }
49
50 QVariant CBooleanConfigType::getVariant() {
51 return QVariant(boolValue);
52 }
53
54 CBooleanConfigType *CBooleanConfigType::setValue(bool value) {
55 boolValue = value;
56 return this;
57 }
58
59 bool CBooleanConfigType::getValue() {
60 return boolValue;
61 }
62
63 bool CBooleanConfigType::equals(CConfigType *dataType) {
64 CBooleanConfigType *boolType = dynamic_cast<CBooleanConfigType *>(dataType);
65 if (boolType) {
66 return (boolValue == boolType->boolValue);
67 }
68 return false;
69 }
70
71 bool CBooleanConfigType::readFromString(const QString &string) {
72 bool ok = true;
73 qint64 tmp = string.toInt(&ok);
74 if (ok) {
75 boolValue = tmp;
76 } else {
77 if (string.toUpper() == "TRUE") {
78 boolValue = true;
79 ok = true;
80 }
81 if (string.toUpper() == "FALSE") {
82 boolValue = false;
83 ok = true;
84 }
85 }
86 return ok;
87 }
88
89 QString CBooleanConfigType::getString() {
90 if (boolValue) {
91 return QString("TRUE");
92 } else {
93 return QString("FALSE");
94 }
95 }
96
97 bool CBooleanConfigType::readFromInteger(qint64 integer) {
98 boolValue = integer;
99 return true;
100 }
101
102 qint64 CBooleanConfigType::getInteger() {
103 return boolValue;
104 }
105
106 bool CBooleanConfigType::readFromBoolean(bool boolean) {
107 boolValue = boolean;
108 return true;
109 }
110
111 bool CBooleanConfigType::getBoolean() {
112 return boolValue;
113 }
114
115
116 }; // end namespace Config
117
118 }; // end namespace Konclude