[PATCH 3/4] Build sorted models on top of filtered models to make column sorting work.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For some reason, doing it the other way around allows you to click on column
headers but there is no sorting that happens.
---
 iw/cleardisks_gui.py |   42 +++++++++++++++++++++---------------------
 iw/filter_gui.py     |    8 ++++----
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/iw/cleardisks_gui.py b/iw/cleardisks_gui.py
index bab9c51..c00e2ed 100644
--- a/iw/cleardisks_gui.py
+++ b/iw/cleardisks_gui.py
@@ -99,15 +99,15 @@ class ClearDisksWindow (InstallWindow):
 
         # The left view shows all the drives that will just be mounted, but
         # can still be moved to the right hand side.
-        self.leftSortedModel = gtk.TreeModelSort(self.store)
         self.leftFilteredModel = self.store.filter_new()
-        self.leftTreeView = gtk.TreeView(self.leftFilteredModel)
+        self.leftSortedModel = gtk.TreeModelSort(self.leftFilteredModel)
+        self.leftTreeView = gtk.TreeView(self.leftSortedModel)
 
         self.leftFilteredModel.set_visible_func(lambda model, iter, view: model.get_value(iter, self.leftVisible), self.leftTreeView)
 
         self.leftScroll.add(self.leftTreeView)
 
-        self.leftDS = DeviceSelector(self.store, self.leftFilteredModel,
+        self.leftDS = DeviceSelector(self.store, self.leftSortedModel,
                                      self.leftTreeView, visible=self.leftVisible,
                                      active=self.leftActive)
         self.leftDS.createMenu()
@@ -118,15 +118,15 @@ class ClearDisksWindow (InstallWindow):
         self.leftDS.addColumn(_("Serial Number"), 9, displayed=False)
 
         # The right view show all the drives that will be wiped during install.
-        self.rightSortedModel = gtk.TreeModelSort(self.store)
         self.rightFilteredModel = self.store.filter_new()
-        self.rightTreeView = gtk.TreeView(self.rightFilteredModel)
+        self.rightSortedModel = gtk.TreeModelSort(self.rightFilteredModel)
+        self.rightTreeView = gtk.TreeView(self.rightSortedModel)
 
         self.rightFilteredModel.set_visible_func(lambda model, iter, view: model.get_value(iter, self.rightVisible), self.rightTreeView)
 
         self.rightScroll.add(self.rightTreeView)
 
-        self.rightDS = DeviceSelector(self.store, self.rightFilteredModel,
+        self.rightDS = DeviceSelector(self.store, self.rightSortedModel,
                                       self.rightTreeView, visible=self.rightVisible,
                                       active=self.rightActive)
         self.rightDS.createSelectionCol(title=_("Boot"), radioButton=True)
@@ -168,7 +168,7 @@ class ClearDisksWindow (InstallWindow):
         return self.vbox
 
     def _add_clicked(self, widget, *args, **kwargs):
-        (filteredModel, pathlist) = self.leftTreeView.get_selection().get_selected_rows()
+        (sortedModel, pathlist) = self.leftTreeView.get_selection().get_selected_rows()
 
         if not pathlist:
             return
@@ -181,15 +181,15 @@ class ClearDisksWindow (InstallWindow):
             setFirstActive = False
 
         for path in reversed(pathlist):
-            filteredIter = filteredModel.get_iter(path)
-            if not filteredIter:
+            sortedIter = sortedModel.get_iter(path)
+            if not sortedIter:
                 continue
 
-            sortedIter = self.leftFilteredModel.convert_iter_to_child_iter(filteredIter)
+            filteredIter = self.leftSortedModel.convert_iter_to_child_iter(sortedIter)
 
-            self.store.set_value(sortedIter, self.leftVisible, False)
-            self.store.set_value(sortedIter, self.rightVisible, True)
-            self.store.set_value(sortedIter, self.rightActive, False)
+            self.store.set_value(filteredIter, self.leftVisible, False)
+            self.store.set_value(filteredIter, self.rightVisible, True)
+            self.store.set_value(filteredIter, self.rightActive, False)
 
         if setFirstActive:
             i = 0
@@ -203,7 +203,7 @@ class ClearDisksWindow (InstallWindow):
         self.rightFilteredModel.refilter()
 
     def _remove_clicked(self, widget, *args, **kwargs):
-        (filteredModel, pathlist) = self.rightTreeView.get_selection().get_selected_rows()
+        (sortedModel, pathlist) = self.rightTreeView.get_selection().get_selected_rows()
 
         if not pathlist:
             return
@@ -211,20 +211,20 @@ class ClearDisksWindow (InstallWindow):
         setFirstActive = False
 
         for path in reversed(pathlist):
-            filteredIter = filteredModel.get_iter(path)
-            if not filteredIter:
+            sortedIter = sortedModel.get_iter(path)
+            if not sortedIter:
                 continue
 
-            sortedIter = self.rightFilteredModel.convert_iter_to_child_iter(filteredIter)
+            filteredIter = self.rightSortedModel.convert_iter_to_child_iter(sortedIter)
 
             # If we're removing a row that was checked, try to set the first
             # visible one to active after the selection is applied.
-            if self.store.get_value(sortedIter, self.rightActive):
+            if self.store.get_value(filteredIter, self.rightActive):
                 setFirstActive = True
 
-            self.store.set_value(sortedIter, self.leftVisible, True)
-            self.store.set_value(sortedIter, self.rightVisible, False)
-            self.store.set_value(sortedIter, self.rightActive, False)
+            self.store.set_value(filteredIter, self.leftVisible, True)
+            self.store.set_value(filteredIter, self.rightVisible, False)
+            self.store.set_value(filteredIter, self.rightActive, False)
 
         if self.rightDS.getNVisible() > 0 and setFirstActive:
             i = 0
diff --git a/iw/filter_gui.py b/iw/filter_gui.py
index 5c13787..fedb370 100644
--- a/iw/filter_gui.py
+++ b/iw/filter_gui.py
@@ -319,16 +319,16 @@ class NotebookPage(object):
         # Every page needs a ScrolledWindow to display the results in.
         self.scroll = xml.get_widget("%sScroll" % name)
 
-        self.sortedModel = gtk.TreeModelSort(store)
         self.filteredModel = store.filter_new()
-        self.treeView = gtk.TreeView(self.filteredModel)
+        self.sortedModel = gtk.TreeModelSort(self.filteredModel)
+        self.treeView = gtk.TreeView(self.sortedModel)
 
         self.scroll.add(self.treeView)
 
         self.cb = cb
-        self.cb.model = self.filteredModel
+        self.cb.model = self.sortedModel
 
-        self.ds = DeviceSelector(store, self.filteredModel, self.treeView,
+        self.ds = DeviceSelector(store, self.sortedModel, self.treeView,
                                  visible=VISIBLE_COL, active=ACTIVE_COL)
         self.ds.createMenu()
         self.ds.createSelectionCol(toggledCB=self.cb.deviceToggled)
-- 
1.6.5.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux