Qt: Add GUI view of peer information. #4133
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user