allow recreating filter-model after adding columns

This commit is contained in:
Martijn Voncken 2008-07-12 05:46:21 +00:00
parent a462abb5f3
commit f2120b1131
1 changed files with 14 additions and 7 deletions

View File

@ -171,13 +171,8 @@ class TorrentView(listview.ListView, component.Component):
# Set filter to None for now # Set filter to None for now
self.filter = (None, None) self.filter = (None, None)
# Set the liststore filter column self.create_model_filter()
model_filter = self.liststore.filter_new()
model_filter.set_visible_column(
self.columns["filter"].column_indices[0])
self.model_filter = gtk.TreeModelSort(model_filter)
self.treeview.set_model(self.model_filter)
### Connect Signals ### ### Connect Signals ###
# Connect to the 'button-press-event' to know when to bring up the # Connect to the 'button-press-event' to know when to bring up the
# torrent menu popup. # torrent menu popup.
@ -194,6 +189,18 @@ class TorrentView(listview.ListView, component.Component):
# the session so we can add them to our list. # the session so we can add them to our list.
client.get_session_state(self._on_session_state) client.get_session_state(self._on_session_state)
def create_model_filter(self):
"""create new filter-model
must be called after listview.create_new_liststore
"""
# Set the liststore filter column
model_filter = self.liststore.filter_new()
model_filter.set_visible_column(
self.columns["filter"].column_indices[0])
self.model_filter = gtk.TreeModelSort(model_filter)
self.treeview.set_model(self.model_filter)
def _on_session_state(self, state): def _on_session_state(self, state):
for torrent_id in state: for torrent_id in state:
self.add_row(torrent_id) self.add_row(torrent_id)