mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-12 04:24:27 +00:00
[#2698] [GTKUI] Fix corrupted column indexes when using multiple col_types
* Ensures that removing multiple items from liststore_columns list does not affect the index.
This commit is contained in:
parent
2c1a863ffb
commit
dd6e7ec490
@ -488,8 +488,8 @@ class ListView:
|
||||
# Delete the column
|
||||
del self.columns[header]
|
||||
self.column_index.remove(header)
|
||||
# Shift the column_indices values of those columns effected by the
|
||||
# removal. Any column_indices > the one removed.
|
||||
# Shift the column_indices values of those columns affected by the
|
||||
# removal. Any column_indices > the one removed.
|
||||
for column in self.columns.values():
|
||||
if column.column_indices[0] > column_indices[0]:
|
||||
# We need to shift this column_indices
|
||||
@ -499,7 +499,7 @@ class ListView:
|
||||
self.update_treeview_column(column.name, add=False)
|
||||
|
||||
# Remove from the liststore columns list
|
||||
for index in column_indices:
|
||||
for index in sorted(column_indices, reverse=True):
|
||||
del self.liststore_columns[index]
|
||||
# Create a new liststore
|
||||
self.create_new_liststore()
|
||||
|
@ -30,6 +30,8 @@ class TorrentviewTestCase(unittest.TestCase):
|
||||
self.assertEquals(self.torrentview.liststore_columns, default_liststore_columns)
|
||||
|
||||
self.assertEquals(self.torrentview.columns["Save Path"].column_indices, [26])
|
||||
|
||||
# Add a text column
|
||||
test_col = "Test column"
|
||||
self.torrentview.add_text_column(test_col, status_field=["label"])
|
||||
self.assertEquals(len(self.torrentview.liststore_columns), 28)
|
||||
@ -37,6 +39,7 @@ class TorrentviewTestCase(unittest.TestCase):
|
||||
self.assertEquals(self.torrentview.column_index[-1], test_col)
|
||||
self.assertEquals(self.torrentview.columns[test_col].column_indices, [27])
|
||||
|
||||
# Add a second text column
|
||||
test_col2 = "Test column2"
|
||||
self.torrentview.add_text_column(test_col2, status_field=["label2"])
|
||||
self.assertEquals(len(self.torrentview.liststore_columns), 29)
|
||||
@ -44,8 +47,24 @@ class TorrentviewTestCase(unittest.TestCase):
|
||||
self.assertEquals(self.torrentview.column_index[-1], test_col2)
|
||||
self.assertEquals(self.torrentview.columns[test_col2].column_indices, [28])
|
||||
|
||||
# Remove column
|
||||
self.torrentview.remove_column(test_col)
|
||||
self.assertEquals(len(self.torrentview.liststore_columns), 28)
|
||||
self.assertEquals(len(self.torrentview.column_index), 23)
|
||||
self.assertEquals(self.torrentview.column_index[-1], test_col2)
|
||||
self.assertEquals(self.torrentview.columns[test_col2].column_indices, [27])
|
||||
|
||||
# Add a column with multiple column types
|
||||
test_col3 = "Test column3"
|
||||
self.torrentview.add_progress_column(test_col3, status_field=["progress", "label3"], col_types=[float, str])
|
||||
self.assertEquals(len(self.torrentview.liststore_columns), 30)
|
||||
self.assertEquals(len(self.torrentview.column_index), 24)
|
||||
self.assertEquals(self.torrentview.column_index[-1], test_col3)
|
||||
self.assertEquals(self.torrentview.columns[test_col3].column_indices, [28, 29])
|
||||
|
||||
# Remove multiple column-types column
|
||||
self.torrentview.remove_column(test_col3)
|
||||
self.assertEquals(len(self.torrentview.liststore_columns), 28)
|
||||
self.assertEquals(len(self.torrentview.column_index), 23)
|
||||
self.assertEquals(self.torrentview.column_index[-1], test_col2)
|
||||
self.assertEquals(self.torrentview.columns[test_col2].column_indices, [27])
|
||||
|
Loading…
x
Reference in New Issue
Block a user