]> granicus.if.org Git - transmission/commitdiff
when sorting by activity and both torrents' upload and download speed is zero, use...
authorJordan Lee <jordan@transmissionbt.com>
Wed, 30 Jan 2013 00:20:51 +0000 (00:20 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Wed, 30 Jan 2013 00:20:51 +0000 (00:20 +0000)
gtk/tr-core.c
qt/torrent-filter.cc

index 836dcf32085252f539f6e1d7b39d9943971c7747..ccf44e784161a1889099de6c35f35bb60d4e19dd 100644 (file)
@@ -468,7 +468,6 @@ compare_by_activity (GtkTreeModel * m,
 {
   int ret = 0;
   tr_torrent *ta, *tb;
-  const tr_stat *sa, *sb;
   double aUp, aDown, bUp, bDown;
 
   gtk_tree_model_get (m, a, MC_SPEED_UP, &aUp,
@@ -479,15 +478,19 @@ compare_by_activity (GtkTreeModel * m,
                             MC_SPEED_DOWN, &bDown,
                             MC_TORRENT, &tb,
                             -1);
-  sa = tr_torrentStatCached (ta);
-  sb = tr_torrentStatCached (tb);
+
+  ret = compare_double (aUp+aDown, bUp+bDown);
 
   if (!ret)
-    ret = compare_double (aUp+aDown, bUp+bDown);
-  if (!ret)
-    ret = compare_uint64 (sa->uploadedEver, sb->uploadedEver);
+    {
+      const tr_stat * const sa = tr_torrentStatCached (ta);
+      const tr_stat * const sb = tr_torrentStatCached (tb);
+      ret = compare_uint64 (sa->peersSendingToUs + sa->peersGettingFromUs,
+                            sb->peersSendingToUs + sb->peersGettingFromUs);
+    }
+
   if (!ret)
-    ret = compare_by_queue (m, a, b, user_data);
+    ret = compare_by_activity (m, a, b, user_data);
 
   return ret;
 }
index f53f519a34500556c22b413d4497dd72831bb246..e5eecc1884cab8354b1693d3bab0d80c487f97d3 100644 (file)
@@ -100,12 +100,14 @@ TorrentFilter :: lessThan( const QModelIndex& left, const QModelIndex& right ) c
             break;
         case SortMode :: SORT_BY_ACTIVITY:
             if( !val ) val = compare( a->downloadSpeed() + a->uploadSpeed(), b->downloadSpeed() + b->uploadSpeed() );
-            if( !val ) val = compare( a->uploadedEver(), b->uploadedEver() );
+            if( !val ) val = compare( a->peersWeAreUploadingTo() + a->webseedsWeAreDownloadingFrom(),
+                                      b->peersWeAreUploadingTo() + b->webseedsWeAreDownloadingFrom());
             // fall through
         case SortMode :: SORT_BY_STATE:
-            if( !val ) val = compare( a->hasError(), b->hasError() );
+            if( !val ) val = -compare( a->isPaused(), b->isPaused() );
             if( !val ) val = compare( a->getActivity(), b->getActivity() );
             if( !val ) val = -compare( a->queuePosition(), b->queuePosition() );
+            if( !val ) val = compare( a->hasError(), b->hasError() );
             // fall through
         case SortMode :: SORT_BY_PROGRESS:
             if( !val ) val = compare( a->percentComplete(), b->percentComplete() );