-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathquickviewscreen.py
116 lines (99 loc) · 3.88 KB
/
quickviewscreen.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
105
106
107
108
109
110
111
112
113
114
115
116
from kivy.properties import ListProperty, NumericProperty, ObjectProperty, StringProperty
from listitems import QuickViewScreenItem
from kivy.utils import escape_markup
from kivy.lang import Builder
from weakref import proxy
from uiux import Screen_
class QuickViewScreen(Screen_):
_item = ObjectProperty(proxy(QuickViewScreenItem))
action_items = ListProperty([])
page = StringProperty('')
page_number = NumericProperty(None)
watchwords = ListProperty(['Go', 'Pickup', 'Start', 'Begin', 'Finish', 'Pay'])
def __init__(self, **kwargs):
self.register_event_type('on_full_list')
super(QuickViewScreen, self).__init__(**kwargs)
def on_pre_enter(self):
if self.page:
cursor = self.root_directory.cursor()
cursor.execute("""
SELECT ix, what, when_, why, how
FROM [notebook]
WHERE page=? AND ix<4
ORDER BY ix
""",
(self.page,))
self.action_items = cursor.fetchall()
def on_full_list(self, *args):
screen = self.manager.get_screen('List Screen')
screen.page, screen.page_number = self.page, self.page_number
kwargs = {'direction': 'left', 'duration': 0.2}
self.dispatch('on_screen_change', 'List Screen', kwargs)
def _args_converter(self, row_index, an_obj):
_dict = {'size_hint_y': 0.3}
_dict['ix'], _dict['text'], _dict['when'], _dict['why'], _dict['how'] = an_obj
what = self.format_title(_dict['text'])
if what:
_dict['text'] = what
_dict['markup'] = True
return _dict
def format_title(self, string):
for word in self.watchwords:
if string.startswith(word + ' '):
return '[b]' + word + '[/b]' + string[(len(word)):] #escape_markup(string[(len(word)):])
def on_delete(self, instance):
cursor = self.root_directory.cursor()
ix = instance.parent.ix
cursor.execute("""
DELETE FROM [notebook]
WHERE ix=? AND page=?;
""",
(ix, self.page))
self.polestar = lambda : None
self.dispatch('on_pre_enter')
def on_complete(self, instance):
cursor = self.root_directory.cursor()
ix = instance.parent.ix
cursor.execute("""
INSERT INTO [archive]
SELECT * FROM [notebook] WHERE ix=? AND page=?;
""",
(ix, self.page))
self.polestar = lambda : None
self.dispatch('on_pre_enter')
Builder.load_string("""
#:import NavBar uiux.NavBar
#:import QuickListView listviews
<QuickViewScreen>:
name: 'QuickView Screen'
NavBar:
id: navbar_id
text: root.page
size_hint: 1, 0.1127
font_size: root.width*0.1
pos_hint:{'top': 1, 'x': 0}
Button_:
text: '<D'
state_color: app.no_color
text_color: app.white
font_size: self.width*0.5
font_name: 'breezi_font-webfont.ttf'
size_hint: 0.18, 1
pos_hint: {'center_x': 0.08, 'center_y': 0.5}
on_press: root.dispatch('on_screen_change', 'Pages Screen', {'direction': 'right', 'duration': 0.2})
Button_:
text: 'd>'
state_color: app.no_color
text_color: app.white
font_size: self.width*0.5
font_name: 'breezi_font-webfont.ttf'
size_hint: 0.18, 1
pos_hint: {'center_x': 0.9, 'center_y': 0.5}
on_press: root.dispatch('on_full_list')
QuickListView:
data: root.action_items
args_converter: root._args_converter
list_item: root._item
size_hint: 1, 0.8873
top: navbar_id.y
""")