Skip to content

Commit 7e2beab

Browse files
committed
gui: create GUIUtil::ConnectionTypeToQString utility function
1 parent 9158d6f commit 7e2beab

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/qt/guiutil.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,19 @@ QString NetworkToQString(Network net)
764764
assert(false);
765765
}
766766

767+
QString ConnectionTypeToQString(ConnectionType conn_type)
768+
{
769+
switch (conn_type) {
770+
case ConnectionType::INBOUND: return QObject::tr("Inbound");
771+
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay");
772+
case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay");
773+
case ConnectionType::MANUAL: return QObject::tr("Outbound Manual");
774+
case ConnectionType::FEELER: return QObject::tr("Outbound Feeler");
775+
case ConnectionType::ADDR_FETCH: return QObject::tr("Outbound Address Fetch");
776+
} // no default case, so the compiler can warn about missing cases
777+
assert(false);
778+
}
779+
767780
QString formatDurationStr(int secs)
768781
{
769782
QStringList strList;

src/qt/guiutil.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77

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

1213
#include <QEvent>
1314
#include <QHeaderView>
1415
#include <QItemDelegate>
16+
#include <QLabel>
1517
#include <QMessageBox>
1618
#include <QObject>
1719
#include <QProgressBar>
1820
#include <QString>
1921
#include <QTableView>
20-
#include <QLabel>
2122

2223
class QValidatedLineEdit;
2324
class SendCoinsRecipient;
@@ -228,6 +229,9 @@ namespace GUIUtil
228229
/** Convert enum Network to QString */
229230
QString NetworkToQString(Network net);
230231

232+
/** Convert enum ConnectionType to QString */
233+
QString ConnectionTypeToQString(ConnectionType conn_type);
234+
231235
/** Convert seconds into a QString with days, hours, mins, secs */
232236
QString formatDurationStr(int secs);
233237

0 commit comments

Comments
 (0)