Browse Source

Fix queue sorting order fixes #1120

adaptive-webui-19844
alfrix 11 years ago
parent
commit
85cfe464f9
  1. 28
      src/transferlistsortmodel.h

28
src/transferlistsortmodel.h

@ -66,16 +66,26 @@ protected:
if (!vR.isValid()) return true; if (!vR.isValid()) return true;
return vL < vR; return vL < vR;
} else if (sortColumn() == TorrentModelItem::TR_PEERS || sortColumn() == TorrentModelItem::TR_SEEDS) { }
int left_active = sourceModel()->data(left).toInt(); else if (sortColumn() == TorrentModelItem::TR_PRIORITY) {
int left_total = sourceModel()->data(left, Qt::UserRole).toInt(); int vL = sourceModel()->data(left).toInt();
int right_active = sourceModel()->data(right).toInt(); int vR = sourceModel()->data(right).toInt();
int right_total = sourceModel()->data(right, Qt::UserRole).toInt();
//finished torrents should be last
if (vL == -1) return false;
if (vR == -1) return true;
return vL < vR;
}
else if (sortColumn() == TorrentModelItem::TR_PEERS || sortColumn() == TorrentModelItem::TR_SEEDS) {
int left_active = sourceModel()->data(left).toInt();
int left_total = sourceModel()->data(left, Qt::UserRole).toInt();
int right_active = sourceModel()->data(right).toInt();
int right_total = sourceModel()->data(right, Qt::UserRole).toInt();
// Active peers/seeds take precedence over total peers/seeds. // Active peers/seeds take precedence over total peers/seeds.
if (left_active == right_active) if (left_active == right_active)
return (left_total < right_total); return (left_total < right_total);
else return (left_active < right_active); else return (left_active < right_active);
} }
return QSortFilterProxyModel::lessThan(left, right); return QSortFilterProxyModel::lessThan(left, right);
} }

Loading…
Cancel
Save