little improvements for rename

This commit is contained in:
DYefremov
2018-10-26 19:28:40 +03:00
parent 4210c44ee9
commit 0db2080e2b
2 changed files with 6 additions and 4 deletions

View File

@@ -1465,8 +1465,8 @@ class MainAppWindow:
data = model[paths][:]
cur_name, srv_type, fav_id = data[2], data[5], data[7]
if srv_type == BqServiceType.IPTV.name:
show_dialog(DialogType.ERROR, self._main_window, "This item is not allowed to edit!")
if srv_type == BqServiceType.IPTV.name or srv_type == BqServiceType.MARKER.name:
show_dialog(DialogType.ERROR, self._main_window, "This action is not allowed in current context!")
return
response = show_dialog(DialogType.INPUT, self._main_window, cur_name)

View File

@@ -161,8 +161,10 @@ def rename(view, parent_window, target, fav_view=None, service_view=None, servic
old_srv = services.get(f_id, None)
if old_srv:
if srv_type == BqServiceType.IPTV.name or srv_type == BqServiceType.MARKER.name:
old_name = old_srv.service
new_fav_id = f_id.replace(old_name.strip(), srv_name.strip(), 2)
l, sep, r = f_id.partition("#DESCRIPTION")
old_name = old_srv.service.strip()
new_name = srv_name.strip()
new_fav_id = "".join((new_name.join(l.rsplit(old_name, 1)), sep, new_name.join(r.rsplit(old_name, 1))))
services[f_id] = old_srv._replace(service=srv_name, fav_id=new_fav_id)
else:
services[f_id] = old_srv._replace(service=srv_name)