mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-23 05:44:45 -04:00
Improved total file size and a small bug with a comma in TB string of file size 2 CLEANED CODE
This commit is contained in:
parent
e3d832cfd1
commit
ddff9f5358
2 changed files with 35 additions and 23 deletions
|
@ -391,34 +391,46 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||||
switch(coln)
|
switch(coln)
|
||||||
{
|
{
|
||||||
case 0: {
|
case 0: {
|
||||||
SharedDirStats stats ;
|
SharedDirStats stats ;
|
||||||
QString res ;
|
QString res ;
|
||||||
|
|
||||||
if(RemoteMode)
|
if(RemoteMode)
|
||||||
{
|
{
|
||||||
res = QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
res = QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||||
rsFiles->getSharedDirStatistics(details.id,stats) ;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res = tr("My files");
|
||||||
|
}
|
||||||
|
return res ;
|
||||||
}
|
}
|
||||||
else
|
case 1: {
|
||||||
{
|
SharedDirStats stats ;
|
||||||
res = tr("My files");
|
QString res ;
|
||||||
rsFiles->getSharedDirStatistics(rsPeers->getOwnId(),stats) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(stats.total_number_of_files > 0)
|
if(RemoteMode)
|
||||||
res += " - " + QString::number(stats.total_number_of_files) + " files, " + misc::friendlyUnit(stats.total_shared_size) ;
|
{
|
||||||
|
//res = QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||||
|
rsFiles->getSharedDirStatistics(details.id,stats) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//res = tr("My files");
|
||||||
|
rsFiles->getSharedDirStatistics(rsPeers->getOwnId(),stats) ;
|
||||||
|
}
|
||||||
|
|
||||||
return res ;
|
if(stats.total_number_of_files > 0)
|
||||||
}
|
res += QString::number(stats.total_number_of_files) + " files, " + misc::friendlyUnit(stats.total_shared_size) ;
|
||||||
|
|
||||||
case 1:
|
return res ;
|
||||||
return QString() ;
|
}
|
||||||
case 2: if(!isNewerThanEpoque(details.max_mtime))
|
case 2: if(!isNewerThanEpoque(details.max_mtime))
|
||||||
return QString();
|
return QString();
|
||||||
else
|
|
||||||
return misc::timeRelativeToNow(details.max_mtime);
|
|
||||||
|
|
||||||
default:
|
else
|
||||||
|
return misc::timeRelativeToNow(details.max_mtime);
|
||||||
|
|
||||||
|
default:
|
||||||
return QString() ;
|
return QString() ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ QString misc::friendlyUnit(float val)
|
||||||
if(val < 0) {
|
if(val < 0) {
|
||||||
return tr("Unknown", "Unknown (size)");
|
return tr("Unknown", "Unknown (size)");
|
||||||
}
|
}
|
||||||
const QString units[5] = {tr(" B", "bytes"), tr(" KB", "kilobytes (1024 bytes)"), tr(" MB", "megabytes (1024 kilobytes)"), tr(" GB", "gigabytes (1024 megabytes)"), tr(" TB,", "terabytes (1024 gigabytes)") };
|
const QString units[5] = {tr(" B", "bytes"), tr(" KB", "kilobytes (1024 bytes)"), tr(" MB", "megabytes (1024 kilobytes)"), tr(" GB", "gigabytes (1024 megabytes)"), tr(" TB", "terabytes (1024 gigabytes)") };
|
||||||
for(unsigned int i=0; i<5; ++i) {
|
for(unsigned int i=0; i<5; ++i) {
|
||||||
if (val < 1024.) {
|
if (val < 1024.) {
|
||||||
return QString(QByteArray::number(val, 'f', 1)) + units[i];
|
return QString(QByteArray::number(val, 'f', 1)) + units[i];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue