2019-11-05 21:18:20 +00:00
|
|
|
from model.entry import Entry
|
2020-01-24 00:49:33 +00:00
|
|
|
from model.example import Example
|
2019-11-11 22:04:45 +00:00
|
|
|
from browser import window
|
2020-02-02 21:04:02 +00:00
|
|
|
from model.example_clusters import ExampleClusters
|
|
|
|
|
2019-11-05 21:18:20 +00:00
|
|
|
|
|
|
|
class Model:
|
2020-01-24 00:47:27 +00:00
|
|
|
def __init__(self):
|
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-25 22:22:23 +00:00
|
|
|
# choosing and hiding examples
|
2020-01-02 12:15:04 +00:00
|
|
|
self.chosen_examples = []
|
2020-01-25 22:22:23 +00:00
|
|
|
self.examples_shown = True
|
2020-02-03 05:11:26 +00:00
|
|
|
|
|
|
|
# hiding cluster numbers
|
|
|
|
self.clusters_shown = True
|
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
|
|
|
|
2020-02-02 21:04:02 +00:00
|
|
|
def pre_view(self):
|
|
|
|
# this should go into "after data change" or something
|
|
|
|
ExampleClusters.rebuild_lists(self)
|
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"))
|
2020-01-28 22:05:48 +00:00
|
|
|
self.reset()
|
2020-01-24 00:49:33 +00:00
|
|
|
|