-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstates.py
59 lines (44 loc) · 1.06 KB
/
states.py
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
from dataclasses import dataclass
from PySide6.QtGui import QColor
class StateNotifier():
""""""
def __init__(self):
self._states = {}
self._observers = []
def add_state(self, state):
""""""
self._states[state.id] = state
def remove_state(self, id):
""""""
return self._states.pop(id)
def get_states(self):
""""""
return self._states.values()
def get_state(self, id):
""""""
return self._states.get(id, None)
def add_observer(self, func):
""""""
self._observers.append(func)
def notify_all(self, concrete=[]):
""""""
for func in self._observers:
func(*self._states.values(), concrete=concrete)
@dataclass
class BlockStore:
id: str
name: str
done: bool
values: list
times: list
def __hash__(self):
return hash(self.id)
@dataclass
class ElementStore:
id: str
values: list
times: list
color: QColor
show: bool
def __hash__(self):
return hash(self.id)