From 3910f9cb245865c17ed7722df2c1136114c21e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D1=80=D0=BE=D0=B4=D0=B8=D0=BD=20=D0=A0=D0=BE?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD?= Date: Thu, 23 Jan 2020 13:23:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=90=D0=BD=D0=B0=D0=BC=D0=BD=D0=B5=D0=B7=20?= =?UTF-8?q?=D0=B2=20=D0=BF=D1=80=D0=B8=D1=91=D0=BC=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mods/lists.py | 36 ++++++- mods/receptions.py | 6 +- res/ui/choose_list_win.glade | 169 -------------------------------- res/ui/open_list_win.glade | 32 +++++- res/ui/open_reception_win.glade | 3 + 5 files changed, 72 insertions(+), 174 deletions(-) delete mode 100644 res/ui/choose_list_win.glade diff --git a/mods/lists.py b/mods/lists.py index 85ce83b..aa94d76 100644 --- a/mods/lists.py +++ b/mods/lists.py @@ -59,6 +59,9 @@ class ListRecordRow(Gtk.ListBoxRow): def get_list(list_id): with db.atomic(): return List.get_by_id(list_id) +def get_list_by_system_id(s_id): + with db.atomic(): + return List.select().where(List.system_id == s_id).get() def get_listrecord(listrec_id): with db.atomic(): return ListRecord.get_by_id(listrec_id) @@ -142,7 +145,7 @@ def build_listrec_editable_row(listrec_o=None): row.add(box) return (row, text_input) -def create_open_list_win(list_id): +def create_open_list_win(list_id, choose=False, parent_list=None): list_o = get_list(list_id) b = Gtk.Builder() listrecord_filter = ListRecFilter(search_list_record) @@ -159,6 +162,7 @@ def create_open_list_win(list_id): row = build_listrecord_row(rec) lr_list.remove(edit_row) edit_row.destroy() + lr_list.unselect_all() lr_list.add(row) lr_list.show_all() def enable_buttons_on_add_edit(self, *a): @@ -168,6 +172,7 @@ def create_open_list_win(list_id): delete_list_record(row.props.db_id) lr_list.remove(row) row.destroy() + lr_list.unselect_all() lr_list.show_all() self.listrec_row_unselected() def edit_row(self, button): @@ -181,6 +186,7 @@ def create_open_list_win(list_id): inp.connect('key-release-event', self.row_edit_cancel, edit_row) inp.connect('activate', self.update_row, edit_row) inp.connect('destroy', self.enable_buttons_on_add_edit) + lr_list.unselect_all() disable_widget([add_button, edit_button, remove_button, lr_filter]) lr_list.show_all() def add_new_row(self, button): @@ -190,6 +196,7 @@ def create_open_list_win(list_id): text_input.connect('key-release-event', self.row_add_cancel, row) text_input.connect('activate', self.save_new_row, row) text_input.connect('destroy', self.enable_buttons_on_add_edit) + lr_list.unselect_all() disable_widget([add_button, edit_button, remove_button, lr_filter]) lr_list.show_all() def update_row(self, inp, edit_row): @@ -222,14 +229,29 @@ def create_open_list_win(list_id): row.destroy() def listrec_row_selected(self, *a): enable_widget([edit_button, remove_button]) + if choose: + enable_widget([accept_button]) def listrec_row_unselected(self, *a): disable_widget([edit_button, remove_button]) + if choose: + disable_widget([accept_button]) def listrec_filter_changed(self, filter_widget): lr_list.unselect_all() self.listrec_row_unselected() lr_list.invalidate_filter() + def submit(self, button): + from mods.receptions import build_reception_anamnesis_row + exist_rows = list(map(lambda x: x.props.db_id, parent_list.get_children())) + rows = lr_list.get_selected_rows() + for row in rows: + if row.props.db_id not in exist_rows: + anamnesis = get_listrecord(row.props.db_id) + parent_list.add(build_reception_anamnesis_row(anamnesis)) + parent_list.show_all() + w.destroy() b.add_from_file(open_list_win_file) - b.connect_signals(OpenListHandler()) + olh = OpenListHandler() + b.connect_signals(olh) # Gtk objects w = b.get_object('open_list_window') lr_list = b.get_object('listrecord_list') @@ -238,6 +260,16 @@ def create_open_list_win(list_id): edit_button = b.get_object('edit_button') remove_button = b.get_object('remove_button') list_header = b.get_object('list_win_header') + accept_place_box = b.get_object('accept_place') + sep_place_box = b.get_object('sep_place') + if choose: + sep_place_box.pack_start(Gtk.Separator(orientation=Gtk.Orientation.VERTICAL), True, True, 0) + accept_button_img = Gtk.Image() + accept_button_img.set_from_icon_name('object-select-symbolic', Gtk.IconSize.BUTTON) + accept_button = Gtk.Button() + accept_button.set_image(accept_button_img) + accept_place_box.pack_start(accept_button, True, True, 0) + accept_button.connect('clicked', olh.submit) ############# ###### def listrecord_sort_func(row1, row2, *a): diff --git a/mods/receptions.py b/mods/receptions.py index 7a549a1..bdfa5c8 100644 --- a/mods/receptions.py +++ b/mods/receptions.py @@ -7,7 +7,7 @@ from mods.files import new_reception_win_file, reception_row_ui_str, reception_l from mods.files import anamnesis_row_ui_str from mods.settings import s_get_reception_list, s_set_reception_list from mods.diagnosis import create_choose_diagnosis_win, get_giagnosis -from mods.lists import get_listrecord +from mods.lists import get_listrecord, get_list_by_system_id, create_open_list_win, ANAMNEZ_LIST from mods.root import builder from datetime import datetime, timedelta @@ -166,6 +166,10 @@ def create_open_reception_win(): def show_choose_diagnosis_win(self, button): choose_diagnosis_win = create_choose_diagnosis_win(b) choose_diagnosis_win.show_all() + def show_choose_anamnesis_win(self, button): + anam_db_list = get_list_by_system_id(ANAMNEZ_LIST) + choose_anamnesis_win = create_open_list_win(anam_db_list.id, choose=True, parent_list=reception_anam_list) + choose_anamnesis_win.show_all() def remove_diagnosis(self, button): row = reception_diag_list.get_selected_row() reception_diag_list.remove(row) diff --git a/res/ui/choose_list_win.glade b/res/ui/choose_list_win.glade deleted file mode 100644 index 24d8dcf..0000000 --- a/res/ui/choose_list_win.glade +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - 600 - 500 - False - True - center - 800 - 500 - dialog - - - True - False - True - - - True - False - True - True - - - True - False - object-select-symbolic - - - - - - - True - False - vertical - - - 1 - - - - - gtk-add - True - True - True - True - True - - - 2 - - - - - gtk-edit - True - False - True - True - True - True - - - 3 - - - - - gtk-remove - True - False - True - True - True - True - - - 4 - - - - - - - True - False - vertical - - - True - True - never - in - - - True - False - - - True - False - - - - - - - True - True - 0 - - - - - True - False - 3 - 3 - - - True - False - - - True - True - 0 - - - - - True - True - edit-find-symbolic - False - False - - - True - True - 1 - - - - - True - False - - - True - True - 2 - - - - - False - True - 1 - - - - - - diff --git a/res/ui/open_list_win.glade b/res/ui/open_list_win.glade index 4e3d4d3..fe231f5 100644 --- a/res/ui/open_list_win.glade +++ b/res/ui/open_list_win.glade @@ -16,6 +16,29 @@ True False True + + + True + False + vertical + + + + + + + + True + False + vertical + + + + + + 1 + + gtk-add @@ -26,6 +49,9 @@ True + + 2 + @@ -39,7 +65,7 @@ - 1 + 3 @@ -54,7 +80,7 @@ - 2 + 4 @@ -78,6 +104,8 @@ True False + multiple + False diff --git a/res/ui/open_reception_win.glade b/res/ui/open_reception_win.glade index 4420c5e..7ef52ff 100644 --- a/res/ui/open_reception_win.glade +++ b/res/ui/open_reception_win.glade @@ -174,6 +174,7 @@ True False + @@ -206,6 +207,7 @@ True True True + True @@ -227,6 +229,7 @@ False True True + True