mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-20 07:08:30 +00:00
Fix #317, commit patch from Sadrul to properly hide torrents when their
status changes from the selected filter in the sidebar.
This commit is contained in:
parent
ce66e22099
commit
f872263a45
@ -99,24 +99,28 @@ class Signals(component.Component):
|
|||||||
|
|
||||||
def torrent_paused(self, torrent_id):
|
def torrent_paused(self, torrent_id):
|
||||||
log.debug("torrent_paused signal received..")
|
log.debug("torrent_paused signal received..")
|
||||||
|
component.get("TorrentView").mark_dirty(torrent_id)
|
||||||
component.get("TorrentView").update()
|
component.get("TorrentView").update()
|
||||||
component.get("ToolBar").update_buttons()
|
component.get("ToolBar").update_buttons()
|
||||||
component.get("MenuBar").update_menu()
|
component.get("MenuBar").update_menu()
|
||||||
|
|
||||||
def torrent_resumed(self, torrent_id):
|
def torrent_resumed(self, torrent_id):
|
||||||
log.debug("torrent_resumed signal received..")
|
log.debug("torrent_resumed signal received..")
|
||||||
|
component.get("TorrentView").mark_dirty(torrent_id)
|
||||||
component.get("TorrentView").update()
|
component.get("TorrentView").update()
|
||||||
component.get("ToolBar").update_buttons()
|
component.get("ToolBar").update_buttons()
|
||||||
component.get("MenuBar").update_menu()
|
component.get("MenuBar").update_menu()
|
||||||
|
|
||||||
def torrent_all_paused(self):
|
def torrent_all_paused(self):
|
||||||
log.debug("torrent_all_paused signal received..")
|
log.debug("torrent_all_paused signal received..")
|
||||||
|
component.get("TorrentView").mark_dirty()
|
||||||
component.get("TorrentView").update()
|
component.get("TorrentView").update()
|
||||||
component.get("ToolBar").update_buttons()
|
component.get("ToolBar").update_buttons()
|
||||||
component.get("MenuBar").update_menu()
|
component.get("MenuBar").update_menu()
|
||||||
|
|
||||||
def torrent_all_resumed(self):
|
def torrent_all_resumed(self):
|
||||||
log.debug("torrent_all_resumed signal received..")
|
log.debug("torrent_all_resumed signal received..")
|
||||||
|
component.get("TorrentView").mark_dirty()
|
||||||
component.get("TorrentView").update()
|
component.get("TorrentView").update()
|
||||||
component.get("ToolBar").update_buttons()
|
component.get("ToolBar").update_buttons()
|
||||||
component.get("MenuBar").update_menu()
|
component.get("MenuBar").update_menu()
|
||||||
@ -128,6 +132,7 @@ class Signals(component.Component):
|
|||||||
|
|
||||||
def torrent_queue_changed(self):
|
def torrent_queue_changed(self):
|
||||||
log.debug("torrent_queue_changed signal received..")
|
log.debug("torrent_queue_changed signal received..")
|
||||||
|
component.get("TorrentView").mark_dirty()
|
||||||
component.get("TorrentView").update()
|
component.get("TorrentView").update()
|
||||||
|
|
||||||
def torrent_resume_at_stop_ratio(self):
|
def torrent_resume_at_stop_ratio(self):
|
||||||
|
@ -120,6 +120,7 @@ class TorrentView(listview.ListView, component.Component):
|
|||||||
# Add the columns to the listview
|
# Add the columns to the listview
|
||||||
self.add_text_column("torrent_id", hidden=True)
|
self.add_text_column("torrent_id", hidden=True)
|
||||||
self.add_bool_column("filter", hidden=True)
|
self.add_bool_column("filter", hidden=True)
|
||||||
|
self.add_bool_column("dirty", hidden=True)
|
||||||
self.add_func_column("#", cell_data_queue, [int], status_field=["queue"])
|
self.add_func_column("#", cell_data_queue, [int], status_field=["queue"])
|
||||||
self.add_texticon_column(_("Name"), status_field=["state", "name"],
|
self.add_texticon_column(_("Name"), status_field=["state", "name"],
|
||||||
function=cell_data_statusicon)
|
function=cell_data_statusicon)
|
||||||
@ -252,8 +253,10 @@ class TorrentView(listview.ListView, component.Component):
|
|||||||
torrent_ids = []
|
torrent_ids = []
|
||||||
for row in self.liststore:
|
for row in self.liststore:
|
||||||
# Only add this torrent_id if it's not filtered
|
# Only add this torrent_id if it's not filtered
|
||||||
if row[self.columns["filter"].column_indices[0]] == True:
|
if row[self.columns["filter"].column_indices[0]] == True or \
|
||||||
|
row[self.columns["dirty"].column_indices[0]] == True :
|
||||||
torrent_ids.append(row[self.columns["torrent_id"].column_indices[0]])
|
torrent_ids.append(row[self.columns["torrent_id"].column_indices[0]])
|
||||||
|
row[self.columns["dirty"].column_indices[0]] = False
|
||||||
|
|
||||||
if torrent_ids == []:
|
if torrent_ids == []:
|
||||||
return
|
return
|
||||||
@ -266,13 +269,16 @@ class TorrentView(listview.ListView, component.Component):
|
|||||||
def update_filter(self):
|
def update_filter(self):
|
||||||
# Update the filter view
|
# Update the filter view
|
||||||
for row in self.liststore:
|
for row in self.liststore:
|
||||||
|
self.update_filter_row(row)
|
||||||
|
|
||||||
|
def update_filter_row(self, row):
|
||||||
filter_column = self.columns["filter"].column_indices[0]
|
filter_column = self.columns["filter"].column_indices[0]
|
||||||
# Create a function to create a new liststore with only the
|
# Create a function to create a new liststore with only the
|
||||||
# desired rows based on the filter.
|
# desired rows based on the filter.
|
||||||
field, condition = self.filter
|
field, condition = self.filter
|
||||||
if field == None and condition == None:
|
if field == None and condition == None:
|
||||||
row[filter_column] = True
|
row[filter_column] = True
|
||||||
continue
|
return
|
||||||
|
|
||||||
value = row[self.get_state_field_column(field)]
|
value = row[self.get_state_field_column(field)]
|
||||||
|
|
||||||
@ -327,7 +333,7 @@ class TorrentView(listview.ListView, component.Component):
|
|||||||
column_index.index(index)]]
|
column_index.index(index)]]
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
self.update_filter_row(row)
|
||||||
# Update the toolbar buttons just in case some state has changed
|
# Update the toolbar buttons just in case some state has changed
|
||||||
component.get("ToolBar").update_buttons()
|
component.get("ToolBar").update_buttons()
|
||||||
component.get("MenuBar").update_menu()
|
component.get("MenuBar").update_menu()
|
||||||
@ -365,6 +371,13 @@ class TorrentView(listview.ListView, component.Component):
|
|||||||
self.update_filter()
|
self.update_filter()
|
||||||
break
|
break
|
||||||
|
|
||||||
|
def mark_dirty(self, torrent_id = None):
|
||||||
|
for row in self.liststore:
|
||||||
|
if not torrent_id or row[0] == torrent_id:
|
||||||
|
log.debug("marking %s dirty", torrent_id)
|
||||||
|
row[self.columns["dirty"].column_indices[0]] = True
|
||||||
|
if torrent_id: break
|
||||||
|
|
||||||
def get_selected_torrent(self):
|
def get_selected_torrent(self):
|
||||||
"""Returns a torrent_id or None. If multiple torrents are selected,
|
"""Returns a torrent_id or None. If multiple torrents are selected,
|
||||||
it will return the torrent_id of the first one."""
|
it will return the torrent_id of the first one."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user