mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 04:18:39 +00:00
#671 "torrent queuing" -- modify the queue implementation s.t. every torrent has a queuePosition, even if it's not currently in the queue.
This commit is contained in:
@@ -233,6 +233,7 @@ Prefs._SortMethod = 'sort_method';
|
||||
Prefs._SortByAge = 'age';
|
||||
Prefs._SortByActivity = 'activity';
|
||||
Prefs._SortByName = 'name';
|
||||
Prefs._SortByQueue = 'queue_order';
|
||||
Prefs._SortByProgress = 'percent_completed';
|
||||
Prefs._SortByRatio = 'ratio';
|
||||
Prefs._SortByState = 'state';
|
||||
|
||||
@@ -252,7 +252,8 @@ Torrent.prototype =
|
||||
isSeeding: function() { return this.state() == Torrent._StatusSeed; },
|
||||
name: function() { return this._name; },
|
||||
queuePosition: function() { return this._queue_position; },
|
||||
isQueued: function() { return this.queuePosition() >= 0; },
|
||||
isQueued: function() { return ( this.state() == Torrent._StatusSeedWait )
|
||||
|| ( this.state() == Torrent._StatusDownloadWait ); },
|
||||
webseedsSendingToUs: function() { return this._webseeds_sending_to_us; },
|
||||
peersSendingToUs: function() { return this._peers_sending_to_us; },
|
||||
peersGettingFromUs: function() { return this._peers_getting_from_us; },
|
||||
@@ -272,9 +273,9 @@ Torrent.prototype =
|
||||
case Torrent._StatusStopped: return this.isFinished() ? 'Seeding complete' : 'Paused';
|
||||
case Torrent._StatusCheckWait: return 'Waiting to verify local data';
|
||||
case Torrent._StatusCheck: return 'Verifying local data';
|
||||
case Torrent._StatusDownloadWait: return 'Waiting to download #' + (this.queuePosition()+1);
|
||||
case Torrent._StatusDownloadWait: return 'Waiting to download';
|
||||
case Torrent._StatusDownload: return 'Downloading';
|
||||
case Torrent._StatusSeedWait: return 'Waiting to seed #' + (this.queuePosition()+1);
|
||||
case Torrent._StatusSeedWait: return 'Waiting to seed';
|
||||
case Torrent._StatusSeed: return 'Seeding';
|
||||
default: return 'error';
|
||||
}
|
||||
@@ -770,17 +771,7 @@ Torrent.compareByName = function( a, b ) {
|
||||
/** Helper function for sortTorrents(). */
|
||||
Torrent.compareByQueue = function( a, b )
|
||||
{
|
||||
var a_is_queued = a.isQueued( );
|
||||
var b_is_queued = b.isQueued( );
|
||||
if( a_is_queued != b_is_queued )
|
||||
return a_is_queued ? -1 : 1;
|
||||
|
||||
var a_pos = a.queuePosition( );
|
||||
var b_pos = b.queuePosition( );
|
||||
if( a_pos != b_pos )
|
||||
return a_pos - b_pos;
|
||||
|
||||
return Torrent.compareByName( a, b );
|
||||
return a.queuePosition( ) - b.queuePosition();
|
||||
};
|
||||
|
||||
/** Helper function for sortTorrents(). */
|
||||
@@ -846,6 +837,9 @@ Torrent.sortTorrents = function( torrents, sortMethod, sortDirection )
|
||||
case Prefs._SortByAge:
|
||||
torrents.sort( this.compareByAge );
|
||||
break;
|
||||
case Prefs._SortByQueue:
|
||||
torrents.sort( this.compareByQueue );
|
||||
break;
|
||||
case Prefs._SortByProgress:
|
||||
torrents.sort( this.compareByProgress );
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user