Skip to content

Commit 0d5613f

Browse files
committed
gui: create GUIUtil::NetworkToQString() utility function
1 parent af9103c commit 0d5613f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/qt/guiutil.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,21 @@ QString boostPathToQString(const fs::path &path)
749749
return QString::fromStdString(path.string());
750750
}
751751

752+
QString NetworkToQString(Network net)
753+
{
754+
switch (net) {
755+
case NET_UNROUTABLE: return QObject::tr("Unroutable");
756+
case NET_IPV4: return "IPv4";
757+
case NET_IPV6: return "IPv6";
758+
case NET_ONION: return "Onion";
759+
case NET_I2P: return "I2P";
760+
case NET_CJDNS: return "CJDNS";
761+
case NET_INTERNAL: return QObject::tr("Internal");
762+
case NET_MAX: assert(false);
763+
} // no default case, so the compiler can warn about missing cases
764+
assert(false);
765+
}
766+
752767
QString formatDurationStr(int secs)
753768
{
754769
QStringList strList;

src/qt/guiutil.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <amount.h>
99
#include <fs.h>
10+
#include <netaddress.h>
1011

1112
#include <QEvent>
1213
#include <QHeaderView>
@@ -224,6 +225,9 @@ namespace GUIUtil
224225
/* Convert OS specific boost path to QString through UTF-8 */
225226
QString boostPathToQString(const fs::path &path);
226227

228+
/** Convert enum Network to QString */
229+
QString NetworkToQString(Network net);
230+
227231
/* Convert seconds into a QString with days, hours, mins, secs */
228232
QString formatDurationStr(int secs);
229233

0 commit comments

Comments
 (0)