aboutsummaryrefslogtreecommitdiff
path: root/src/qt/guiutil.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-06-03 10:59:53 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2014-06-03 11:13:51 +0200
commit4c097f9669a28420da74b159a4d61e509da80d33 (patch)
treebd6c5a1a5448190a86ab34f0f96f2756a2e13a99 /src/qt/guiutil.cpp
parent522a8fa3777486725f06d6bbf5694b9cd32cbcce (diff)
parent65f78a111ff52c2212cc0a423662e7a41d1206dd (diff)
Merge pull request #4225
65f78a1 Qt: Add GUI view of peer information. #4133 (Ashley Holman)
Diffstat (limited to 'src/qt/guiutil.cpp')
-rw-r--r--src/qt/guiutil.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp
index 183fcac4a0..62db0487fc 100644
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -11,6 +11,7 @@
#include "core.h"
#include "init.h"
+#include "protocol.h"
#include "util.h"
#ifdef WIN32
@@ -754,4 +755,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