Native gui make almost every data editable

This commit is contained in:
thooge committed 2026-11-04 12:45:16 +01:00
1 parent b8ac8d0185
commit 1a6674c819
48 files changed
+2168 -737

No files matched your search

+1
View File
@@ -13,6 +13,7 @@ INSERT INTO vessel (vid, htype, vesselname, model, loa, lwl, beam, draught, disp
(1, 'mono', 'Generic vessel', 'Generic model', 10.0, 9.5, 3.0, 1.8, 4000, 1200, 'generic.svg'); (1, 'mono', 'Generic vessel', 'Generic model', 10.0, 9.5, 3.0, 1.8, 4000, 1200, 'generic.svg');
INSERT INTO settings (userid, sno, valint) VALUES INSERT INTO settings (userid, sno, valint) VALUES
(1, 1, 1), -- Vessel 1 for captain
(2, 1, 1), -- Vessel 1 for helmsman (2, 1, 1), -- Vessel 1 for helmsman
(3, 1, 1); -- Vessel 1 for sailor (3, 1, 1); -- Vessel 1 for sailor
+479 -458
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.
+1
View File
@@ -132,6 +132,7 @@ class Lookup:
'inventory.invcond': ('inventory', 'invcond'), 'inventory.invcond': ('inventory', 'invcond'),
'inventory.flags': ('inventory', 'flags'), 'inventory.flags': ('inventory', 'flags'),
'maintenance.maintstate': ('maintenance', 'maintstate'), 'maintenance.maintstate': ('maintenance', 'maintstate'),
'maintenance.plan_precision': ('maintenance', 'plan_precision'),
'measurement.accuracy': ('measurement', 'accuracy'), 'measurement.accuracy': ('measurement', 'accuracy'),
'note.notetype': ('note', 'notetype'), 'note.notetype': ('note', 'notetype'),
'project.projstate': ('project', 'projstate'), 'project.projstate': ('project', 'projstate'),
+7 -2
View File
@@ -15,6 +15,11 @@ class Box(DbRecord):
self.title = _("Box({})") self.title = _("Box({})")
def save(self, commit=True): def save(self, commit=True):
super().save(Table.BOXES) if not super().save(Table.BOXES):
return False
if commit: if commit:
self.conn.commit() try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+7 -2
View File
@@ -16,6 +16,11 @@ class Cable(DbRecord):
self.title = _("Cable({})") self.title = _("Cable({})")
def save(self, commit=True): def save(self, commit=True):
super().save(Table.CABLES) if not super().save(Table.CABLES):
return False
if commit: if commit:
self.conn.commit() try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+7 -2
View File
@@ -22,6 +22,11 @@ class Company(DbRecord):
self.title = _("Company({})") self.title = _("Company({})")
def save(self, commit=True): def save(self, commit=True):
super().save(Table.COMPANIES) if not super().save(Table.COMPANIES):
return False
if commit: if commit:
self.conn.commit() try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+10
View File
@@ -13,3 +13,13 @@ class Document(DbRecord):
def __init__(self, db, docid=None): def __init__(self, db, docid=None):
super().__init__(db, docid) super().__init__(db, docid)
self.title = _("Document({})") self.title = _("Document({})")
def save(self, commit=True):
if not super().save():
return False
if commit:
try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+7 -2
View File
@@ -16,6 +16,11 @@ class Equipment(DbRecord):
self.title = _("Equipment({})") self.title = _("Equipment({})")
def save(self, commit=True): def save(self, commit=True):
super().save(Table.EQUIPMENT) if not super().save(Table.EQUIPMENT):
return False
if commit: if commit:
self.conn.commit() try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+8 -3
View File
@@ -8,13 +8,18 @@ class Fuse(DbRecord):
table = "fuse" table = "fuse"
pk_field = "fuseid" pk_field = "fuseid"
fields = ('fuseid', 'vid', 'fnumber', 'ftype', 'current', 'cableid', fields = ('fuseid', 'vid', 'fnumber', 'ftype', 'current', 'cableid',
'eid', 'location', 'description', 'remarks') 'eid', 'location', 'description', 'color', 'remarks')
def __init__(self, db, fuseid=None): def __init__(self, db, fuseid=None):
super().__init__(db, fuseid) super().__init__(db, fuseid)
self.title = _("Fuse({})") self.title = _("Fuse({})")
def save(self, commit=True): def save(self, commit=True):
super().save(Table.FUSES) if not super().save(Table.FUSES):
return False
if commit: if commit:
self.conn.commit() try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+7 -2
View File
@@ -16,6 +16,11 @@ class Inventory(DbRecord):
self.title = _("Inventory({})") self.title = _("Inventory({})")
def save(self, commit=True): def save(self, commit=True):
super().save() if not super().save():
return False
if commit: if commit:
self.conn.commit() try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+12 -2
View File
@@ -7,9 +7,19 @@ class Maintenance(DbRecord):
table = "maintenance" table = "maintenance"
pk_field = "maintid" pk_field = "maintid"
fields = ('maintid', 'vid', 'eid', 'series', 'activities', 'plan_date', fields = ('maintid', 'vid', 'eid', 'series', 'activities', 'plan_date',
'completion_date', 'interval_hours', 'last_hours', 'remarks', 'plan_precision', 'completion_date', 'interval_hours', 'last_hours',
'maintstate') 'remarks', 'maintstate')
def __init__(self, db, maintid=None): def __init__(self, db, maintid=None):
super().__init__(db, maintid) super().__init__(db, maintid)
self.title = _("Maintenance({})") self.title = _("Maintenance({})")
def save(self, commit=True):
if not super().save():
return False
if commit:
try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+10
View File
@@ -12,3 +12,13 @@ class Measurement(DbRecord):
def __init__(self, db, mid=None): def __init__(self, db, mid=None):
super().__init__(db, mid) super().__init__(db, mid)
self.title = _("Measurement({})") self.title = _("Measurement({})")
def save(self, commit=True):
if not super().save():
return False
if commit:
try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+7 -2
View File
@@ -15,6 +15,11 @@ class Project(DbRecord):
self.title = _("Project({})") self.title = _("Project({})")
def save(self, commit=True): def save(self, commit=True):
super().save(Table.PROJECTS) if not super().save(Table.PROJECTS):
return False
if commit: if commit:
self.conn.commit() try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+7 -2
View File
@@ -15,6 +15,11 @@ class Provision(DbRecord):
self.title = _("Provision({})") self.title = _("Provision({})")
def save(self, commit=True): def save(self, commit=True):
super().save() if not super().save():
return False
if commit: if commit:
self.conn.commit() try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+7 -2
View File
@@ -20,9 +20,14 @@ class Storage(DbRecord):
self.title = _("Storage({})") self.title = _("Storage({})")
def save(self, commit=True): def save(self, commit=True):
super().save(Table.STORAGE) if not super().save(Table.STORAGE):
return False
if commit: if commit:
self.conn.commit() try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
def delete(self): def delete(self):
# there must be no associated data! # there must be no associated data!
+10
View File
@@ -12,3 +12,13 @@ class Task(DbRecord):
def __init__(self, db, taskid=None): def __init__(self, db, taskid=None):
super().__init__(db, taskid) super().__init__(db, taskid)
self.title = _("Task({})") self.title = _("Task({})")
def save(self, commit=True):
if not super().save():
return False
if commit:
try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
+7 -2
View File
@@ -44,9 +44,14 @@ class Vessel(DbRecord):
self.conn.commit() self.conn.commit()
def save(self, commit=True): def save(self, commit=True):
super().save() if not super().save():
return False
if commit: if commit:
self.conn.commit() try:
self.conn.commit()
except mariadb.Error as e:
return False
return True
def delete(self): def delete(self):
# there must be no assiciated data! # there must be no assiciated data!
+22
View File
@@ -43,3 +43,25 @@ def set_value(treeview, column, value):
return True return True
else: else:
return False return False
def set_row_values(treeview, data):
"""
Set every column in row to new value
"""
try:
selection = treeview.get_selection()
except:
return False
if not selection.get_mode() == Gtk.SelectionMode.SINGLE:
return False
(model, iter) = selection.get_selected()
# check if data count matches treeview columns
if len(data) != model.get_n_columns():
print("treeview:refresh_row column count mismatch")
return False
column = 0
for value in data:
# TODO data type checks?
model.set_value(iter, column, value)
column += 1
return True
+58 -1
View File
@@ -915,6 +915,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="receives-default">True</property> <property name="receives-default">True</property>
<property name="use-alpha">True</property>
<property name="show-editor">True</property> <property name="show-editor">True</property>
<signal name="color-set" handler="on_but_color_set" swapped="no"/> <signal name="color-set" handler="on_but_color_set" swapped="no"/>
</object> </object>
@@ -994,6 +995,62 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="revealed">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -1031,7 +1088,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+73 -2
View File
@@ -292,6 +292,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -476,6 +477,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -490,6 +492,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -504,6 +507,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -518,6 +522,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -532,6 +537,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -546,6 +552,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">False</property> <property name="hexpand">False</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -560,6 +567,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -574,6 +582,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -588,6 +597,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -602,6 +612,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -616,6 +627,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -631,6 +643,7 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property> <property name="yalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
@@ -1046,6 +1059,8 @@
<object class="GtkEntry" id="ent_color"> <object class="GtkEntry" id="ent_color">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<signal name="activate" handler="on_ent_color_activate" swapped="no"/>
<signal name="focus-out-event" handler="on_ent_color_focus_out_event" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
@@ -1059,7 +1074,8 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="receives-default">True</property> <property name="receives-default">True</property>
<property name="show-editor">True</property> <property name="use-alpha">True</property>
<signal name="color-set" handler="on_but_color_set" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -1080,6 +1096,61 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -1117,7 +1188,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+57 -1
View File
@@ -614,6 +614,62 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="revealed">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -652,7 +708,7 @@
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="pack-type">end</property> <property name="pack-type">end</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+57 -1
View File
@@ -919,6 +919,62 @@
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="revealed">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -987,7 +1043,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">3</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
</object> </object>
+56 -1
View File
@@ -1149,6 +1149,61 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -1187,7 +1242,7 @@
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="pack-type">end</property> <property name="pack-type">end</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+185 -26
View File
@@ -26,7 +26,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<child> <child>
<!-- n-columns=3 n-rows=3 --> <!-- n-columns=3 n-rows=4 -->
<object class="GtkGrid"> <object class="GtkGrid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
@@ -99,7 +99,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">2</property> <property name="top-attach">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -119,7 +119,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">2</property> <property name="top-attach">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -132,6 +132,30 @@
<property name="top-attach">1</property> <property name="top-attach">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Location</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmb_flt_location">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object> </object>
</child> </child>
<child type="label"> <child type="label">
@@ -252,7 +276,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<!-- n-columns=2 n-rows=8 --> <!-- n-columns=2 n-rows=9 -->
<object class="GtkGrid" id="grd_details"> <object class="GtkGrid" id="grd_details">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
@@ -264,6 +288,7 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -383,7 +408,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">7</property> <property name="top-attach">8</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -392,6 +417,7 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -407,6 +433,7 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -422,6 +449,7 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -438,6 +466,7 @@
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property> <property name="yalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
@@ -445,7 +474,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">7</property> <property name="top-attach">8</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -454,6 +483,7 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -469,6 +499,7 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -484,6 +515,7 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -493,6 +525,36 @@
<property name="top-attach">3</property> <property name="top-attach">3</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Color</property>
<style>
<class name="field-name"/>
</style>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_color">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
<style>
<class name="field-value"/>
</style>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
@@ -586,7 +648,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<!-- n-columns=2 n-rows=8 --> <!-- n-columns=2 n-rows=9 -->
<object class="GtkGrid" id="grd_editor"> <object class="GtkGrid" id="grd_editor">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
@@ -611,9 +673,6 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">Description</property> <property name="label" translatable="yes">Description</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
@@ -625,9 +684,6 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">Type</property> <property name="label" translatable="yes">Type</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
@@ -690,7 +746,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">7</property> <property name="top-attach">8</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -730,6 +786,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="adjustment">adj_current</property> <property name="adjustment">adj_current</property>
<property name="digits">1</property>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@@ -756,17 +813,6 @@
<property name="top-attach">5</property> <property name="top-attach">5</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkEntry" id="ent_location">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
</packing>
</child>
<child> <child>
<object class="GtkScrolledWindow"> <object class="GtkScrolledWindow">
<property name="visible">True</property> <property name="visible">True</property>
@@ -777,14 +823,72 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property>
</object> </object>
</child> </child>
</object> </object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Color</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkEntry" id="ent_color">
<property name="visible">True</property>
<property name="can-focus">True</property>
<signal name="activate" handler="on_ent_color_activate" swapped="no"/>
<signal name="focus-out-event" handler="on_ent_color_focus_out_event" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkColorButton" id="but_color">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="color-set" handler="on_but_color_set" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">7</property> <property name="top-attach">7</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkComboBox" id="cmb_location">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -792,6 +896,61 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -832,7 +991,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+56 -1
View File
@@ -1083,6 +1083,61 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -1120,7 +1175,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+73 -4
View File
@@ -715,6 +715,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">Remarks</property> <property name="label" translatable="yes">Remarks</property>
<property name="yalign">0</property>
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
@@ -722,7 +723,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkEntry" id="txt_activities"> <object class="GtkEntry" id="ent_activities">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
@@ -817,7 +818,8 @@
<object class="GtkEntry" id="ent_plandate"> <object class="GtkEntry" id="ent_plandate">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="hexpand">True</property> <property name="max-length">10</property>
<property name="width-chars">12</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -839,6 +841,17 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkComboBox" id="cmb_plan_precision">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@@ -853,7 +866,8 @@
<object class="GtkEntry" id="ent_completion"> <object class="GtkEntry" id="ent_completion">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="hexpand">True</property> <property name="max-length">10</property>
<property name="width-chars">12</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -887,6 +901,61 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -924,7 +993,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+59 -4
View File
@@ -709,7 +709,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="lbl_edit_val1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">Value 1</property> <property name="label" translatable="yes">Value 1</property>
@@ -720,7 +720,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="lbl_edit_val2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">Value 2</property> <property name="label" translatable="yes">Value 2</property>
@@ -731,7 +731,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel" id="lbl_edit_val3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="label" translatable="yes">Value 3</property> <property name="label" translatable="yes">Value 3</property>
@@ -802,6 +802,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<signal name="changed" handler="on_cmb_dimensions_changed" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
@@ -970,6 +971,60 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="revealed">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -1007,7 +1062,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+63 -2
View File
@@ -17,6 +17,11 @@
<property name="step-increment">1</property> <property name="step-increment">1</property>
<property name="page-increment">10</property> <property name="page-increment">10</property>
</object> </object>
<object class="GtkImage" id="img_startdate">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">x-office-calendar-symbolic</property>
</object>
<object class="GtkStack" id="topobject"> <object class="GtkStack" id="topobject">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
@@ -789,10 +794,11 @@
</child> </child>
<child> <child>
<object class="GtkButton" id="but_date_start"> <object class="GtkButton" id="but_date_start">
<property name="label" translatable="yes">button</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="receives-default">True</property> <property name="receives-default">True</property>
<property name="image">img_startdate</property>
<property name="always-show-image">True</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -813,6 +819,61 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -850,7 +911,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+56 -1
View File
@@ -668,6 +668,61 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -705,7 +760,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+56 -1
View File
@@ -1019,6 +1019,61 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -1056,7 +1111,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+135 -32
View File
@@ -6,7 +6,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="pixel-size">16</property> <property name="pixel-size">16</property>
<property name="icon-name">stock_calendar</property> <property name="icon-name">x-office-calendar-symbolic</property>
</object> </object>
<object class="GtkImage" id="img_finished"> <object class="GtkImage" id="img_finished">
<property name="visible">True</property> <property name="visible">True</property>
@@ -357,7 +357,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<!-- n-columns=2 n-rows=10 --> <!-- n-columns=2 n-rows=11 -->
<object class="GtkGrid" id="grd_details"> <object class="GtkGrid" id="grd_details">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
@@ -383,6 +383,7 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -417,7 +418,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">2</property> <property name="top-attach">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -431,7 +432,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">3</property> <property name="top-attach">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -440,6 +441,7 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -455,13 +457,14 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">2</property> <property name="top-attach">3</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -470,13 +473,14 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">3</property> <property name="top-attach">4</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -490,7 +494,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">4</property> <property name="top-attach">5</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -504,7 +508,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">5</property> <property name="top-attach">6</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -518,7 +522,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">6</property> <property name="top-attach">7</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -527,21 +531,7 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<style> <property name="xalign">0</property>
<class name="field-value"/>
</style>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_duedate">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="selectable">True</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -552,11 +542,12 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="lbl_started"> <object class="GtkLabel" id="lbl_duedate">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
@@ -566,6 +557,22 @@
<property name="top-attach">6</property> <property name="top-attach">6</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkLabel" id="lbl_started">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
<style>
<class name="field-value"/>
</style>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel"> <object class="GtkLabel">
<property name="visible">True</property> <property name="visible">True</property>
@@ -578,7 +585,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">9</property> <property name="top-attach">10</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -588,6 +595,7 @@
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="vexpand">True</property> <property name="vexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<property name="yalign">0</property> <property name="yalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
@@ -595,7 +603,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">9</property> <property name="top-attach">10</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -609,7 +617,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">7</property> <property name="top-attach">8</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -618,13 +626,14 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">7</property> <property name="top-attach">8</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -638,7 +647,7 @@
</object> </object>
<packing> <packing>
<property name="left-attach">0</property> <property name="left-attach">0</property>
<property name="top-attach">8</property> <property name="top-attach">9</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -647,13 +656,44 @@
<property name="can-focus">False</property> <property name="can-focus">False</property>
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="selectable">True</property> <property name="selectable">True</property>
<property name="xalign">0</property>
<style> <style>
<class name="field-value"/> <class name="field-value"/>
</style> </style>
</object> </object>
<packing> <packing>
<property name="left-attach">1</property> <property name="left-attach">1</property>
<property name="top-attach">8</property> <property name="top-attach">9</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Project</property>
<style>
<class name="field-name"/>
</style>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_project">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="selectable">True</property>
<property name="xalign">0</property>
<style>
<class name="field-value"/>
</style>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
</packing> </packing>
</child> </child>
</object> </object>
@@ -955,6 +995,8 @@
<object class="GtkEntry" id="ent_plandate"> <object class="GtkEntry" id="ent_plandate">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="max-length">10</property>
<property name="width-chars">12</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -991,6 +1033,8 @@
<object class="GtkEntry" id="ent_duedate"> <object class="GtkEntry" id="ent_duedate">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="max-length">10</property>
<property name="width-chars">12</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -1027,6 +1071,8 @@
<object class="GtkEntry" id="ent_started"> <object class="GtkEntry" id="ent_started">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="max-length">16</property>
<property name="width-chars">18</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -1062,6 +1108,8 @@
<object class="GtkEntry" id="ent_finished"> <object class="GtkEntry" id="ent_finished">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can-focus">True</property> <property name="can-focus">True</property>
<property name="max-length">16</property>
<property name="width-chars">18</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@@ -1096,6 +1144,61 @@
<property name="position">1</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="spacing">6</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="spacing">16</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child> <child>
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
@@ -1133,7 +1236,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>
+3 -2
View File
@@ -1,8 +1,8 @@
# SPDX-License-Identifier: WTFPL # SPDX-License-Identifier: WTFPL
""" """
Spezial: Special:
Notebook mit Vessel, User, Lists, Settings Notebook with Vessel, User, Lists, Settings
""" """
@@ -328,6 +328,7 @@ class BaseView(View):
self.db.conn.commit() self.db.conn.commit()
# Refresh dependent data # Refresh dependent data
self.load_dropdowns() self.load_dropdowns()
self.context.publish("vessel_changed", (self.context.vessel.pk_value, ))
# Show data # Show data
self.display_vessel(self.context.vessel) self.display_vessel(self.context.vessel)
+8 -4
View File
@@ -126,9 +126,9 @@ class BoxesView(View):
self.sbox.sid = combobox.get_list_value(self.combo['storage']) self.sbox.sid = combobox.get_list_value(self.combo['storage'])
self.sbox.boxtype = combobox.get_list_value(self.combo['type']) self.sbox.boxtype = combobox.get_list_value(self.combo['type'])
self.sbox.content = self.entry['content'].get_text() self.sbox.content = self.entry['content'].get_text()
self.sbox.wx = int(self.spin['wx'].get_value()) self.sbox.wx = self.spin['wx'].get_value_as_int()
self.sbox.wy = int(self.spin['wy'].get_value()) self.sbox.wy = self.spin['wy'].get_value_as_int()
self.sbox.wz = int(self.spin['wz'].get_value()) self.sbox.wz = self.spin['wz'].get_value_as_int()
self.sbox.color = self.entry['color'].get_text().lstrip('#') self.sbox.color = self.entry['color'].get_text().lstrip('#')
self.sbox.price = self.spin['price'].get_value() self.sbox.price = self.spin['price'].get_value()
self.sbox.weight = self.spin['weight'].get_value() self.sbox.weight = self.spin['weight'].get_value()
@@ -203,8 +203,12 @@ class BoxesView(View):
r = round(rgba.red * 255) r = round(rgba.red * 255)
g = round(rgba.green * 255) g = round(rgba.green * 255)
b = round(rgba.blue * 255) b = round(rgba.blue * 255)
a = round(rgba.alpha * 255)
#self.last_valid_rgb = f"{r:02X}{g:02X}{b:02X}" #self.last_valid_rgb = f"{r:02X}{g:02X}{b:02X}"
self.entry['color'].set_text(f"#{r:02X}{g:02X}{b:02X}") if a > 0:
self.entry['color'].set_text(f"#{r:02X}{g:02X}{b:02X}")
else:
self.entry['color'].set_text('')
def on_ent_color_activate(self, entry): def on_ent_color_activate(self, entry):
self.set_color_from_entry(entry) self.set_color_from_entry(entry)
+70 -13
View File
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: WTFPL # SPDX-License-Identifier: WTFPL
import os import os
from gi.repository import Gtk from gi.repository import Gtk, Gdk
from .view import View from .view import View
from yms import gtkutils, combobox, treeview from yms import gtkutils, combobox, treeview
@@ -16,12 +16,13 @@ class CablesView(View):
self.cable = cable.Cable(context.db) # current record self.cable = cable.Cable(context.db) # current record
self.newrecord = False self.newrecord = False
self.lst_cables = Gtk.ListStore(int, str, str) self.lst_cables = Gtk.ListStore(int, str, str, str)
self.load_list() self.load_list()
treeview.add_column(self.tree['cables'], _('ID'), 0) treeview.add_column(self.tree['cables'], _('ID'), 0)
treeview.add_column(self.tree['cables'], _('Name'), 1) treeview.add_column(self.tree['cables'], _('Name'), 1)
treeview.add_column(self.tree['cables'], _('Condition'), 2) treeview.add_column(self.tree['cables'], _('Condition'), 2)
treeview.add_column(self.tree['cables'], _('Length'), 3)
self.tree['cables'].set_model(self.lst_cables) self.tree['cables'].set_model(self.lst_cables)
# Cable type # Cable type
@@ -41,21 +42,27 @@ class CablesView(View):
combobox.load_from_dict(self.combo['condition'], self.dd_condition, 'unknown') combobox.load_from_dict(self.combo['condition'], self.dd_condition, 'unknown')
def load_list(self): def load_list(self):
selected_id = treeview.get_value(self.tree['cables'])
self.lst_cables.clear() self.lst_cables.clear()
sql = ( sql = (
"SELECT cableid, cablename, cablecond " "SELECT cableid, cablename, cablecond, length "
"FROM cable " "FROM cable "
"WHERE vid=%s " "WHERE vid=%s "
"ORDER BY cableid" "ORDER BY cableid"
) )
self.db.dcur.execute(sql, (self.context.vessel.vid,)) self.db.dcur.execute(sql, (self.context.vessel.vid,))
selection = self.tree['cables'].get_selection()
for row in self.db.dcur.fetchall(): for row in self.db.dcur.fetchall():
data = ( data = (
row['cableid'], row['cableid'],
row['cablename'], row['cablename'],
row['cablecond'] row['cablecond'],
self.format_float(row['length'], suffix='m')
) )
self.lst_cables.append(data) treeiter = self.lst_cables.append(data)
if row['cableid'] == selected_id:
# restore previous selected row
selection.select_iter(treeiter)
def display_record(self): def display_record(self):
self.label['name'].set_text(self.cable.cablename or '') self.label['name'].set_text(self.cable.cablename or '')
@@ -83,36 +90,69 @@ class CablesView(View):
def edit_record(self): def edit_record(self):
# fill UI fields from database record # fill UI fields from database record
self.entry['name'].set_text(self.cable.cablename) self.entry['name'].set_text(self.cable.cablename or '')
combobox.activate_row(self.combo['type'], self.cable.cabletype or -1) combobox.activate_row(self.combo['type'], self.cable.cabletype or -1)
combobox.activate_row(self.combo['techname'], self.cable.techname or -1) combobox.activate_row(self.combo['techname'], self.cable.techname or -1)
self.spin['length'].set_value(self.cable.length or 0) self.spin['length'].set_value(self.cable.length or 0)
self.spin['consuctors'].set_value(self.cable.conductors or 0) self.spin['conductors'].set_value(self.cable.conductors or 0)
self.spin['diameter'].set_value(self.cable.diameter or 0) self.spin['diameter'].set_value(self.cable.diameter or 0)
self.spin['xsection'].set_value(self.cable.xsection or 0) self.spin['xsection'].set_value(self.cable.xsection or 0)
self.spin['weight'].set_value(self.cable.weight or 0) self.spin['weight'].set_value(self.cable.weight or 0)
self.entry['color'].set_text('#' + self.cable.color) self.entry['color'].set_text(self.format_color(self.cable.color))
rgba = Gdk.RGBA() if self.cable.color is None:
rgba.parse('#' + self.cable.color) rgba = Gdk.RGBA(0, 0, 0, 0)
else:
rgba = Gdk.RGBA()
rgba.parse('#' + self.cable.color)
self.button['color'].set_rgba(rgba) self.button['color'].set_rgba(rgba)
combobox.activate_row(self.combo['supplier'], self.cable.supplier or -1) combobox.activate_row(self.combo['supplier'], self.cable.supplier or -1)
combobox.activate_row(self.combo['manufacturer'], self.cable.manufacturer or -1) combobox.activate_row(self.combo['manufacturer'], self.cable.manufacturer or -1)
combobox.activate_row(self.combo['consition'], self.cable.cablecond or 'unknown') combobox.activate_row(self.combo['condition'], self.cable.cablecond or 'unknown')
self.text['remarks'].get_buffer().set_text(self.sbox.remarks or '') self.text['remarks'].get_buffer().set_text(self.cable.remarks or '')
self.entry['name'].grab_focus() self.entry['name'].grab_focus()
def save_record(self): def save_record(self):
# fields must have been validated beforehand # fields must have been validated beforehand
self.cable.vid = self.context.vessel.vid
self.cable.cablename = self.entry['name'].get_text().strip() self.cable.cablename = self.entry['name'].get_text().strip()
self.cable.cabletype = combobox.get_list_value(self.combo['type']) self.cable.cabletype = combobox.get_list_value(self.combo['type'])
if self.cable.cabletype == -1:
self.cable.cabletype = None
self.cable.length = int(self.spin['length'].get_value()) self.cable.length = int(self.spin['length'].get_value())
self.cable.conductors = int(self.spin['conductors'].get_value()) self.cable.conductors = int(self.spin['conductors'].get_value())
self.cable.diameter = self.spin['diameter'].get_value() self.cable.diameter = self.spin['diameter'].get_value()
self.cable.xsection = self.spin['xsection'].get_value() self.cable.xsection = self.spin['xsection'].get_value()
self.cable.weight = int(self.spin['weight'].get_value()) self.cable.weight = int(self.spin['weight'].get_value())
if self.button['color'].get_rgba().alpha > 0:
self.cable.color = self.entry['color'].get_text().lstrip('#')
else:
self.cable.color = None
self.cable.supplier = combobox.get_list_value(self.combo['supplier']) self.cable.supplier = combobox.get_list_value(self.combo['supplier'])
if self.cable.supplier == -1:
self.cable.supplier = None
self.cable.manufacturer = combobox.get_list_value(self.combo['manufacturer']) self.cable.manufacturer = combobox.get_list_value(self.combo['manufacturer'])
self.cable.condition = combobox.get_list_value(self.combo['condition']) if self.cable.manufacturer == -1:
self.cable.manufacturer = None
self.cable.cablecond = combobox.get_list_value(self.combo['condition'])
self.cable.remarks = gtkutils.get_text_contents(self.text['remarks'])
def on_but_color_set(self, button):
rgba = button.get_rgba()
r = round(rgba.red * 255)
g = round(rgba.green * 255)
b = round(rgba.blue * 255)
a = round(rgba.alpha * 255)
if a > 0:
self.entry['color'].set_text(f"#{r:02X}{g:02X}{b:02X}")
else:
self.entry['color'].set_text('')
def on_ent_color_activate(self, entry):
self.set_color_from_entry(entry, self.button['color'])
def on_ent_color_focus_out_event(self, entry, event):
self.set_color_from_entry(entry, self.button['color'])
return False
# buttons on list page # buttons on list page
def on_but_new_clicked(self, widget): def on_but_new_clicked(self, widget):
@@ -122,6 +162,13 @@ class CablesView(View):
self.topwidget.set_visible_child(self.box['cable_edit']) self.topwidget.set_visible_child(self.box['cable_edit'])
def on_but_edit_clicked(self, widget): def on_but_edit_clicked(self, widget):
self.newrecord = False
self.label['title_edit'].set_text(_("Edit Cable"))
cableid = treeview.get_value(self.tree['cables'], 0)
if not cableid:
return
self.cable.load(cableid)
self.edit_record()
self.topwidget.set_visible_child(self.box['cable_edit']) self.topwidget.set_visible_child(self.box['cable_edit'])
def on_but_detail_clicked(self, widget): def on_but_detail_clicked(self, widget):
@@ -163,6 +210,16 @@ class CablesView(View):
return return
self.save_record() self.save_record()
print(self.cable) print(self.cable)
if not self.cable.save():
print("ERROR saving cable")
# TODO error in infobox
print(self.context.db.last_error())
return
if self.newrecord:
self.load_list()
self.newrecord = False
self.display_record()
self.topwidget.set_visible_child(self.box['cable_detail'])
def on_but_cancel_clicked(self, widget): def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['cables']) self.topwidget.set_visible_child(self.box['cables'])
+19 -10
View File
@@ -37,21 +37,13 @@ class DocumentsView(View):
self.uploaddialog.set_title("Upload new document") self.uploaddialog.set_title("Upload new document")
self.lst_documents = Gtk.ListStore(int, str, str, str, int) self.lst_documents = Gtk.ListStore(int, str, str, str, int)
sql = ( self.load_list()
"SELECT d.docid, d.doctype, d.filename, d.title, COUNT(r.drid) AS refcount "
"FROM document AS d LEFT OUTER JOIN docref AS r USING (docid) "
"GROUP BY d.docid, d.doctype, d.filename, d.title "
"ORDER BY d.docid"
)
self.db.cur.execute(sql)
for row in self.db.cur.fetchall():
self.lst_documents.append(row)
treeview.add_column(self.tree['documents'], _('ID'), 0) treeview.add_column(self.tree['documents'], _('ID'), 0)
treeview.add_column(self.tree['documents'], _('Type'), 1) treeview.add_column(self.tree['documents'], _('Type'), 1)
treeview.add_column(self.tree['documents'], _('Filename'), 2) treeview.add_column(self.tree['documents'], _('Filename'), 2)
treeview.add_column(self.tree['documents'], _('Title'), 3) treeview.add_column(self.tree['documents'], _('Title'), 3)
treeview.add_column(self.tree['documents'], _('References'), 3) treeview.add_column(self.tree['documents'], _('References'), 4)
self.tree['documents'].set_model(self.lst_documents) self.tree['documents'].set_model(self.lst_documents)
# Status # Status
@@ -61,6 +53,23 @@ class DocumentsView(View):
self.dd_access = self.context.lookup.enum('document.roleaccess') self.dd_access = self.context.lookup.enum('document.roleaccess')
combobox.load_from_dict(self.combo['accesslevel'], self.dd_access) combobox.load_from_dict(self.combo['accesslevel'], self.dd_access)
def load_list(self):
selected_id = treeview.get_value(self.tree['documents'])
self.lst_documents.clear()
sql = (
"SELECT d.docid, d.doctype, d.filename, d.title, COUNT(r.drid) AS refcount "
"FROM document AS d LEFT OUTER JOIN docref AS r USING (docid) "
"GROUP BY d.docid, d.doctype, d.filename, d.title "
"ORDER BY d.docid"
)
self.db.cur.execute(sql)
selection = self.tree['documents'].get_selection()
for row in self.db.cur.fetchall():
treeiter = self.lst_documents.append(row)
if row['docid'] == selected_id:
# restore previous selected row
selection.select_iter(treeiter)
def clear_record(self): def clear_record(self):
self.doc.clear() self.doc.clear()
combobox.activate_row(self.combo['doctype'], 'generic') combobox.activate_row(self.combo['doctype'], 'generic')
+39 -9
View File
@@ -5,7 +5,7 @@ from gi.repository import GLib, Gtk, Gdk
from dateutil.parser import parse from dateutil.parser import parse
from gettext import pgettext from gettext import pgettext
from .view import View from .view import View, DatePicker
from yms import gtkutils, combobox, treeview from yms import gtkutils, combobox, treeview
from yms.lookup import Dropdown from yms.lookup import Dropdown
from yms.model import equipment from yms.model import equipment
@@ -44,7 +44,29 @@ class EquipmentView(View):
self.dd_condition = self.context.lookup.enum('equipment.econd') self.dd_condition = self.context.lookup.enum('equipment.econd')
combobox.load_from_dict(self.combo['condition'], self.dd_condition, 'unknown') combobox.load_from_dict(self.combo['condition'], self.dd_condition, 'unknown')
self.entry['purchdate'].set_placeholder_text(context.get_datefmt_placeholder())
self.dt_purchdate = DatePicker(self.entry['purchdate'], self.button['purchdate'], context.get_datefmt())
def get_list_row(self):
return (
self.equip.eid,
self.equip.ename,
self.dd_manufacturer.get(self.equip.manufacturer, ''),
self.equip.model,
self.equip.serial,
self.format_date(self.equip.purchdate),
self.equip.remarks
)
def add_row(self):
treeiter = self.lst_equipment.append(self.get_list_row())
# TODO self.tree['equipment'].get_selection().select_iter(treeiter)
def refresh_row(self):
treeview.set_row_values(self.tree['equipment'], self.get_list_row())
def load_list(self): def load_list(self):
selected_id = treeview.get_value(self.tree['equipment'])
self.lst_equipment.clear() self.lst_equipment.clear()
sql = ( sql = (
"SELECT e.eid, e.ename, c.compname, e.model, e.serial, " "SELECT e.eid, e.ename, c.compname, e.model, e.serial, "
@@ -52,11 +74,17 @@ class EquipmentView(View):
"FROM equipment AS e LEFT OUTER JOIN company AS c ON (e.manufacturer=c.compid) " "FROM equipment AS e LEFT OUTER JOIN company AS c ON (e.manufacturer=c.compid) "
"WHERE e.vid=%s " "WHERE e.vid=%s "
"ORDER BY e.ename" "ORDER BY e.ename"
).format(self.context.datefmt.replace('%', '%%')) ).format(self.context.get_datefmt().replace('%', '%%'))
# ).format("%%d.%%m.%%Y") # TODO format from settings via mapping
self.db.cur.execute(sql, (self.context.vessel.vid,)) self.db.cur.execute(sql, (self.context.vessel.vid,))
selection = self.tree['equipment'].get_selection()
for row in self.db.cur.fetchall(): for row in self.db.cur.fetchall():
self.lst_equipment.append(row) treeiter = self.lst_equipment.append(row)
if row[0] == selected_id:
# restore previous selected row
selection.select_iter(treeiter)
def on_page_activated(self):
print("Equipment activated")
def clear_record(self): def clear_record(self):
self.equip.clear() self.equip.clear()
@@ -208,12 +236,14 @@ class EquipmentView(View):
return return
self.save_record() self.save_record()
print(self.equip) print(self.equip)
self.equip.save() if not self.equip.save():
if self.newrecord: # TODO error handling
self.load_list()
else:
pass pass
# TODO aktuelle Listenzeile aktualisieren! if self.newrecord:
self.add_row()
#self.load_list()
else:
self.refresh_row()
self.newrecord = False self.newrecord = False
self.display_record() self.display_record()
self.topwidget.set_visible_child(self.box['equip_detail']) self.topwidget.set_visible_child(self.box['equip_detail'])
+98 -26
View File
@@ -17,21 +17,7 @@ class FusesView(View):
self.newrecord = False self.newrecord = False
self.lst_fuses = Gtk.ListStore(int, str, str, str) self.lst_fuses = Gtk.ListStore(int, str, str, str)
sql = ( self.load_list()
"SELECT fuseid, fnumber, current, description "
"FROM fuse "
"WHERE vid=%s "
"ORDER BY fuseid"
)
self.db.dcur.execute(sql, (context.vessel.vid,))
for row in self.db.dcur.fetchall():
data = (
row['fuseid'],
'F{}'.format(row['fnumber']),
'{} A'.format(row['current']), # TODO better formatting
row['description']
)
self.lst_fuses.append(data)
treeview.add_column(self.tree['fuses'], _('ID'), 0) treeview.add_column(self.tree['fuses'], _('ID'), 0)
treeview.add_column(self.tree['fuses'], _('Name'), 1) treeview.add_column(self.tree['fuses'], _('Name'), 1)
@@ -41,13 +27,39 @@ class FusesView(View):
# Fuse Type # Fuse Type
self.dd_ftype = self.context.lookup.dropdown(Dropdown.FUSE_TYPE) self.dd_ftype = self.context.lookup.dropdown(Dropdown.FUSE_TYPE)
combobox.load_from_dict(self.combo['ftype'], self.dd_ftype) combobox.load_from_dict(self.combo['ftype'], {-1: _("─── unknown ───")} | self.dd_ftype)
# Cables # Cables
self.dd_cable = self.context.lookup.cable(context.vessel.vid) self.dd_cable = self.context.lookup.cable(context.vessel.vid)
combobox.load_from_dict(self.combo['cable'], {-1: _("─── none ───")} | self.dd_cable) combobox.load_from_dict(self.combo['cable'], {-1: _("─── none ───")} | self.dd_cable)
# Equipment # Equipment
self.dd_equipment = self.context.lookup.equipment(context.vessel.vid) self.dd_equipment = self.context.lookup.equipment(context.vessel.vid)
combobox.load_from_dict(self.combo['equipment'], {-1: _("─── none ───")} | self.dd_equipment) combobox.load_from_dict(self.combo['equipment'], {-1: _("─── none ───")} | self.dd_equipment)
# Location
self.dd_location = self.context.lookup.dropdown(Dropdown.FUSE_BLOCK)
combobox.load_from_dict(self.combo['location'], {-1: _("─── unknown ───")} | self.dd_location)
def load_list(self):
selected_id = treeview.get_value(self.tree['fuses'])
self.lst_fuses.clear()
sql = (
"SELECT fuseid, fnumber, current, description "
"FROM fuse "
"WHERE vid=%s "
"ORDER BY fuseid"
)
self.db.dcur.execute(sql, (self.context.vessel.vid,))
selection = self.tree['fuses'].get_selection()
for row in self.db.dcur.fetchall():
data = (
row['fuseid'],
'F{}'.format(row['fnumber']),
'{} A'.format(row['current']), # TODO better formatting
row['description']
)
treeiter = self.lst_fuses.append(data)
if row['fuseid'] == selected_id:
# restore previous selected row
selection.select_iter(treeiter)
def clear_record(self): def clear_record(self):
self.fuse.clear() self.fuse.clear()
@@ -57,18 +69,34 @@ class FusesView(View):
self.spin['current'].set_value(0) self.spin['current'].set_value(0)
combobox.activate_row(self.combo['cable'], -1) combobox.activate_row(self.combo['cable'], -1)
combobox.activate_row(self.combo['equipment'], -1) combobox.activate_row(self.combo['equipment'], -1)
self.entry['location'].set_text('') combobox.activate_row(self.combo['location'], -1)
self.text['remarks'].get_buffer().set_text('') self.text['remarks'].get_buffer().set_text('')
self.spin['fnumber'].grab_focus() self.spin['fnumber'].grab_focus()
def display_record(self): def display_record(self):
self.label['fnumber'].set_text(f"F{self.fuse.fnumber}") self.label['fnumber'].set_text(f"F{self.fuse.fnumber}")
self.label['type'].set_text(self.dd_type[self.fuse.ftype]) if self.fuse.ftype:
self.label['type'].set_text(self.dd_ftype[self.fuse.ftype] or '')
else:
self.label['type'].set_text('')
self.label['current'].set_text(self.format_float(self.fuse.current, 2, suffix="A")) self.label['current'].set_text(self.format_float(self.fuse.current, 2, suffix="A"))
self.label['cable'].set_text(str(self.fuse.cableid)) if self.fuse.cableid:
self.label['equipment'].set_text(str(self.fuse.eid)) self.label['cable'].set_text(self.dd_cable[self.fuse.cableid])
self.label['location'].set_text(str(self.fuse.location)) else:
self.label['cable'].set_text('')
if self.fuse.eid:
self.label['equipment'].set_text(self.dd_equipment[self.fuse.eid])
else:
self.label['equipment'].set_text('')
if self.fuse.location:
self.label['location'].set_text(self.dd_location[self.fuse.location])
else:
self.label['location'].set_text('')
self.label['description'].set_text(str(self.fuse.description or '')) self.label['description'].set_text(str(self.fuse.description or ''))
if self.fuse.color:
self.label['color'].set_markup(f'#{self.cable.color} <span foreground="#{self.fuse.color}">●</span>')
else:
self.label['color'].set_text('')
self.label['remarks'].set_text(str(self.fuse.remarks or '')) self.label['remarks'].set_text(str(self.fuse.remarks or ''))
def edit_record(self): def edit_record(self):
@@ -78,20 +106,52 @@ class FusesView(View):
self.spin['current'].set_value(self.fuse.current) self.spin['current'].set_value(self.fuse.current)
combobox.activate_row(self.combo['cable'], self.fuse.cableid) combobox.activate_row(self.combo['cable'], self.fuse.cableid)
combobox.activate_row(self.combo['equipment'], self.fuse.eid) combobox.activate_row(self.combo['equipment'], self.fuse.eid)
self.entry['location'].set_text(self.fuse.location) combobox.activate_row(self.combo['location'], self.fuse.location)
self.text['remarks'].get_buffer().set_text(self.prov.remarks or '') self.text['remarks'].get_buffer().set_text(self.fuse.remarks or '')
self.spin['fnumber'].grab_focus() self.spin['fnumber'].grab_focus()
def save_record(self): def save_record(self):
# fields must have been validated beforehand # fields must have been validated beforehand
self.fuse.number = int(self.spin['fnumber'].get_value()) self.fuse.vid = self.context.vessel.vid
self.fuse.fnumber = self.spin['fnumber'].get_value_as_int()
self.fuse.current = self.spin['current'].get_value()
self.fuse.description = self.entry['description'].get_text() self.fuse.description = self.entry['description'].get_text()
self.fuse.ftype = combobox.get_list_value(self.combo['ftype']) self.fuse.ftype = combobox.get_list_value(self.combo['ftype'])
if self.fuse.ftype == -1:
self.fuse.ftype = None
self.fuse.cableid = combobox.get_list_value(self.combo['cable']) self.fuse.cableid = combobox.get_list_value(self.combo['cable'])
if self.fuse.cableid == -1:
self.fuse.cableid = None
self.fuse.eid = combobox.get_list_value(self.combo['equipment']) self.fuse.eid = combobox.get_list_value(self.combo['equipment'])
self.fuse.location = self.entry['location'].get_text() if self.fuse.eid == -1:
self.fuse.eid = None
self.fuse.location = combobox.get_list_value(self.combo['location'])
if self.fuse.location == -1:
self.fuse.location = None
if self.button['color'].get_rgba().alpha > 0:
self.fuse.color = self.entry['color'].get_text().lstrip('#')
else:
self.fuse.color = None
self.fuse.remarks = gtkutils.get_text_contents(self.text['remarks']) self.fuse.remarks = gtkutils.get_text_contents(self.text['remarks'])
def on_but_color_set(self, button):
rgba = button.get_rgba()
r = round(rgba.red * 255)
g = round(rgba.green * 255)
b = round(rgba.blue * 255)
a = round(rgba.alpha * 255)
if a > 0:
self.entry['color'].set_text(f"#{r:02X}{g:02X}{b:02X}")
else:
self.entry['color'].set_text('')
def on_ent_color_activate(self, entry):
self.set_color_from_entry(entry, self.button['color'])
def on_ent_color_focus_out_event(self, entry, event):
self.set_color_from_entry(entry, self.button['color'])
return False
# buttons on list page # buttons on list page
def on_but_new_clicked(self, widget): def on_but_new_clicked(self, widget):
self.newrecord = True self.newrecord = True
@@ -141,7 +201,19 @@ class FusesView(View):
# buttons on edit page # buttons on edit page
def on_but_save_clicked(self, widget): def on_but_save_clicked(self, widget):
pass fnumber = self.spin['fnumber'].get_value_as_int()
current = self.spin['current'].get_value()
# TODO check for duplicate number!
sql = "SELECT COUNT(fnumber) FROM fuse WHERE fnumber=%s"
if (fnumber == 0) or (current == 0):
# TODO error marker
return
self.save_record()
print(self.fuse)
self.fuse.save()
self.display_record()
self.topwidget.set_visible_child(self.box['fuse_detail'])
def on_but_cancel_clicked(self, widget): def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['fuses']) self.topwidget.set_visible_child(self.box['fuses'])
+11 -5
View File
@@ -55,6 +55,7 @@ class InventoryView(View):
combobox.load_from_dict(self.combo['condition'], self.dd_condition) combobox.load_from_dict(self.combo['condition'], self.dd_condition)
def load_list(self): def load_list(self):
selected_id = treeview.get_value(self.tree['inventory'])
self.lst_inventory.clear() self.lst_inventory.clear()
sql = ( sql = (
"SELECT i.invid, i.invname, s.sname AS container, i.number, i.invcond, i.remarks " "SELECT i.invid, i.invname, s.sname AS container, i.number, i.invcond, i.remarks "
@@ -65,9 +66,13 @@ class InventoryView(View):
"WHERE s.vid=%s" "WHERE s.vid=%s"
) )
self.db.cur.execute(sql, (self.context.vessel.vid, self.context.vessel.vid)) self.db.cur.execute(sql, (self.context.vessel.vid, self.context.vessel.vid))
selection = self.tree['inventory'].get_selection()
for row in self.db.cur.fetchall(): for row in self.db.cur.fetchall():
self.lst_inventory.append(row) treeiter = self.lst_inventory.append(row)
if row[0] == selected_id:
# restore previous selected row
selection.select_iter(treeiter)
def lock_timer(self): def lock_timer(self):
self.context.db.lock_refresh(self.token) self.context.db.lock_refresh(self.token)
return True # continue timer return True # continue timer
@@ -96,9 +101,9 @@ class InventoryView(View):
self.label['name'].set_text(self.inv.invname) self.label['name'].set_text(self.inv.invname)
container = pgettext("inventory.conttype", self.inv.conttype) container = pgettext("inventory.conttype", self.inv.conttype)
if self.inv.conttype == 'storage': if self.inv.conttype == 'storage':
self.label['conttype'].set_text("{}: {}".format(container, self.dd_storage[self.inv.sid])) self.label['conttype'].set_text("{}: {}".format(container, self.dd_storage.get(self.inv.sid, '')))
else: else:
self.label['conttype'].set_text("{}: {}".format(container, self.dd_box[self.inv.boxid])) self.label['conttype'].set_text("{}: {}".format(container, self.dd_box.get(self.inv.boxid, '')))
self.label['equipment'].set_text(str(self.inv.eid)) self.label['equipment'].set_text(str(self.inv.eid))
self.label['number'].set_text(self.format_int(self.inv.number)) self.label['number'].set_text(self.format_int(self.inv.number))
self.label['weight'].set_text(self.format_float(self.inv.weight, suffix='kg')) self.label['weight'].set_text(self.format_float(self.inv.weight, suffix='kg'))
@@ -255,7 +260,8 @@ class InventoryView(View):
return return
self.save_record() self.save_record()
print(self.inv) print(self.inv)
self.inv.save() if not self.inv.save():
pass
if self.newrecord: if self.newrecord:
self.load_list() self.load_list()
self.newrecord = False self.newrecord = False
+81 -24
View File
@@ -2,9 +2,12 @@
import os import os
from gi.repository import Gtk from gi.repository import Gtk
from dateutil.parser import parse
from datetime import datetime
from .view import View from .view import View, DatePicker
from yms import gtkutils, combobox, treeview from yms import gtkutils, combobox, treeview
from yms.lookup import Dropdown
from yms.model import maintenance from yms.model import maintenance
class MaintenanceView(View): class MaintenanceView(View):
@@ -16,15 +19,7 @@ class MaintenanceView(View):
self.newrecord = False self.newrecord = False
self.lst_maintenance = Gtk.ListStore(int, str, str, str) self.lst_maintenance = Gtk.ListStore(int, str, str, str)
sql = ( self.load_list()
"SELECT m.maintid, m.activities, e.ename, m.remarks "
"FROM maintenance AS m LEFT OUTER JOIN equipment AS e USING (eid) "
"WHERE m.vid=%s "
"ORDER BY m.maintid"
)
self.db.cur.execute(sql, (context.vessel.vid,))
for row in self.db.cur.fetchall():
self.lst_maintenance.append(row)
treeview.add_column(self.tree['maintenance'], _('ID'), 0) treeview.add_column(self.tree['maintenance'], _('ID'), 0)
treeview.add_column(self.tree['maintenance'], _('Activities'), 1) treeview.add_column(self.tree['maintenance'], _('Activities'), 1)
@@ -32,14 +27,49 @@ class MaintenanceView(View):
treeview.add_column(self.tree['maintenance'], _('Remarks'), 3) treeview.add_column(self.tree['maintenance'], _('Remarks'), 3)
self.tree['maintenance'].set_model(self.lst_maintenance) self.tree['maintenance'].set_model(self.lst_maintenance)
# Equipment
self.dd_equipment = self.context.lookup.equipment(context.vessel.vid)
combobox.load_from_dict(self.combo['equipment'], {-1: _("─── none ───")} | self.dd_equipment)
# Plan date precision
self.dd_precision = self.context.lookup.enum('maintenance.plan_precision')
combobox.load_from_dict(self.combo['plan_precision'], self.dd_precision, 'month')
# Status
self.dd_status = self.context.lookup.enum('maintenance.maintstate')
combobox.load_from_dict(self.combo['status'], self.dd_status, 'new')
self.entry['plandate'].set_placeholder_text(context.get_datefmt_placeholder())
self.dt_plandate = DatePicker(self.entry['plandate'], self.button['plandate'], context.get_datefmt())
self.entry['completion'].set_placeholder_text(context.get_datefmt_placeholder())
self.dt_completion = DatePicker(self.entry['completion'], self.button['completion'], context.get_datefmt())
def load_list(self):
selected_id = treeview.get_value(self.tree['maintenance'])
self.lst_maintenance.clear()
sql = (
"SELECT m.maintid, m.activities, e.ename, m.remarks "
"FROM maintenance AS m LEFT OUTER JOIN equipment AS e USING (eid) "
"WHERE m.vid=%s "
"ORDER BY m.maintid"
)
self.db.cur.execute(sql, (self.context.vessel.vid,))
selection = self.tree['maintenance'].get_selection()
for row in self.db.cur.fetchall():
treeiter = self.lst_maintenance.append(row)
if row[0] == selected_id:
# restore previous selected row
selection.select_iter(treeiter)
def clear_record(self): def clear_record(self):
self.maint.clear() self.maint.clear()
self.entry['activities'].set_text('') self.entry['activities'].set_text('')
combobox.activate_row(self.combo['equipment'], -1) combobox.activate_row(self.combo['equipment'], -1)
self.spin['series'].set_value(0) self.spin['series'].set_text('')
self.spin['interval'].set_value(0) self.spin['interval'].set_text('')
self.spin['last'].set_value(0) self.spin['last_hours'].set_text('')
self.entry['plandate'].set_text('') self.entry['plandate'].set_text('')
combobox.activate_row(self.combo['plan_precision'], 'month')
self.entry['completion'].set_text('') self.entry['completion'].set_text('')
combobox.activate_row(self.combo['status'], 'new') combobox.activate_row(self.combo['status'], 'new')
self.text['remarks'].get_buffer().set_text('') self.text['remarks'].get_buffer().set_text('')
@@ -57,31 +87,49 @@ class MaintenanceView(View):
self.label['remarks'].set_text(self.maint.remarks or '') self.label['remarks'].set_text(self.maint.remarks or '')
def edit_record(self): def edit_record(self):
self.entry['activities'].set_text(self.maint.activities) self.entry['activities'].set_text(self.maint.activities or '')
combobox.activate_row(self.combo['equipment'], self.maint.eid) combobox.activate_row(self.combo['equipment'], self.maint.eid or -1)
self.spin['series'].set_value(self.maint.series or 0) self.spin['series'].set_value(self.maint.series or 0)
self.spin['interval'].set_value(self.maint.interval_hours or 0) self.spin['interval'].set_value(self.maint.interval_hours or 0)
self.spin['last'].set_value(self.maint.last_hours or 0) self.spin['last_hours'].set_value(self.maint.last_hours or 0)
self.entry['plandate'].set_text(self.maint.plan_date) self.entry['plandate'].set_text(self.format_date(self.maint.plan_date))
self.entry['completion'].set_text(self.maint.completion_date) self.entry['completion'].set_text(self.format_date(self.maint.completion_date))
combobox.activate_row(self.combo['status'], self.maint.maintstate) combobox.activate_row(self.combo['status'], self.maint.maintstate)
self.text['remarks'].get_buffer().set_text(self.maint.remarks or '') self.text['remarks'].get_buffer().set_text(self.maint.remarks or '')
self.entry['activities'].grab_focus() self.entry['activities'].grab_focus()
def save_record(self): def save_record(self):
# fields must have been validated beforehand # fields must have been validated beforehand
self.maint.vid = self.context.vessel.vid
self.maint.activities = self.entry['activities'].get_text() self.maint.activities = self.entry['activities'].get_text()
self.maint.eid = combobox.get_list_value(self.combo['equipment']) self.maint.eid = combobox.get_list_value(self.combo['equipment'])
self.maint.series = int(self.spin['series'].get_value()) if self.maint.eid == -1:
self.maint.interval_hours = int(self.spin['interval'].get_value()) self.maint.eid = None
self.maint.last_hours = int(self.spin['last'].get_value()) self.maint.series = self.spin['series'].get_value_as_int()
self.maint.plan_date = self.entry['plandate'].get_text() if self.maint.series == -1:
self.maint.completion_date = self.entry['completion'].get_text() self.maint.series = None
self.maint.interval_hours = self.spin['interval'].get_value_as_int()
if self.maint.interval_hours == 0:
self.maint.interval_hours = None
self.maint.last_hours = self.spin['last_hours'].get_value_as_int()
if self.maint.last_hours == 0:
self.maint.last_hours = None
try:
self.maint.plan_date = parse(self.entry['plandate'].get_text(), dayfirst=True)
except ValueError:
self.maint.plan_date = None
try:
self.maint.completion_date = parse(self.entry['completion'].get_text(), dayfirst=True)
except ValueError:
self.maint.completion_date = None
self.maint.maintstate = combobox.get_list_value(self.combo['status']) self.maint.maintstate = combobox.get_list_value(self.combo['status'])
self.maint.remarks = gtkutils.get_text_contents(self.text['remarks']) self.maint.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page # buttons on list page
def on_but_new_clicked(self, widget): def on_but_new_clicked(self, widget):
self.clear_record()
self.newrecord = True
print("New:Datefmt={}".format(self.context.datefmt))
self.topwidget.set_visible_child(self.box['maint_edit']) self.topwidget.set_visible_child(self.box['maint_edit'])
def on_but_edit_clicked(self, widget): def on_but_edit_clicked(self, widget):
@@ -132,7 +180,16 @@ class MaintenanceView(View):
return return
self.save_record() self.save_record()
print(self.maint) print(self.maint)
self.maint.save() if not self.maint.save():
print("Save error")
# TODO error in infobox
print(self.context.db.last_error())
return
if self.newrecord:
self.load_list()
self.newrecord = False
self.display_record()
self.topwidget.set_visible_child(self.box['maint_detail'])
def on_but_cancel_clicked(self, widget): def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['maintenance']) self.topwidget.set_visible_child(self.box['maintenance'])
+80 -28
View File
@@ -12,6 +12,9 @@ class MeasurementView(View):
def __init__(self, context): def __init__(self, context):
super().__init__(context, _("Measurements"), "measurement.ui") super().__init__(context, _("Measurements"), "measurement.ui")
self.infobar.set_revealed(False)
self.infobar_label = Gtk.Label()
self.infobar.get_content_area().add(self.infobar_label)
self.measure = measurement.Measurement(context.db) # current record self.measure = measurement.Measurement(context.db) # current record
self.newrecord = False self.newrecord = False
@@ -22,9 +25,10 @@ class MeasurementView(View):
# accuracy # accuracy
self.dd_accuracy = self.context.lookup.enum('measurement.accuracy') self.dd_accuracy = self.context.lookup.enum('measurement.accuracy')
combobox.load_from_dict(self.combo['accuracy'], {"-1": _("─── none ───")} | self.dd_accuracy) combobox.load_from_dict(self.combo['accuracy'], self.dd_accuracy, 'unknown')
# measurement units # measurement units
# ATTENTION: Minimum one element in list has to be defined!
self.dd_unit = self.context.lookup.dropdown(Dropdown.UNIT) self.dd_unit = self.context.lookup.dropdown(Dropdown.UNIT)
combobox.load_from_dict(self.combo['unit'], self.dd_unit, 1) combobox.load_from_dict(self.combo['unit'], self.dd_unit, 1)
@@ -37,6 +41,19 @@ class MeasurementView(View):
combobox.load_from_dict(self.combo['category'], {-1: _("─── none ───")} | self.dd_category) combobox.load_from_dict(self.combo['category'], {-1: _("─── none ───")} | self.dd_category)
self.lst_measurement = Gtk.ListStore(int, str, str, str, str, str) self.lst_measurement = Gtk.ListStore(int, str, str, str, str, str)
self.load_list()
treeview.add_column(self.tree['measurement'], _('ID'), 0)
treeview.add_column(self.tree['measurement'], _('Measurement'), 1)
treeview.add_column(self.tree['measurement'], _('Value'), 2)
treeview.add_column(self.tree['measurement'], _('Accuracy'), 3)
treeview.add_column(self.tree['measurement'], _('Equipment'), 4)
treeview.add_column(self.tree['measurement'], _('Note'), 5)
self.tree['measurement'].set_model(self.lst_measurement)
def load_list(self):
selected_id = treeview.get_value(self.tree['measurement'])
self.lst_measurement.clear()
sql = ( sql = (
"SELECT m.mid, m.mname, m.nval, m.val1, m.val2, m.val3, m.unit, " "SELECT m.mid, m.mname, m.nval, m.val1, m.val2, m.val3, m.unit, "
"m.accuracy, m.note, e.ename " "m.accuracy, m.note, e.ename "
@@ -44,7 +61,8 @@ class MeasurementView(View):
"WHERE m.vid=%s " "WHERE m.vid=%s "
"ORDER BY m.mid" "ORDER BY m.mid"
) )
self.db.dcur.execute(sql, (context.vessel.vid,)) self.db.dcur.execute(sql, (self.context.vessel.vid,))
selection = self.tree['measurement'].get_selection()
for row in self.db.dcur.fetchall(): for row in self.db.dcur.fetchall():
if row['nval'] == 1: if row['nval'] == 1:
value = "{} {}".format(row['val1'], row['unit']) value = "{} {}".format(row['val1'], row['unit'])
@@ -63,23 +81,18 @@ class MeasurementView(View):
row['ename'], row['ename'],
row['note'] or '' row['note'] or ''
) )
self.lst_measurement.append(data) treeiter = self.lst_measurement.append(data)
if row[0] == selected_id:
treeview.add_column(self.tree['measurement'], _('ID'), 0) # restore previous selected row
treeview.add_column(self.tree['measurement'], _('Measurement'), 1) selection.select_iter(treeiter)
treeview.add_column(self.tree['measurement'], _('Value'), 2)
treeview.add_column(self.tree['measurement'], _('Accuracy'), 3)
treeview.add_column(self.tree['measurement'], _('Equipment'), 4)
treeview.add_column(self.tree['measurement'], _('Note'), 5)
self.tree['measurement'].set_model(self.lst_measurement)
def clear_record(self): def clear_record(self):
self.measure.clear() self.measure.clear()
self.entry['name'].set_text('') self.entry['name'].set_text('')
combobox.activate_row(self.combo['dimensions'], -1) combobox.activate_row(self.combo['dimensions'], 1)
self.spin['val1'].set_value(0) self.spin['val1'].set_text('')
self.spin['val2'].set_value(0) self.spin['val2'].set_text('')
self.spin['val3'].set_value(0) self.spin['val3'].set_text('')
combobox.activate_row(self.combo['accuracy'], 'unknown') combobox.activate_row(self.combo['accuracy'], 'unknown')
self.entry['date'].set_text('') self.entry['date'].set_text('')
combobox.activate_row(self.combo['equipment'], -1) combobox.activate_row(self.combo['equipment'], -1)
@@ -87,29 +100,45 @@ class MeasurementView(View):
self.text['note'].get_buffer().set_text('') self.text['note'].get_buffer().set_text('')
self.entry['name'].grab_focus() self.entry['name'].grab_focus()
self.label['edit_val2'].set_visible(False)
self.spin['val2'].set_visible(False)
self.label['edit_val3'].set_visible(False)
self.spin['val3'].set_visible(False)
def display_record(self): def display_record(self):
self.label['name'].set_text(self.measure.mname) self.label['name'].set_text(self.measure.mname)
self.label['dimensions'].set_text(self.measure.nval) self.label['dimensions'].set_text(self.dd_dimensions[self.measure.nval])
self.label['val1'].set_text(self.measure.val1) self.label['val1'].set_text(self.format_int(self.measure.val1))
if self.measure.nval >= 2: if self.measure.nval >= 2:
self.label['val2'].set_text(self.measure.val2 or '') self.label['val2'].set_text(self.format_int(self.measure.val2))
else: else:
self.label['val2'].set_text('n/a') self.label['val2'].set_text('n/a')
if self.measure.nval == 3: if self.measure.nval == 3:
self.label['val3'].set_text(self.measure.val3 or '') self.label['val3'].set_text(self.format_int(self.measure.val3))
else: else:
self.label['val3'].set_text('n/a') self.label['val3'].set_text('n/a')
# TODO self.label['unit'].set_text(self.dd_unit.get(self.measure.unit, ''))
# unit self.label['accuracy'].set_text(self.dd_accuracy[self.measure.accuracy])
# accuracy self.label['date'].set_text(self.format_date(self.measure.mdate))
# category self.label['category'].set_text(self.dd_category[self.measure.mcat])
self.label['note'].set_text(self.measure.note or '')
def edit_record(self): def edit_record(self):
self.entry['name'].set_text(self.measure.mname) self.entry['name'].set_text(self.measure.mname)
combobox.activate_row(self.combo['dimensions'], self.measure.nval) combobox.activate_row(self.combo['dimensions'], self.measure.nval)
self.spin['val1'].set_value(self.measure.val1) if self.measure.val1 is None:
self.spin['val2'].set_value(self.measure.val2 or 0) self.spin['val1'].set_text('')
self.spin['val3'].set_value(self.measure.val3 or 0) else:
self.spin['val1'].set_value(self.measure.val1)
if self.measure.val2 is None:
self.spin['val2'].set_text('')
else:
self.spin['val2'].set_value(self.measure.val2)
if self.measure.val3 is None:
self.spin['val3'].set_text('')
else:
self.spin['val3'].set_value(self.measure.val3)
combobox.activate_row(self.combo['unit'], self.measure.unit or 1)
combobox.activate_row(self.combo['accuracy'], self.measure.accuracy) combobox.activate_row(self.combo['accuracy'], self.measure.accuracy)
self.entry['date'].set_text(self.measure.mdate) self.entry['date'].set_text(self.measure.mdate)
combobox.activate_row(self.combo['equipment'], self.measure.eid) combobox.activate_row(self.combo['equipment'], self.measure.eid)
@@ -117,6 +146,11 @@ class MeasurementView(View):
self.text['note'].get_buffer().set_text(self.task.note or '') self.text['note'].get_buffer().set_text(self.task.note or '')
self.entry['name'].grab_focus() self.entry['name'].grab_focus()
self.label['edit_val2'].set_visible(self.measure.nval > 1)
self.spin['val2'].set_visible(self.measure.nval > 1)
self.label['edit_val3'].set_visible(self.measure.nval > 2)
self.spin['val3'].set_visible(self.measure.nval > 2)
def save_record(self): def save_record(self):
# fields must have been validated beforehand # fields must have been validated beforehand
self.measure.mname = self.entry['name'].get_text() self.measure.mname = self.entry['name'].get_text()
@@ -124,7 +158,7 @@ class MeasurementView(View):
self.measure.val1 = self.spin['val1'].get_value_as_int() self.measure.val1 = self.spin['val1'].get_value_as_int()
self.measure.val2 = self.spin['val2'].get_value_as_int() self.measure.val2 = self.spin['val2'].get_value_as_int()
self.measure.val3 = self.spin['val3'].get_value_as_int() self.measure.val3 = self.spin['val3'].get_value_as_int()
self.measure.accuracy = combobox.get_list_value(self.combo['accurace']) self.measure.accuracy = combobox.get_list_value(self.combo['accuracy'])
self.measure.mdate = self.entry['date'].get_text() self.measure.mdate = self.entry['date'].get_text()
self.measure.eid = combobox.get_list_value(self.combo['equipment']) self.measure.eid = combobox.get_list_value(self.combo['equipment'])
self.measure.mcat = combobox.get_list_value(self.combo['category']) self.measure.mcat = combobox.get_list_value(self.combo['category'])
@@ -163,6 +197,13 @@ class MeasurementView(View):
self.topwidget.set_visible_child(self.box['measure_detail']) self.topwidget.set_visible_child(self.box['measure_detail'])
self.button['close'].grab_focus() self.button['close'].grab_focus()
def on_cmb_dimensions_changed(self, widget):
ndim = combobox.get_list_value(widget)
self.label['edit_val2'].set_visible(ndim > 1)
self.spin['val2'].set_visible(ndim > 1)
self.label['edit_val3'].set_visible(ndim > 2)
self.spin['val3'].set_visible(ndim > 2)
# buttons on detail page # buttons on detail page
# edit2 uses edit callback # edit2 uses edit callback
def on_but_close_clicked(self, widget): def on_but_close_clicked(self, widget):
@@ -180,12 +221,23 @@ class MeasurementView(View):
# buttons on edit page # buttons on edit page
def on_but_save_clicked(self, widget): def on_but_save_clicked(self, widget):
# check mandatory fields # check mandatory fields
if not self.entry['mname'].get_text().strip(): if not self.entry['name'].get_text().strip():
# TODO error marker # TODO error marker
print("Save error mandatory fields missing")
self.infobar.set_message_type(Gtk.MessageType.WARNING)
self.infobar_label.set_text("Save error mandatory fields missing")
self.infobar.set_revealed(True)
return return
else:
self.infobar_label.set_text('')
self.infobar.set_revealed(False)
self.save_record() self.save_record()
print(self.measure) print(self.measure)
self.measure.save() self.measure.save()
if self.newrecord:
self.load_list()
self.newrecord = False
self.display_record() self.display_record()
self.topwidget.set_visible_child(self.box['measure_detail']) self.topwidget.set_visible_child(self.box['measure_detail'])
+55 -26
View File
@@ -18,23 +18,7 @@ class ProjectsView(View):
self.newrecord = False self.newrecord = False
self.lst_projects = Gtk.ListStore(int, str, str, int, str, str) self.lst_projects = Gtk.ListStore(int, str, str, int, str, str)
sql = ( self.load_list()
"SELECT projid, projname, startdate, duration, projstate, remarks "
"FROM project "
"WHERE vid=%s "
"ORDER BY projid"
)
self.db.dcur.execute(sql, (context.vessel.vid,))
for row in self.db.dcur.fetchall():
data = (
row['projid'],
row['projname'],
self.format_date(row['startdate']),
row['duration'],
row['projstate'],
row['remarks']
)
self.lst_projects.append(data)
treeview.add_column(self.tree['projects'], _('ID'), 0) treeview.add_column(self.tree['projects'], _('ID'), 0)
treeview.add_column(self.tree['projects'], _('Name'), 1) treeview.add_column(self.tree['projects'], _('Name'), 1)
@@ -52,13 +36,38 @@ class ProjectsView(View):
self.dd_state = self.context.lookup.enum('project.projstate') self.dd_state = self.context.lookup.enum('project.projstate')
combobox.load_from_dict(self.combo['status'], self.dd_state) combobox.load_from_dict(self.combo['status'], self.dd_state)
def load_list(self):
selected_id = treeview.get_value(self.tree['projects'])
self.lst_projects.clear()
sql = (
"SELECT projid, projname, startdate, duration, projstate, remarks "
"FROM project "
"WHERE vid=%s "
"ORDER BY projid"
)
self.db.dcur.execute(sql, (self.context.vessel.vid,))
selection = self.tree['projects'].get_selection()
for row in self.db.dcur.fetchall():
data = (
row['projid'],
row['projname'],
self.format_date(row['startdate']),
row['duration'],
row['projstate'],
row['remarks']
)
treeiter = self.lst_projects.append(data)
if row['projid'] == selected_id:
# restore previous selected row
selection.select_iter(treeiter)
def clear_record(self): def clear_record(self):
self.project.clear() self.project.clear()
self.entry['name'].set_text('') self.entry['name'].set_text('')
combobox.activate_row(self.combo['responsible'], 0) combobox.activate_row(self.combo['responsible'], 0)
self.entry['date_start'].set_text('') self.entry['date_start'].set_text('')
self.spin['costs_plan'].set_value(0) self.spin['costs_plan'].set_text('')
self.spin['costs_final'].set_value(0) self.spin['costs_final'].set_text('')
combobox.activate_row(self.combo['status'], 'new') combobox.activate_row(self.combo['status'], 'new')
self.text['remarks'].get_buffer().set_text('') self.text['remarks'].get_buffer().set_text('')
self.entry['name'].grab_focus() self.entry['name'].grab_focus()
@@ -76,15 +85,26 @@ class ProjectsView(View):
def edit_record(self): def edit_record(self):
self.entry['name'].set_text(self.project.projname) self.entry['name'].set_text(self.project.projname)
combobox.activate_row(self.combo['responsible'], self.project.responsible) combobox.activate_row(self.combo['responsible'], self.project.responsible)
self.entry['date_start'].set_text(self.project.startdate) self.entry['date_start'].set_text(self.format_date(self.project.startdate))
self.spin['costs_plan'].set_value(self.project.costs_plan) if self.project.costs_plan:
self.spin['costs_final'].set_value(self.project.costs_final) self.spin['duration'].set_value(self.project.duration)
else:
self.spin['duration'].set_text('')
if self.project.costs_plan:
self.spin['costs_plan'].set_value(self.project.costs_plan)
else:
self.spin['costs_plan'].set_text('')
if self.project.costs_final:
self.spin['costs_final'].set_value(self.project.costs_final)
else:
self.spin['costs_final'].set_text('')
combobox.activate_row(self.combo['status'], self.project.projstate) combobox.activate_row(self.combo['status'], self.project.projstate)
self.text['remarks'].get_buffer().set_text(self.project.remarks or '') self.text['remarks'].get_buffer().set_text(self.project.remarks or '')
self.entry['name'].grab_focus() self.entry['name'].grab_focus()
def save_record(self): def save_record(self):
# fields must have been validated beforehand # fields must have been validated beforehand
self.project.vid = self.context.vessel.vid
self.project.projname = self.entry['name'].get_text() self.project.projname = self.entry['name'].get_text()
self.project.responsible = combobox.get_list_value(self.combo['responsible']) self.project.responsible = combobox.get_list_value(self.combo['responsible'])
self.project.costs_plan = int(self.spin['costs_plan'].get_value()) self.project.costs_plan = int(self.spin['costs_plan'].get_value())
@@ -103,9 +123,9 @@ class ProjectsView(View):
self.newrecord = False self.newrecord = False
self.label['title_edit'].set_text(_("Edit Project")) self.label['title_edit'].set_text(_("Edit Project"))
projid = treeview.get_value(self.tree['projects'], 0) projid = treeview.get_value(self.tree['projects'], 0)
if not projidid: if not projid:
return return
self.measure.load(mid) self.project.load(projid)
self.edit_record() self.edit_record()
self.topwidget.set_visible_child(self.box['proj_edit']) self.topwidget.set_visible_child(self.box['proj_edit'])
@@ -142,12 +162,21 @@ class ProjectsView(View):
# buttons on edit page # buttons on edit page
def on_but_save_clicked(self, widget): def on_but_save_clicked(self, widget):
# check mandatory fields # check mandatory fields
if not self.entry['projname'].get_text().strip(): if not self.entry['name'].get_text().strip():
# TODO error marker # TODO error marker
return return
self.save_record() self.save_record()
print(self.project) print(self.project)
self.project.save() if not self.project.save():
print("Project save error")
# TODO error in infobox
print(self.context.db.last_error())
return
if self.newrecord:
self.load_list()
self.newrecord = False
self.display_record()
self.topwidget.set_visible_child(self.box['proj_detail'])
def on_but_cancel_clicked(self, widget): def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['projects']) self.topwidget.set_visible_child(self.box['projects'])
+7 -5
View File
@@ -44,10 +44,10 @@ class ProvisionsView(View):
self.tree['provisions'].set_model(self.lst_provisions) self.tree['provisions'].set_model(self.lst_provisions)
# TODO Date format # TODO Date format
self.entry['storedate'].set_placeholder_text("TT.MM.JJJJ") self.entry['storedate'].set_placeholder_text(context.get_datefmt_placeholder())
self.dt_storedate = DatePicker(self.entry['storedate'], self.button['storedate'], context.datefmt) self.dt_storedate = DatePicker(self.entry['storedate'], self.button['storedate'], context.get_datefmt())
self.entry['shelflife'].set_placeholder_text("TT.MM.JJJJ") self.entry['shelflife'].set_placeholder_text(context.get_datefmt_placeholder())
self.dt_shelflife = DatePicker(self.entry['shelflife'], self.button['shelflife'], context.datefmt) self.dt_shelflife = DatePicker(self.entry['shelflife'], self.button['shelflife'], context.get_datefmt())
def load_list(self): def load_list(self):
selected_id = treeview.get_value(self.tree['provisions']) selected_id = treeview.get_value(self.tree['provisions'])
@@ -58,6 +58,7 @@ class ProvisionsView(View):
"WHERE s.vid=%s OR vid IS NULL" "WHERE s.vid=%s OR vid IS NULL"
) )
self.db.dcur.execute(sql, (self.context.vessel.vid,)) self.db.dcur.execute(sql, (self.context.vessel.vid,))
selection = self.tree['provisions'].get_selection()
for row in self.db.dcur.fetchall(): for row in self.db.dcur.fetchall():
data = ( data = (
row['provid'], row['provid'],
@@ -144,13 +145,14 @@ class ProvisionsView(View):
self.prov.unit = combobox.get_list_value(self.combo['unit']) self.prov.unit = combobox.get_list_value(self.combo['unit'])
if self.prov.unit == -1: if self.prov.unit == -1:
self.prov.unit = None self.prov.unit = None
self.prov.calories = self.spin['calories'].get_value_as_int()
# TODO respect configured date format # TODO respect configured date format
# self.prov.storedate = self.dt_storedate.get_date() # self.prov.storedate = self.dt_storedate.get_date()
# self.prov.shelflife = self.dt_shelflife.get_date() # self.prov.shelflife = self.dt_shelflife.get_date()
try: try:
self.prov.storedate = parse(self.entry['storedate'].get_text(), dayfirst=True) self.prov.storedate = parse(self.entry['storedate'].get_text(), dayfirst=True)
except ValueError: except ValueError:
self.prov.shelfstoredatelife = None self.prov.storedate = None
try: try:
self.prov.shelflife = parse(self.entry['shelflife'].get_text(), dayfirst=True) self.prov.shelflife = parse(self.entry['shelflife'].get_text(), dayfirst=True)
except ValueError: except ValueError:
+7
View File
@@ -52,6 +52,13 @@ class StatusView:
self.svg_centerline_y = 0.0 self.svg_centerline_y = 0.0
self.load_svg() self.load_svg()
# subscribe to data change events
self.context.subscribe("vessel_changed", self.vessel_changed)
def vessel_changed(self, data):
print(f"Vessel changed. New ID={data[0]}")
self.load_svg()
def load_svg(self): def load_svg(self):
if not self.context.vessel.shapefile: if not self.context.vessel.shapefile:
print("No Shapefile defined for current vessel") print("No Shapefile defined for current vessel")
-1
View File
@@ -38,7 +38,6 @@ class StorageView(View):
pass pass
def refresh_row(self): def refresh_row(self):
pass
treeview.set_value(self.tree['storage'], 1, self.storage.name) treeview.set_value(self.tree['storage'], 1, self.storage.name)
position = f"({self.storage.x}, {self.storage.y}, {self.storage.z})" position = f"({self.storage.x}, {self.storage.y}, {self.storage.z})"
treeview.set_value(self.tree['storage'], 2, position) treeview.set_value(self.tree['storage'], 2, position)
+55 -21
View File
@@ -2,8 +2,10 @@
import os import os
from gi.repository import Gtk from gi.repository import Gtk
from dateutil.parser import parse
from datetime import datetime
from .view import View from .view import View, DatePicker
from yms import gtkutils, combobox, treeview from yms import gtkutils, combobox, treeview
from yms.model import task from yms.model import task
@@ -32,17 +34,24 @@ class TasksView(View):
# Priority # Priority
self.dd_priority = self.context.lookup.enum('task.priority') self.dd_priority = self.context.lookup.enum('task.priority')
combobox.load_from_dict(self.combo['priority'], self.dd_priority) combobox.load_from_dict(self.combo['priority'], self.dd_priority, 'low')
# Status # Status
self.dd_state = self.context.lookup.enum('task.taskstate') self.dd_state = self.context.lookup.enum('task.taskstate')
combobox.load_from_dict(self.combo['status'], self.dd_state) combobox.load_from_dict(self.combo['status'], self.dd_state, 'pending')
# Responsible # Responsible
self.dd_user = context.lookup.user() self.dd_user = context.lookup.user()
combobox.load_from_dict(self.combo['responsible'], self.dd_user) combobox.load_from_dict(self.combo['responsible'], self.dd_user, 0)
self.entry['plandate'].set_placeholder_text(context.get_datefmt_placeholder())
self.dt_plandate = DatePicker(self.entry['plandate'], self.button['plandate'], context.get_datefmt())
self.entry['duedate'].set_placeholder_text(context.get_datefmt_placeholder())
self.dt_duedate = DatePicker(self.entry['duedate'], self.button['duedate'], context.get_datefmt())
def load_list(self): def load_list(self):
selected_id = treeview.get_value(self.tree['tasks'])
self.lst_tasks.clear()
sql = ( sql = (
"SELECT t.taskid, t.taskname, t.priority, t.taskstate, " "SELECT t.taskid, t.taskname, t.priority, t.taskstate, "
"u.displayname AS responsible " "u.displayname AS responsible "
@@ -51,6 +60,7 @@ class TasksView(View):
"ORDER BY t.taskid" "ORDER BY t.taskid"
) )
self.db.dcur.execute(sql, (self.context.vessel.vid,)) self.db.dcur.execute(sql, (self.context.vessel.vid,))
selection = self.tree['tasks'].get_selection()
for row in self.db.dcur.fetchall(): for row in self.db.dcur.fetchall():
data = ( data = (
row['taskid'], row['taskid'],
@@ -59,53 +69,77 @@ class TasksView(View):
row['taskstate'], row['taskstate'],
row['responsible'] row['responsible']
) )
self.lst_tasks.append(data) treeiter = self.lst_tasks.append(data)
if row['taskid'] == selected_id:
# restore previous selected row
selection.select_iter(treeiter)
def clear_record(self): def clear_record(self):
self.task.clear() self.task.clear()
self.entry['name'].set_text('') self.entry['name'].set_text('')
combobox.activate_row(self.combo['project'], -1) combobox.activate_row(self.combo['project'], -1)
combobox.activate_row(self.combo['priority'], -1) combobox.activate_row(self.combo['priority'], 'low')
self.entry['plandate'].set_text('') self.entry['plandate'].set_text('')
self.entry['duedate'].set_text('') self.entry['duedate'].set_text('')
self.entry['started'].set_text('') self.entry['started'].set_text('')
self.entry['finished'].set_text('') self.entry['finished'].set_text('')
combobox.activate_row(self.combo['status'], 'new') combobox.activate_row(self.combo['status'], 'pending')
combobox.activate_row(self.combo['responsible'], 0) combobox.activate_row(self.combo['responsible'], 0)
self.text['remarks'].get_buffer().set_text('') self.text['remarks'].get_buffer().set_text('')
self.entry['name'].grab_focus() self.entry['name'].grab_focus()
def display_record(self): def display_record(self):
self.label['name'].set_text(self.task.taskname) self.label['name'].set_text(self.task.taskname)
self.label['responsible'].set_text('') self.label['project'].set_text(self.dd_project.get(self.task.projid, ''))
self.label['priority'].set_text(self.dd_priority[self.task.priority])
self.label['plandate'].set_text(self.format_date(self.task.plandate))
self.label['duedate'].set_text(self.format_date(self.task.duedate))
self.label['started'].set_text(self.format_datetime(self.task.started))
self.label['finished'].set_text(self.format_datetime(self.task.finished))
self.label['status'].set_text(self.task.taskstate) self.label['status'].set_text(self.task.taskstate)
self.label['responsible'].set_text('')
self.label['remarks'].set_text(self.task.remarks or '') self.label['remarks'].set_text(self.task.remarks or '')
def edit_record(self): def edit_record(self):
self.entry['name'].set_text(self.task.taskname) self.entry['name'].set_text(self.task.taskname)
combobox.activate_row(self.combo['project'], self.task.projid) combobox.activate_row(self.combo['project'], self.task.projid)
combobox.activate_row(self.combo['priority'], self.task.priority) combobox.activate_row(self.combo['priority'], self.task.priority)
self.entry['plandate'].set_text(self.task.plandate) self.entry['plandate'].set_text(self.format_date(self.task.plandate))
self.entry['duedate'].set_text(self.task.duedate) self.entry['duedate'].set_text(self.format_date(self.task.duedate))
self.entry['started'].set_text(self.task.started) self.entry['started'].set_text(self.format_datetime(self.task.started))
self.entry['finished'].set_text(self.task.finsihed) self.entry['finished'].set_text(self.format_datetime(self.task.finished))
combobox.activate_row(self.combo['taskstate'], self.task.taskstate) combobox.activate_row(self.combo['status'], self.task.taskstate)
combobox.activate_row(self.combo['responsible'], self.task.responsible) combobox.activate_row(self.combo['responsible'], self.task.responsible)
self.text['remarks'].get_buffer().set_text(self.task.remarks or '') self.text['remarks'].get_buffer().set_text(self.task.remarks or '')
self.entry['name'].grab_focus() self.entry['name'].grab_focus()
def save_record(self): def save_record(self):
# fields must have been validated beforehand # fields must have been validated beforehand
self.task.vid = self.context.vessel.vid
self.task.taskname = self.entry['name'].get_text() self.task.taskname = self.entry['name'].get_text()
self.task.projid = combobox.get_list_value(self.combo['project']) self.task.projid = combobox.get_list_value(self.combo['project'])
self.task.priority = combobox.get_list_value(self.combo['project']) if self.task.projid == -1:
self.task.plandate = self.entry['plandate'].get_text() self.task.projid = None
self.task.duedate = self.entry['duedate'].get_text() self.task.priority = combobox.get_list_value(self.combo['priority'])
self.task.started = self.entry['started'].get_text() try:
self.task.finished = self.entry['finished'].get_text() self.task.plandate = parse(self.entry['plandate'].get_text(), dayfirst=True)
self.task.taskstate = combobox.get_list_value(self.combo['taskstate']) except ValueError:
self.task.resposible = combobox.get_list_value(self.combo['responsible']) self.task.plandate = None
self.project.remarks = gtkutils.get_text_contents(self.text['remarks']) try:
self.task.duedate = parse(self.entry['plandate'].get_text(), dayfirst=True)
except ValueError:
self.task.duedate = None
try:
self.task.started = parse(self.entry['started'].get_text(), dayfirst=True)
except ValueError:
self.task.started = None
try:
self.task.finished = parse(self.entry['finished'].get_text(), dayfirst=True)
except ValueError:
self.task.finished = None
self.task.taskstate = combobox.get_list_value(self.combo['status'])
self.task.responsible = combobox.get_list_value(self.combo['responsible'])
self.task.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page # buttons on list page
def on_but_new_clicked(self, widget): def on_but_new_clicked(self, widget):
+27 -3
View File
@@ -30,6 +30,10 @@ class View:
self.builder.connect_signals(self) self.builder.connect_signals(self)
self.topwidget = self.builder.get_object("topobject") self.topwidget = self.builder.get_object("topobject")
self.infobar = self.builder.get_object("infobar")
if self.infobar:
self.infobar.set_revealed(False)
gtkutils.init_named_controls(self, self.builder) gtkutils.init_named_controls(self, self.builder)
def format_int(self, ival, separator=True, suffix=None, default=''): def format_int(self, ival, separator=True, suffix=None, default=''):
@@ -51,7 +55,23 @@ class View:
def format_date(self, dval, default=''): def format_date(self, dval, default=''):
if dval is None: if dval is None:
return default return default
return dval.strftime(self.context.datefmt) return dval.strftime(self.context.get_datefmt())
def format_datetime(self, dtval, default=''):
# we do not use seconds!
if dtval is None:
return default
return dtval.strftime(self.context.get_datefmt() + ' %H:%M')
def format_color(self, color, default=''):
# alpha only for "no color"
if not color or color.alpha == 0:
return default
else:
r = round(color.red * 255)
g = round(color.green * 255)
b = round(color.blue * 255)
return f"#{r:02X}{g:02X}{b:02X}"
def on_textview_keypress(self, widget, event): def on_textview_keypress(self, widget, event):
# Generic limit length function # Generic limit length function
@@ -120,14 +140,18 @@ class View:
context.add_class("invalid") context.add_class("invalid")
def set_color_from_entry(self, entry, colorbutton): def set_color_from_entry(self, entry, colorbutton):
# TODO this was a fast hack!
text = entry.get_text().strip() text = entry.get_text().strip()
if len(text) == 6:
text = '#' + text
rgba = Gdk.RGBA() rgba = Gdk.RGBA()
if len(text) == 7 and rgba.parse(text): if len(text) == 7 and rgba.parse(text):
self.last_valid_rgb = text.lstrip('#') self.last_valid_rgb = text.lstrip('#')
self.entry.set_text(text) entry.set_text(text.upper())
colorbutton.set_rgba(rgba) colorbutton.set_rgba(rgba)
self.set_entry_valid(entry, True) self.set_entry_valid(entry, True)
elif len(text) == 0:
# set color to "no color" means: black with alpha=0
colorbutton.set_rgba(Gdk.RGBA(0, 0, 0, 0))
else: else:
self.set_entry_valid(entry, False) self.set_entry_valid(entry, False)
+8 -2
View File
@@ -94,7 +94,7 @@ class AppContext:
self.ui_path = os.path.join(self.get_sharepath(), "yms", "ui") self.ui_path = os.path.join(self.get_sharepath(), "yms", "ui")
self.textdomain = "ymsgui" # static here for early initialization self.textdomain = "ymsgui" # static here for early initialization
self.localedir = "locale" self.localedir = "locale"
self.datefmt = '%d.%m.%Y' self.datefmt = 'Y-m-d' # key into map
self.scan_enabled = False self.scan_enabled = False
# system settings stored in database # system settings stored in database
self.curr_sym = '€' self.curr_sym = '€'
@@ -167,6 +167,12 @@ class AppContext:
return "/usr/share" return "/usr/share"
return "" return ""
def get_datefmt(self):
return self.datefmt_map[self.datefmt][0]
def get_datefmt_placeholder(self):
return self.datefmt_map[self.datefmt][1]
class Frontend: class Frontend:
def __init__(self, context): def __init__(self, context):
@@ -235,7 +241,7 @@ class Frontend:
self.db.cur.execute(sql, (self.db_poll_ts,)) self.db.cur.execute(sql, (self.db_poll_ts,))
for row in self.db.cur.fetchall(): for row in self.db.cur.fetchall():
print(f"refresh table based list #{row[0]}") print(f"refresh table based list #{row[0]}")
# TODO get module name für changes in table # TODO get module name for changes in table
modulemap = { modulemap = {
#Table.VESSEL: "base", #Table.VESSEL: "base",
#Table.USERS: "base", #Table.USERS: "base",