From 25314fd2aed81aa5281bc3d93dbcc7919368ebe1 Mon Sep 17 00:00:00 2001 From: Bicker Date: Wed, 22 May 2019 17:45:37 +0200 Subject: Initial commit --- ql/types/boolean.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 ql/types/boolean.py (limited to 'ql/types/boolean.py') diff --git a/ql/types/boolean.py b/ql/types/boolean.py new file mode 100644 index 0000000..f9dc76c --- /dev/null +++ b/ql/types/boolean.py @@ -0,0 +1,42 @@ +from gui.widgets.checkbox import CheckBox +from ql.ast.nodes.expressions.literals.boolean_literal import BooleanNode +from ql.types.type import QLType + + +class QLBoolean(QLType): + def __init__(self, value=False): + super(QLBoolean, self).__init__() + self.__value = bool(value) + + @property + def value(self): + return self.__value + + def __bool__(self): + return bool(self.value) + + def __str__(self): + return str(self.value) + + def __repr__(self): + return str(self.value) + + def __eq__(self, other): + if isinstance(other, QLBoolean): + return QLBoolean(self.value == other.value) + + return QLBoolean(False) + + def __ne__(self, other): + return QLBoolean(not self == other) + + def get_json_value(self): + return self.value + + @staticmethod + def get_literal_node(value): + return BooleanNode(None, QLBoolean, value) + + @staticmethod + def pyqt5_default_widget(): + return CheckBox() -- cgit v1.2.3