(trunk, T) #5072 "In the torrent list, show how many web seeds we're downloading from" -- made the Qt, GTK+, and web client text consistent

This commit is contained in:
Jordan Lee 2012-10-07 17:51:56 +00:00
parent f8f5fa930f
commit 7219f26dae
5 changed files with 59 additions and 29 deletions

View File

@ -1048,7 +1048,7 @@ getWebseedColumnNames( int column )
{
switch( column )
{
case WEBSEED_COL_URL: return _( "Webseeds" );
case WEBSEED_COL_URL: return _( "Web Seeds" );
case WEBSEED_COL_DOWNLOAD_RATE_DOUBLE:
case WEBSEED_COL_DOWNLOAD_RATE_STRING: return _( "Down" );
default: return "";

View File

@ -260,23 +260,38 @@ getStatusString( GString * gstr,
case TR_STATUS_DOWNLOAD:
{
if( tr_torrentHasMetadata( tor ) )
if( !tr_torrentHasMetadata( tor ) )
{
g_string_append_printf( gstr,
ngettext( "Downloading from %1$'d of %2$'d connected peer",
"Downloading from %1$'d of %2$'d connected peers",
st->webseedsSendingToUs + st->peersSendingToUs ),
st->webseedsSendingToUs + st->peersSendingToUs,
st->webseedsSendingToUs + st->peersConnected );
/* Downloading metadata from 2 peer(s) (50% done) */
g_string_append_printf( gstr, _("Downloading metadata from %1$'d %2$s (%3$d%% done)"),
st->peersConnected,
ngettext("peer","peers",st->peersConnected),
(int)(100.0*st->metadataPercentComplete) );
}
else if (st->peersSendingToUs && st->webseedsSendingToUs)
{
/* Downloading from 2 of 3 peer(s) and 2 webseed(s) */
g_string_append_printf (gstr, _("Downloading from %1$'d of %2$'d %3$s and %4$'d %5$s"),
st->peersSendingToUs,
st->peersConnected,
ngettext("peer","peers",st->peersSendingToUs),
st->webseedsSendingToUs,
ngettext("web seed","web seeds",st->webseedsSendingToUs));
}
else if (st->webseedsSendingToUs)
{
/* Downloading from 3 web seed(s) */
g_string_append_printf (gstr, _("Downloading from %1$'d %2$s"),
st->webseedsSendingToUs,
ngettext("web seed","web seeds",st->webseedsSendingToUs));
}
else
{
g_string_append_printf( gstr,
ngettext( "Downloading metadata from %1$'d peer (%2$d%% done)",
"Downloading metadata from %1$'d peers (%2$d%% done)",
st->peersConnected + st->webseedsSendingToUs ),
st->peersConnected + st->webseedsSendingToUs,
(int)(100.0*st->metadataPercentComplete) );
/* Downloading from 2 of 3 peer(s) */
g_string_append_printf (gstr, _("Downloading from %1$'d of %2$'d %3$s"),
st->peersSendingToUs,
st->peersConnected,
ngettext("peer","peers",st->peersSendingToUs));
}
break;
}

View File

@ -173,7 +173,7 @@ TorrentDelegate :: shortTransferString( const Torrent& tor ) const
static const QChar upArrow( 0x2191 );
static const QChar downArrow( 0x2193 );
const bool haveMeta( tor.hasMetadata( ) );
const bool haveDown( haveMeta && tor.peersWeAreDownloadingFrom( ) > 0 );
const bool haveDown( haveMeta && ((tor.webseedsWeAreDownloadingFrom()>0) || (tor.peersWeAreDownloadingFrom( )>0)) );
const bool haveUp( haveMeta && tor.peersWeAreUploadingTo( ) > 0 );
QString downStr, upStr, str;
@ -242,12 +242,16 @@ TorrentDelegate :: statusString( const Torrent& tor ) const
break;
case TR_STATUS_DOWNLOAD:
if( tor.hasMetadata( ) )
str = tr( "Downloading from %1 of %n connected peer(s)", 0, tor.connectedPeersAndWebseeds( ) )
.arg( tor.peersWeAreDownloadingFrom( ) );
else
if( !tor.hasMetadata() ) {
str = tr( "Downloading metadata from %n peer(s) (%1% done)", 0, tor.peersWeAreDownloadingFrom( ) )
.arg( Formatter::percentToString( 100.0 * tor.metadataPercentDone( ) ) );
} else {
/* it would be nicer for translation if this was all one string, but I don't see how to do multiple %n's in tr() */
str = tr( "Downloading from %1 of %n connected peer(s)", 0, tor.connectedPeersAndWebseeds( ) )
.arg( tor.peersWeAreDownloadingFrom( ) );
if (tor.webseedsWeAreDownloadingFrom())
str += tr(" and %n web seed(s)", "", tor.webseedsWeAreDownloadingFrom());
}
break;
case TR_STATUS_SEED:

View File

@ -282,7 +282,8 @@ class Torrent: public QObject
QDateTime dateCreated( ) const { return getDateTime( DATE_CREATED ); }
QDateTime manualAnnounceTime( ) const { return getDateTime( MANUAL_ANNOUNCE_TIME ); }
bool canManualAnnounce( ) const { return isReadyToTransfer() && (manualAnnounceTime()<=QDateTime::currentDateTime()); }
int peersWeAreDownloadingFrom( ) const { return getInt( PEERS_SENDING_TO_US ) + getInt( WEBSEEDS_SENDING_TO_US ); }
int peersWeAreDownloadingFrom( ) const { return getInt( PEERS_SENDING_TO_US ); }
int webseedsWeAreDownloadingFrom( ) const { return getInt( WEBSEEDS_SENDING_TO_US ); }
int peersWeAreUploadingTo( ) const { return getInt( PEERS_GETTING_FROM_US ); }
bool isUploading( ) const { return peersWeAreUploadingTo( ) > 0; }
int connectedPeers( ) const { return getInt( PEERS_CONNECTED ); }

View File

@ -148,31 +148,42 @@ TorrentRendererFull.prototype =
getPeerDetails: function(t)
{
var err, webseed_count;
var err,
peer_count,
webseed_count,
fmt = Transmission.fmt;
if ((err = t.getErrorMessage()))
return err;
if (t.isDownloading())
{
peer_count = t.getPeersConnected();
webseed_count = t.getWebseedsSendingToUs();
if (webseed_count)
if (webseed_count && peer_count)
{
// Downloading from 2 of 3 peer(s) and 2 webseed(s)
return [ 'Downloading from',
t.getPeersSendingToUs(),
'of',
t.getPeersConnected(),
'peers and',
Transmission.fmt.plural (webseed_count, 'webseed') ].join(' ');
fmt.plural (peer_count, 'peer'),
'and',
fmt.plural (webseed_count, 'web seed') ].join(' ');
}
else if (webseed_count)
{
// Downloading from 2 webseed(s)
return [ 'Downloading from',
fmt.plural (webseed_count, 'web seed') ].join(' ');
}
else
{
// Downloading from 2 of 3 peer(s)
return [ 'Downloading from',
t.getPeersSendingToUs(),
'of',
t.getPeersConnected(),
'peers' ].join(' ');
fmt.plural (peer_count, 'peer') ].join(' ');
}
}
@ -180,8 +191,7 @@ TorrentRendererFull.prototype =
return [ 'Seeding to',
t.getPeersGettingFromUs(),
'of',
t.getPeersConnected(),
'peers',
fmt.plural (t.getPeersConnected(), 'peer'),
'-',
TorrentRendererHelper.formatUL(t) ].join(' ');