mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-10 10:28:39 +00:00
Fix torrentview sorting to be persistent
This commit is contained in:
parent
7665f5394a
commit
6948c81d01
3 changed files with 32 additions and 10 deletions
|
@ -10,6 +10,7 @@ Deluge 0.9.07 - "1.0.0_RC7" (18 August 2008)
|
||||||
* Fix hiding the bottom pane when disabling all the tabs
|
* Fix hiding the bottom pane when disabling all the tabs
|
||||||
* Fix not showing new torrents if you don't use the All label first
|
* Fix not showing new torrents if you don't use the All label first
|
||||||
* Fix size units to be more accurate
|
* Fix size units to be more accurate
|
||||||
|
* Fix torrentview sorting to be persistent
|
||||||
|
|
||||||
Null:
|
Null:
|
||||||
* Fix #415 crash when using 'config-set' with no parameters
|
* Fix #415 crash when using 'config-set' with no parameters
|
||||||
|
|
|
@ -160,10 +160,15 @@ class ListView:
|
||||||
treeview_columns = self.treeview.get_columns()
|
treeview_columns = self.treeview.get_columns()
|
||||||
counter = 0
|
counter = 0
|
||||||
for column in treeview_columns:
|
for column in treeview_columns:
|
||||||
|
sort = None
|
||||||
|
id, order = self.treeview.get_model().get_sort_column_id()
|
||||||
|
|
||||||
|
if self.get_column_name(id) == column.get_title():
|
||||||
|
sort = id
|
||||||
# Append a new column state to the state list
|
# Append a new column state to the state list
|
||||||
state.append(ListViewColumnState(column.get_title(), counter,
|
state.append(ListViewColumnState(column.get_title(), counter,
|
||||||
column.get_width(), column.get_visible(),
|
column.get_width(), column.get_visible(),
|
||||||
column.get_sort_indicator(), int(column.get_sort_order())))
|
sort, int(column.get_sort_order())))
|
||||||
# Increase the counter because this is how we determine position
|
# Increase the counter because this is how we determine position
|
||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
|
@ -211,6 +216,12 @@ class ListView:
|
||||||
else:
|
else:
|
||||||
return self.columns[name].column_indices[0]
|
return self.columns[name].column_indices[0]
|
||||||
|
|
||||||
|
def get_column_name(self, index):
|
||||||
|
"""Get the header name for a liststore column index"""
|
||||||
|
for key, value in self.columns.items():
|
||||||
|
if index in value.column_indices:
|
||||||
|
return key
|
||||||
|
|
||||||
def get_state_field_column(self, field):
|
def get_state_field_column(self, field):
|
||||||
"""Returns the column number for the state field"""
|
"""Returns the column number for the state field"""
|
||||||
for column in self.columns.keys():
|
for column in self.columns.keys():
|
||||||
|
@ -285,9 +296,16 @@ class ListView:
|
||||||
if self.liststore is not None:
|
if self.liststore is not None:
|
||||||
self.liststore.foreach(copy_row, (new_list, self.columns))
|
self.liststore.foreach(copy_row, (new_list, self.columns))
|
||||||
|
|
||||||
|
sort_column = None
|
||||||
|
if self.treeview.get_model():
|
||||||
|
# Save the liststore filter column
|
||||||
|
sort_column = self.treeview.get_model().get_sort_column_id()
|
||||||
|
|
||||||
self.liststore = new_list
|
self.liststore = new_list
|
||||||
self.treeview.set_model(self.liststore)
|
self.treeview.set_model(self.liststore)
|
||||||
|
|
||||||
|
if sort_column and sort_column != (None, None):
|
||||||
|
self.treeview.get_model().set_sort_column_id(*sort_column)
|
||||||
return
|
return
|
||||||
|
|
||||||
def remove_column(self, header):
|
def remove_column(self, header):
|
||||||
|
@ -384,7 +402,7 @@ class ListView:
|
||||||
self.columns[header].column_indices[text])
|
self.columns[header].column_indices[text])
|
||||||
elif column_type == None:
|
elif column_type == None:
|
||||||
return
|
return
|
||||||
|
|
||||||
column.set_sort_column_id(self.columns[header].column_indices[sortid])
|
column.set_sort_column_id(self.columns[header].column_indices[sortid])
|
||||||
column.set_clickable(True)
|
column.set_clickable(True)
|
||||||
column.set_resizable(True)
|
column.set_resizable(True)
|
||||||
|
@ -401,8 +419,9 @@ class ListView:
|
||||||
if column_state.width > 0:
|
if column_state.width > 0:
|
||||||
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
|
||||||
column.set_fixed_width(column_state.width)
|
column.set_fixed_width(column_state.width)
|
||||||
column.set_sort_indicator(column_state.sort)
|
|
||||||
column.set_sort_order(column_state.sort_order)
|
if column_state.sort is not None and column_state.sort > -1:
|
||||||
|
self.treeview.get_model().set_sort_column_id(column_state.sort, column_state.sort_order)
|
||||||
column.set_visible(column_state.visible)
|
column.set_visible(column_state.visible)
|
||||||
position = column_state.position
|
position = column_state.position
|
||||||
|
|
||||||
|
|
|
@ -164,13 +164,10 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
listview.cell_data_ratio,
|
listview.cell_data_ratio,
|
||||||
[float],
|
[float],
|
||||||
status_field=["distributed_copies"])
|
status_field=["distributed_copies"])
|
||||||
|
|
||||||
# Set default sort column to #
|
|
||||||
self.liststore.set_sort_column_id(self.get_column_index("#"), gtk.SORT_ASCENDING)
|
|
||||||
|
|
||||||
# Set filter to None for now
|
# Set filter to None for now
|
||||||
self.filter = (None, None)
|
self.filter = (None, None)
|
||||||
|
|
||||||
self.create_model_filter()
|
self.create_model_filter()
|
||||||
|
|
||||||
### Connect Signals ###
|
### Connect Signals ###
|
||||||
|
@ -195,13 +192,18 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
"""create new filter-model
|
"""create new filter-model
|
||||||
must be called after listview.create_new_liststore
|
must be called after listview.create_new_liststore
|
||||||
"""
|
"""
|
||||||
|
sort_column = None
|
||||||
|
if self.treeview.get_model():
|
||||||
|
# Save the liststore filter column
|
||||||
|
sort_column = self.treeview.get_model().get_sort_column_id()
|
||||||
# Set the liststore filter column
|
# Set the liststore filter column
|
||||||
model_filter = self.liststore.filter_new()
|
model_filter = self.liststore.filter_new()
|
||||||
model_filter.set_visible_column(
|
model_filter.set_visible_column(
|
||||||
self.columns["filter"].column_indices[0])
|
self.columns["filter"].column_indices[0])
|
||||||
self.model_filter = gtk.TreeModelSort(model_filter)
|
self.model_filter = gtk.TreeModelSort(model_filter)
|
||||||
self.treeview.set_model(self.model_filter)
|
self.treeview.set_model(self.model_filter)
|
||||||
|
if sort_column and sort_column != (None, None):
|
||||||
|
self.treeview.get_model().set_sort_column_id(*sort_column)
|
||||||
|
|
||||||
def _on_session_state(self, state):
|
def _on_session_state(self, state):
|
||||||
for torrent_id in state:
|
for torrent_id in state:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue