Author: andar

Revision: 5866

Log:
        Fix #215 ETA sort order

Diff:
Modified: branches/1.2_RC/ChangeLog
===================================================================
--- branches/1.2_RC/ChangeLog   2009-10-24 03:47:35 UTC (rev 5865)
+++ branches/1.2_RC/ChangeLog   2009-10-24 04:56:10 UTC (rev 5866)
@@ -6,6 +6,7 @@
        * Fix 'autostart localhost if needed' option
        * Fix starting plugins when the pluginmanager is started
        * Fix #799 translate connection status
+       * Fix #215 ETA sort order
 
 ==== Core ====
        * Fix saving torrent state on fresh configs

Modified: branches/1.2_RC/deluge/ui/gtkui/torrentview.py
===================================================================
--- branches/1.2_RC/deluge/ui/gtkui/torrentview.py      2009-10-24 03:47:35 UTC 
(rev 5865)
+++ branches/1.2_RC/deluge/ui/gtkui/torrentview.py      2009-10-24 04:56:10 UTC 
(rev 5866)
@@ -133,6 +133,20 @@
     if v2 > v1:
         return -1
 
+def eta_column_sort(model, iter1, iter2, data):
+    v1 = model[iter1][data]
+    v2 = model[iter2][data]
+    if v1 == v2:
+        return 0
+    if v1 == 0:
+        return 1
+    if v2 == 0:
+        return -1
+    if v1 > v2:
+        return 1
+    if v2 > v1:
+        return -1
+        
 class TorrentView(listview.ListView, component.Component):
     """TorrentView handles the listing of torrents."""
     def __init__(self):
@@ -190,7 +204,8 @@
         self.add_func_column(_("ETA"),
                                             listview.cell_data_time,
                                             [int],
-                                            status_field=["eta"])
+                                            status_field=["eta"],
+                                            sort_func=eta_column_sort)
         self.add_func_column(_("Ratio"),
                                             listview.cell_data_ratio,
                                             [float],

Modified: trunk/deluge/ui/gtkui/torrentview.py
===================================================================
--- trunk/deluge/ui/gtkui/torrentview.py        2009-10-24 03:47:35 UTC (rev 
5865)
+++ trunk/deluge/ui/gtkui/torrentview.py        2009-10-24 04:56:10 UTC (rev 
5866)
@@ -133,6 +133,20 @@
     if v2 > v1:
         return -1
 
+def eta_column_sort(model, iter1, iter2, data):
+    v1 = model[iter1][data]
+    v2 = model[iter2][data]
+    if v1 == v2:
+        return 0
+    if v1 == 0:
+        return 1
+    if v2 == 0:
+        return -1
+    if v1 > v2:
+        return 1
+    if v2 > v1:
+        return -1
+        
 class TorrentView(listview.ListView, component.Component):
     """TorrentView handles the listing of torrents."""
     def __init__(self):
@@ -190,7 +204,8 @@
         self.add_func_column(_("ETA"),
                                             listview.cell_data_time,
                                             [int],
-                                            status_field=["eta"])
+                                            status_field=["eta"],
+                                            sort_func=eta_column_sort)
         self.add_func_column(_("Ratio"),
                                             listview.cell_data_ratio,
                                             [float],



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to