-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqml_wrapper.py
104 lines (83 loc) · 2.31 KB
/
qml_wrapper.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# -*- coding:utf8 -*-
from PyQt5.QtCore import *
from datetime import datetime as dt
class TaskWrapper(QObject):
def __init__(self, task, parent=None):
"""
Wrapping task from sql row. Wrapped task is shown on QML list (QQuickView()).
:param task: dict
:param parent: object
"""
super(TaskWrapper, self).__init__(parent)
self._task = task
self._message = ''
self._id = None
self._date = None
self._priority = ''
self._datetime = None
self._hour_minute = None
self._cyclic = None
self._action = None
self._done = None
self._expired = False
@pyqtProperty(str)
def message(self):
return self._task['message']
@message.setter
def message(self, message):
self._message = message
@pyqtProperty(int)
def id(self):
return self._task['id']
@id.setter
def id(self, id):
self._id = id
@pyqtProperty(str)
def date(self):
return self._task['date']
@date.setter
def date(self, date):
self._date = date
@pyqtProperty(str)
def priority(self):
return self._task['priority']
@priority.setter
def priority(self, priority):
self._priority = priority
@pyqtProperty(str)
def datetime(self):
return str(self._task['datetime'])
@datetime.setter
def datetime(self, datetime):
self._datetime = datetime
@pyqtProperty(str)
def hour_minute(self):
return str(self._task['datetime'].strftime("%H:%M"))
@hour_minute.setter
def hour_minute(self, hour_minute):
self._hour_minute = hour_minute
@pyqtProperty(bool)
def cyclic(self):
return self._task['cyclic']
@cyclic.setter
def cyclic(self, cyclic):
self._cyclic = cyclic
@pyqtProperty(int)
def action(self):
return self._task['action']
@action.setter
def action(self, action):
self._action = action
@pyqtProperty(bool)
def done(self):
return self._task['done']
@done.setter
def done(self, done):
self._done = done
@pyqtProperty(bool)
def expired(self):
now = dt.now()
if self._task['datetime'] < now:
return True
else:
return False