From 0d5613f9ded846aa20a95c757672e9560c664c4c Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Thu, 24 Dec 2020 11:01:07 +0100 Subject: gui: create GUIUtil::NetworkToQString() utility function --- src/qt/guiutil.cpp | 15 +++++++++++++++ src/qt/guiutil.h | 4 ++++ 2 files changed, 19 insertions(+) (limited to 'src/qt') diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 53ffb27f50..88249c4e2e 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -749,6 +749,21 @@ QString boostPathToQString(const fs::path &path) return QString::fromStdString(path.string()); } +QString NetworkToQString(Network net) +{ + switch (net) { + case NET_UNROUTABLE: return QObject::tr("Unroutable"); + case NET_IPV4: return "IPv4"; + case NET_IPV6: return "IPv6"; + case NET_ONION: return "Onion"; + case NET_I2P: return "I2P"; + case NET_CJDNS: return "CJDNS"; + case NET_INTERNAL: return QObject::tr("Internal"); + case NET_MAX: assert(false); + } // no default case, so the compiler can warn about missing cases + assert(false); +} + QString formatDurationStr(int secs) { QStringList strList; diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index d7bd124884..d7794b071a 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -224,6 +225,9 @@ namespace GUIUtil /* Convert OS specific boost path to QString through UTF-8 */ QString boostPathToQString(const fs::path &path); + /** Convert enum Network to QString */ + QString NetworkToQString(Network net); + /* Convert seconds into a QString with days, hours, mins, secs */ QString formatDurationStr(int secs); -- cgit v1.2.3