From eb9be7b190acdf8ba461cb3c25caf2493468a776 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Tue, 10 Apr 2018 13:04:21 +0300 Subject: [PATCH] fav view update after service edit --- app/ui/main_app_window.py | 2 ++ app/ui/main_helper.py | 15 +++++++++++---- app/ui/service_details_dialog.py | 23 +++++++++++++++++++---- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/app/ui/main_app_window.py b/app/ui/main_app_window.py index 077d8142..77c4892c 100644 --- a/app/ui/main_app_window.py +++ b/app/ui/main_app_window.py @@ -982,6 +982,7 @@ class MainAppWindow: dialog = ServiceDetailsDialog(self._main_window, self._options, self._services_view, + self._fav_view, self._services, self._bouquets) dialog.show() @@ -990,6 +991,7 @@ class MainAppWindow: dialog = ServiceDetailsDialog(self._main_window, self._options, self._services_view, + self._fav_view, self._services, self._bouquets, action=Action.ADD) diff --git a/app/ui/main_helper.py b/app/ui/main_helper.py index a6d3f00c..5de1b92d 100644 --- a/app/ui/main_helper.py +++ b/app/ui/main_helper.py @@ -10,7 +10,7 @@ from app.eparser.ecommons import Flag, BouquetService, Bouquet, BqType from app.eparser.enigma.bouquets import BqServiceType, to_bouquet_id from app.properties import Profile from . import Gtk, Gdk, HIDE_ICON, LOCKED_ICON -from .dialogs import show_dialog, DialogType, get_chooser_dialog +from .dialogs import show_dialog, DialogType, get_chooser_dialog, WaitDialog class ViewTarget(Enum): @@ -439,16 +439,20 @@ def gen_bouquets(view, bq_view, transient, gen_type, tv_types, profile, callback bq_type = BqType.RADIO.value append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, [service.package if gen_type is BqGenType.PACKAGE else - service.pos if gen_type is BqGenType.SAT else service.service_type]) + service.pos if gen_type is BqGenType.SAT else service.service_type], profile) else: - append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, {row[index] for row in model}) + wait_dialog = WaitDialog(transient) + wait_dialog.show() + append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, + {row[index] for row in model}, profile, wait_dialog) @run_task -def append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, names): +def append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, names, profile, wait_dialog=None): bq_view.expand_row(Gtk.TreePath(0), 0) bqs_model = bq_view.get_model() bouquets_names = get_bouquets_names(bqs_model) + for pos, name in enumerate(sorted(names)): if name not in bouquets_names: services = [BouquetService(None, BqServiceType.DEFAULT, row[fav_id_index], 0) @@ -456,6 +460,9 @@ def append_bouquets(bq_type, bq_view, callback, fav_id_index, index, model, name callback(Bouquet(name=name, type=bq_type, services=services, locked=None, hidden=None), bqs_model.get_iter(0)) + if wait_dialog is not None: + wait_dialog.destroy() + def get_bouquets_names(model): """ Returns all current bouquets names """ diff --git a/app/ui/service_details_dialog.py b/app/ui/service_details_dialog.py index ce87bd29..abf0edce 100644 --- a/app/ui/service_details_dialog.py +++ b/app/ui/service_details_dialog.py @@ -6,7 +6,7 @@ from app.eparser import Service from app.eparser.ecommons import MODULATION, Inversion, ROLL_OFF, Pilot, Flag, Pids, POLARIZATION, \ get_key_by_value, get_value_by_name, FEC_DEFAULT, PLS_MODE, SERVICE_TYPE from app.properties import Profile -from . import Gtk, Gdk, UI_RESOURCES_PATH, HIDE_ICON, TEXT_DOMAIN +from . import Gtk, Gdk, UI_RESOURCES_PATH, HIDE_ICON, TEXT_DOMAIN, CODED_ICON from .dialogs import show_dialog, DialogType, Action from .main_helper import get_base_model @@ -31,7 +31,7 @@ class ServiceDetailsDialog: _DIGIT_ENTRY_NAME = "digit-entry" - def __init__(self, transient, options, view, services, bouquets, action=Action.EDIT): + def __init__(self, transient, options, srv_view, fav_view, services, bouquets, action=Action.EDIT): handlers = {"on_system_changed": self.on_system_changed, "on_save": self.on_save, "on_create_new": self.on_create_new, @@ -52,7 +52,8 @@ class ServiceDetailsDialog: self._profile = Profile(options["profile"]) self._satellites_xml_path = options.get(self._profile.value)["data_dir_path"] + "satellites.xml" self._picons_dir_path = options.get(self._profile.value)["picons_dir_path"] - self._services_view = view + self._services_view = srv_view + self._fav_view = fav_view self._action = action self._old_service = None self._services = services @@ -343,6 +344,7 @@ class ServiceDetailsDialog: if self._old_service.picon_id != service.picon_id: self.update_picon_name(self._old_service.picon_id, service.picon_id) self._current_model.set(self._current_itr, {i: v for i, v in enumerate(service)}) + self.update_fav_view(self._old_service, service) self._old_service = service def update_bouquets(self, fav_id, old_fav_id): @@ -355,6 +357,19 @@ class ServiceDetailsDialog: for i in indexes: bq[i] = fav_id + @run_idle + def update_fav_view(self, old_service, new_service): + model = self._fav_view.get_model() + for row in filter(lambda r: old_service.fav_id == r[7], model): + model.set(row.iter, {1: new_service.coded, + 2: new_service.service, + 3: new_service.locked, + 4: new_service.hide, + 5: new_service.service_type, + 6: new_service.pos, + 7: new_service.fav_id, + 8: new_service.picon}) + def update_picon_name(self, old_name, new_name): for file_name in os.listdir(self._picons_dir_path): if file_name == old_name: @@ -372,7 +387,7 @@ class ServiceDetailsDialog: freq, rate, pol, fec, system, pos = self.get_transponder_values() return Service(flags_cas=self.get_flags(), transponder_type="s", - coded=self._old_service.coded, + coded=CODED_ICON if self._cas_entry.get_text() else None, service=self._name_entry.get_text(), locked=self._old_service.locked, hide=HIDE_ICON if self._hide_check_button.get_active() else None,