gui: create GUIUtil::ConnectionTypeToQString utility function

This commit is contained in:
Jon Atack 2020-12-24 12:35:37 +01:00
parent 9158d6f341
commit 7e2beab2d2
No known key found for this signature in database
GPG key ID: 4F5721B3D0E3921D
2 changed files with 18 additions and 1 deletions

View file

@ -764,6 +764,19 @@ QString NetworkToQString(Network net)
assert(false); assert(false);
} }
QString ConnectionTypeToQString(ConnectionType conn_type)
{
switch (conn_type) {
case ConnectionType::INBOUND: return QObject::tr("Inbound");
case ConnectionType::OUTBOUND_FULL_RELAY: return QObject::tr("Outbound Full Relay");
case ConnectionType::BLOCK_RELAY: return QObject::tr("Outbound Block Relay");
case ConnectionType::MANUAL: return QObject::tr("Outbound Manual");
case ConnectionType::FEELER: return QObject::tr("Outbound Feeler");
case ConnectionType::ADDR_FETCH: return QObject::tr("Outbound Address Fetch");
} // no default case, so the compiler can warn about missing cases
assert(false);
}
QString formatDurationStr(int secs) QString formatDurationStr(int secs)
{ {
QStringList strList; QStringList strList;

View file

@ -7,17 +7,18 @@
#include <amount.h> #include <amount.h>
#include <fs.h> #include <fs.h>
#include <net.h>
#include <netaddress.h> #include <netaddress.h>
#include <QEvent> #include <QEvent>
#include <QHeaderView> #include <QHeaderView>
#include <QItemDelegate> #include <QItemDelegate>
#include <QLabel>
#include <QMessageBox> #include <QMessageBox>
#include <QObject> #include <QObject>
#include <QProgressBar> #include <QProgressBar>
#include <QString> #include <QString>
#include <QTableView> #include <QTableView>
#include <QLabel>
class QValidatedLineEdit; class QValidatedLineEdit;
class SendCoinsRecipient; class SendCoinsRecipient;
@ -228,6 +229,9 @@ namespace GUIUtil
/** Convert enum Network to QString */ /** Convert enum Network to QString */
QString NetworkToQString(Network net); QString NetworkToQString(Network net);
/** Convert enum ConnectionType to QString */
QString ConnectionTypeToQString(ConnectionType conn_type);
/** Convert seconds into a QString with days, hours, mins, secs */ /** Convert seconds into a QString with days, hours, mins, secs */
QString formatDurationStr(int secs); QString formatDurationStr(int secs);