Native gui: implement data lists for all modules
This commit is contained in:
+59
-8
@@ -5,15 +5,66 @@ import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .view import View
|
||||
from yms import gtkutils, combobox, treeview
|
||||
from yms.model import project
|
||||
|
||||
class ProjectsView:
|
||||
class ProjectsView(View):
|
||||
|
||||
def __init__(self, context):
|
||||
self.title = _("Projects")
|
||||
builder = Gtk.Builder()
|
||||
builder.set_translation_domain(context.textdomain)
|
||||
builder.add_from_file(os.path.join(context.ui_path, "projects.ui"))
|
||||
builder.connect_signals(self)
|
||||
self.topwidget = builder.get_object("topobject")
|
||||
gtkutils.init_named_controls(self, builder)
|
||||
super().__init__(context, _("Projects"), "projects.ui")
|
||||
|
||||
self.project = project.Project(context.db) # current record
|
||||
self.newrecord = False
|
||||
|
||||
self.lst_projects = Gtk.ListStore(int, str, str, int, str, str)
|
||||
sql = (
|
||||
"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'], _('Name'), 1)
|
||||
treeview.add_column(self.tree['projects'], _('Start date'), 2)
|
||||
treeview.add_column(self.tree['projects'], _('Duration'), 3)
|
||||
treeview.add_column(self.tree['projects'], _('Status'), 4)
|
||||
treeview.add_column(self.tree['projects'], _('Remarks'), 5)
|
||||
self.tree['projects'].set_model(self.lst_projects)
|
||||
|
||||
# buttons on list page
|
||||
def on_but_new_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['proj_edit'])
|
||||
|
||||
def on_but_edit_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['proj_edit'])
|
||||
|
||||
def on_but_detail_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['proj_detail'])
|
||||
|
||||
# buttons on detail page
|
||||
# edit2 uses edit callback
|
||||
def on_but_close_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['projects'])
|
||||
|
||||
def on_but_delete_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['projects'])
|
||||
|
||||
# buttons on edit page
|
||||
def on_but_save_clicked(self, widget):
|
||||
pass
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['projects'])
|
||||
|
||||
Reference in New Issue
Block a user