Fixed vessel change code in native gui
This commit is contained in:
1 parent
09387280fc
commit
db74fb6970
16 files changed
+192
-33
No files matched your search
+33
-7
@@ -29,8 +29,8 @@ class CablesView(View):
|
||||
self.dd_type = self.context.lookup.dropdown(Dropdown.CABLE_TYPE)
|
||||
combobox.load_from_dict(self.combo['type'], {-1: _("─── none ───")} | self.dd_type)
|
||||
# Cable tech type
|
||||
self.dd_tech = self.context.lookup.dropdown(Dropdown.CABLE_TECHNAME)
|
||||
combobox.load_from_dict(self.combo['techname'], {-1: _("─── none ───")} | self.dd_tech)
|
||||
self.dd_techname = self.context.lookup.dropdown(Dropdown.CABLE_TECHNAME)
|
||||
combobox.load_from_dict(self.combo['techname'], {-1: _("─── none ───")} | self.dd_techname)
|
||||
# Supplier
|
||||
self.dd_supplier = self.context.lookup.company(1)
|
||||
combobox.load_from_dict(self.combo['supplier'], {-1: _("─── none ───")} | self.dd_supplier)
|
||||
@@ -42,8 +42,10 @@ class CablesView(View):
|
||||
combobox.load_from_dict(self.combo['condition'], self.dd_condition, 'unknown')
|
||||
|
||||
# subscribe to data change events
|
||||
#self.context.subscribe("dd_type_modified", self.type_modified)
|
||||
#self.context.subscribe("dd_techname_modified", self.techname_modified)
|
||||
self.context.subscribe("dd_cabletype_modified", self.type_modified)
|
||||
self.context.subscribe("dd_techname_modified", self.techname_modified)
|
||||
self.context.subscribe("company_modified", self.company_modified)
|
||||
self.context.subscribe("vessel_modified", self.vessel_modified)
|
||||
|
||||
def get_list_row(self):
|
||||
return (
|
||||
@@ -111,6 +113,30 @@ class CablesView(View):
|
||||
# not implemented
|
||||
pass
|
||||
|
||||
def company_modified(self, eventtype, data):
|
||||
if data[1] == 1:
|
||||
# supplier
|
||||
self.dd_supplier[data[0]] = data[2]
|
||||
lst = self.combo['supplier'].get_model()
|
||||
elif data[1] == 2:
|
||||
# manufacturer
|
||||
self.dd_manufacturer[data[0]] = data[2]
|
||||
lst = self.combo['manufacturer'].get_model()
|
||||
else:
|
||||
# all other
|
||||
return
|
||||
if eventtype == self.context.EVENT_UPD:
|
||||
for row in lst:
|
||||
if row[0] == data[0]:
|
||||
row[1] = data[2]
|
||||
elif eventtype == self.context.EVENT_ADD:
|
||||
lst.append((data[0], data[2]))
|
||||
|
||||
def vessel_modified(self, eventtype, data):
|
||||
self.tree['cables'].get_selection().unselect_all()
|
||||
self.load_list()
|
||||
self.topwidget.set_visible_child(self.box['cables'])
|
||||
|
||||
def display_record(self):
|
||||
self.label['name'].set_text(self.cable.cablename or '')
|
||||
if self.cable.cabletype:
|
||||
@@ -118,7 +144,7 @@ class CablesView(View):
|
||||
else:
|
||||
self.label['type'].set_text('')
|
||||
if self.cable.techname:
|
||||
self.label['techname'].set_text(self.dd_tech[self.cable.techname])
|
||||
self.label['techname'].set_text(self.dd_techname[self.cable.techname])
|
||||
else:
|
||||
self.label['techname'].set_text('')
|
||||
self.label['length'].set_text(self.format_float(self.cable.length, suffix="m"))
|
||||
@@ -130,8 +156,8 @@ class CablesView(View):
|
||||
self.label['color'].set_markup(f'#{self.cable.color} <span foreground="#{self.cable.color}">●</span>')
|
||||
else:
|
||||
self.label['color'].set_text('')
|
||||
self.label['supplier'].set_text(str(self.cable.supplier))
|
||||
self.label['manufacturer'].set_text(str(self.cable.manufacturer))
|
||||
self.label['supplier'].set_text(self.dd_supplier.get(self.cable.supplier, '-'))
|
||||
self.label['manufacturer'].set_text(self.dd_manufacturer.get(self.cable.manufacturer, '-'))
|
||||
self.label['condition'].set_text(self.cable.cablecond)
|
||||
self.label['remarks'].set_text(self.cable.remarks or '')
|
||||
|
||||
|
||||
Reference in new issue
Block a user