2019-11-05 21:18:20 +00:00
|
|
|
from model.entry import Entry
|
2019-11-11 22:04:45 +00:00
|
|
|
from browser import window
|
2019-11-05 21:18:20 +00:00
|
|
|
|
|
|
|
class Model:
|
|
|
|
def __init__(self, names):
|
2019-11-11 22:04:45 +00:00
|
|
|
# main data stuff
|
2019-11-05 21:18:20 +00:00
|
|
|
self.entry = None
|
2019-11-11 22:04:45 +00:00
|
|
|
|
|
|
|
# report everything that happens!
|
2019-11-05 21:18:20 +00:00
|
|
|
self.log = []
|
2019-11-11 22:04:45 +00:00
|
|
|
|
|
|
|
#runtime info
|
|
|
|
self.menu_location = (0, 0)
|
2019-11-20 22:24:16 +00:00
|
|
|
self.menu_target = None
|
2019-11-11 23:34:52 +00:00
|
|
|
|
|
|
|
# modal handling
|
|
|
|
self.modal = lambda: []
|
2019-11-11 22:04:45 +00:00
|
|
|
self.modal_shown = False
|
|
|
|
|
|
|
|
# currently edited stuff
|
|
|
|
self.translation = None
|
|
|
|
self.sense = None
|
2019-11-11 23:34:52 +00:00
|
|
|
|
2020-01-02 12:15:04 +00:00
|
|
|
# choosing examples
|
|
|
|
self.chosen_examples = []
|
|
|
|
|
2019-11-11 23:34:52 +00:00
|
|
|
self.reset()
|
|
|
|
self.modal_reset()
|
2019-11-05 21:18:20 +00:00
|
|
|
|
2019-11-11 22:04:45 +00:00
|
|
|
def reset(self):
|
2020-01-02 12:15:04 +00:00
|
|
|
# do both resets at once
|
|
|
|
self.pre_reset()
|
|
|
|
self.post_reset()
|
|
|
|
|
|
|
|
def pre_reset(self):
|
|
|
|
# the reset before updating models
|
2019-11-20 22:24:16 +00:00
|
|
|
self.menu_target = None
|
2020-01-05 22:58:07 +00:00
|
|
|
self.modal_reset()
|
2019-11-11 23:34:52 +00:00
|
|
|
|
2020-01-02 12:15:04 +00:00
|
|
|
def post_reset(self):
|
|
|
|
# the reset after updating the models
|
|
|
|
self.chosen_examples = []
|
|
|
|
|
2019-11-11 23:34:52 +00:00
|
|
|
def modal_reset(self):
|
|
|
|
self.modal = lambda: []
|
2020-01-05 22:58:07 +00:00
|
|
|
self.modal_shown = False
|
|
|
|
|
|
|
|
def modal_set(self, modal):
|
|
|
|
self.modal = modal
|
|
|
|
self.modal_shown = True
|
2019-11-11 23:34:52 +00:00
|
|
|
|
2019-11-05 21:18:20 +00:00
|
|
|
|
|
|
|
def import_xml(self, xml_text):
|
|
|
|
parser = __new__(DOMParser())
|
|
|
|
xmlDoc = parser.parseFromString(xml_text, "text/xml")
|
|
|
|
self.entry = Entry(xmlDoc.querySelector("entry"))
|
2019-11-11 22:04:45 +00:00
|
|
|
|