Native gui first steps: storage, box and companies are editable

This commit is contained in:
thooge committed 2026-10-21 17:16:55 +02:00
1 parent 1eea4058bf
commit 06a9834688
47 files changed
+3119 -883

No files matched your search

+83 -10
View File
@@ -42,11 +42,81 @@ class TasksView(View):
treeview.add_column(self.tree['tasks'], _('Responsible'), 4)
self.tree['tasks'].set_model(self.lst_tasks)
# Project
self.dd_project = context.lookup.project(self.context.vessel.vid)
combobox.load_from_dict(self.combo['project'], {-1: _("─── none ───")} | self.dd_project)
# Priority
self.dd_priority = self.context.lookup.enum('task.priority')
combobox.load_from_dict(self.combo['priority'], self.dd_priority)
# Status
self.dd_state = self.context.lookup.enum('task.taskstate')
combobox.load_from_dict(self.combo['status'], self.dd_state)
# Responsible
self.dd_user = context.lookup.user()
combobox.load_from_dict(self.combo['responsible'], self.dd_user)
def clear_record(self):
self.task.clear()
self.entry['name'].set_text('')
combobox.activate_row(self.combo['project'], -1)
combobox.activate_row(self.combo['priority'], -1)
self.entry['plandate'].set_text('')
self.entry['duedate'].set_text('')
self.entry['started'].set_text('')
self.entry['finished'].set_text('')
combobox.activate_row(self.combo['status'], 'new')
combobox.activate_row(self.combo['responsible'], 0)
self.text['remarks'].get_buffer().set_text('')
def display_record(self):
self.label['name'].set_text(self.task.taskname)
self.label['responsible'].set_text('')
self.label['status'].set_text(self.task.taskstate)
self.label['remarks'].set_text(self.task.remarks or '')
def edit_record(self):
self.entry['name'].set_text(self.task.taskname)
combobox.activate_row(self.combo['project'], self.task.projid)
combobox.activate_row(self.combo['priority'], self.task.priority)
self.entry['plandate'].set_text(self.task.plandate)
self.entry['duedate'].set_text(self.task.duedate)
self.entry['started'].set_text(self.task.started)
self.entry['finished'].set_text(self.task.finsihed)
combobox.activate_row(self.combo['taskstate'], self.task.taskstate)
combobox.activate_row(self.combo['responsible'], self.task.responsible)
self.text['remarks'].get_buffer().set_text(self.task.remarks or '')
def save_record(self):
# fields must have been validated beforehand
self.task.taskname = self.entry['name'].get_text()
self.task.projid = combobox.get_list_value(self.combo['project'])
self.task.priority = combobox.get_list_value(self.combo['project'])
self.task.plandate = self.entry['plandate'].get_text()
self.task.duedate = self.entry['duedate'].get_text()
self.task.started = self.entry['started'].get_text()
self.task.finished = self.entry['finished'].get_text()
self.task.taskstate = combobox.get_list_value(self.combo['taskstate'])
self.task.resposible = combobox.get_list_value(self.combo['responsible'])
self.project.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text(_("Add new Task"))
self.clear_record()
self.topwidget.set_visible_child(self.box['task_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
self.label['title_edit'].set_text(_("Edit Task"))
taskid = treeview.get_value(self.tree['tasks'], 0)
if not taskid:
return
self.task.load(taskid)
self.edit_record()
self.topwidget.set_visible_child(self.box['task_edit'])
def on_but_detail_clicked(self, widget):
@@ -70,20 +140,23 @@ class TasksView(View):
self.topwidget.set_visible_child(self.box['tasks'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete task!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['tasks'])
# buttons on edit page
def on_but_save_clicked(self, widget):
pass
# check mandatory fields
if not self.entry['taskname'].get_text().strip():
# TODO error marker
return
self.save_record()
print(self.task)
self.task.save()
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['tasks'])
def display_record(self):
self.label['name'].set_text(self.task.taskname)
self.label['responsible'].set_text('')
self.label['status'].set_text(self.task.taskstate)
self.label['remarks'].set_text(self.task.remarks or '')
def edit_record(self):
pass