# SPDX-License-Identifier: WTFPL import os import gi gi.require_version("Gtk", "3.0") from gi.repository import GLib, Gtk, Gdk from .view import View from yms import gtkutils, combobox, treeview from yms.model import document class DocumentsView(View): def __init__(self, context): super().__init__(context, _("Documents"), "documents.ui") self.doc = document.Document(context.db) # current record self.newrecord = False self.lst_documents = Gtk.ListStore(int, str, str, str, int) 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) 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'], _('Type'), 1) treeview.add_column(self.tree['documents'], _('Filename'), 2) treeview.add_column(self.tree['documents'], _('Title'), 3) treeview.add_column(self.tree['documents'], _('References'), 3) self.tree['documents'].set_model(self.lst_documents) # buttons on list page def on_but_new_clicked(self, widget): self.topwidget.set_visible_child(self.box['doc_edit']) def on_but_edit_clicked(self, widget): self.topwidget.set_visible_child(self.box['doc_edit']) def on_but_detail_clicked(self, widget): self.topwidget.set_visible_child(self.box['doc_detail']) # buttons on detail page # edit2 uses edit callback def on_but_close_clicked(self, widget): self.topwidget.set_visible_child(self.box['documents']) def on_but_delete_clicked(self, widget): self.topwidget.set_visible_child(self.box['documents']) # 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['documents'])