diff --git a/gtk/tr-core.c b/gtk/tr-core.c index 836dcf320..ccf44e784 100644 --- a/gtk/tr-core.c +++ b/gtk/tr-core.c @@ -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); + { + 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_uint64 (sa->uploadedEver, sb->uploadedEver); - if (!ret) - ret = compare_by_queue (m, a, b, user_data); + ret = compare_by_activity (m, a, b, user_data); return ret; } diff --git a/qt/torrent-filter.cc b/qt/torrent-filter.cc index f53f519a3..e5eecc188 100644 --- a/qt/torrent-filter.cc +++ b/qt/torrent-filter.cc @@ -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() );