Qt: Add GUI view of peer information. #4133

This commit is contained in:
Ashley Holman
2014-05-23 12:09:59 -05:00
parent 9d97e83bf6
commit 65f78a111f
10 changed files with 870 additions and 12 deletions

View File

@@ -11,6 +11,7 @@
#include "core.h"
#include "init.h"
#include "protocol.h"
#include "util.h"
#ifdef WIN32
@@ -750,4 +751,51 @@ QString boostPathToQString(const boost::filesystem::path &path)
}
#endif
QString formatDurationStr(int secs)
{
QStringList strList;
int days = secs / 86400;
int hours = (secs % 86400) / 3600;
int mins = (secs % 3600) / 60;
int seconds = secs % 60;
if (days)
strList.append(QString(QObject::tr("%1 d")).arg(days));
if (hours)
strList.append(QString(QObject::tr("%1 h")).arg(hours));
if (mins)
strList.append(QString(QObject::tr("%1 m")).arg(mins));
if (seconds || (!days && !hours && !mins))
strList.append(QString(QObject::tr("%1 s")).arg(seconds));
return strList.join(" ");
}
QString formatServicesStr(uint64_t mask)
{
QStringList strList;
// Just scan the last 8 bits for now.
for (int i=0; i < 8; i++) {
uint64_t check = 1 << i;
if (mask & check)
{
switch (check)
{
case NODE_NETWORK:
strList.append(QObject::tr("NETWORK"));
break;
default:
strList.append(QString("%1[%2]").arg(QObject::tr("UNKNOWN")).arg(check));
}
}
}
if (strList.size())
return strList.join(" & ");
else
return QObject::tr("None");
}
} // namespace GUIUtil