Skip to content

Commit b8e263c

Browse files
committed
gui: add GUIUtil::ConnectionTypeToQStringType utility function
1 parent 7beeb36 commit b8e263c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/qt/guiutil.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,19 @@ QString ConnectionTypeToQString(ConnectionType conn_type)
777777
assert(false);
778778
}
779779

780+
QString ConnectionTypeToShortQString(ConnectionType conn_type)
781+
{
782+
switch (conn_type) {
783+
case ConnectionType::INBOUND: return "";
784+
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Full Relay");
785+
case ConnectionType::BLOCK_RELAY: return QObject::tr("Block Relay");
786+
case ConnectionType::MANUAL: return QObject::tr("Manual");
787+
case ConnectionType::FEELER: return QObject::tr("Feeler");
788+
case ConnectionType::ADDR_FETCH: return QObject::tr("Address Fetch");
789+
} // no default case, so the compiler can warn about missing cases
790+
assert(false);
791+
}
792+
780793
QString formatDurationStr(int secs)
781794
{
782795
QStringList strList;

src/qt/guiutil.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ namespace GUIUtil
232232
/** Convert enum ConnectionType to QString */
233233
QString ConnectionTypeToQString(ConnectionType conn_type);
234234

235+
/** Convert enum ConnectionType to short QString (type only, without direction) */
236+
QString ConnectionTypeToShortQString(ConnectionType conn_type);
237+
235238
/** Convert seconds into a QString with days, hours, mins, secs */
236239
QString formatDurationStr(int secs);
237240

0 commit comments

Comments
 (0)