mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
reverted commit:97dda0b because QMetaEnum is working fine, it just needed the Q_ENUMS macro too
made INetwork::connectionStatusToString a static method
This commit is contained in:
@@ -38,6 +38,7 @@ namespace BlackCore
|
|||||||
class INetwork : public QObject
|
class INetwork : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_ENUMS(ConnectionStatus)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*!
|
/*!
|
||||||
@@ -64,20 +65,11 @@ namespace BlackCore
|
|||||||
Connected
|
Connected
|
||||||
};
|
};
|
||||||
|
|
||||||
static const QString connectionStatusToString(ConnectionStatus status)
|
static QString connectionStatusToString(ConnectionStatus status)
|
||||||
{
|
{
|
||||||
// the version with metaObject, metaObject()->indexOfEnumerator does not work anymore
|
int index = staticMetaObject.indexOfEnumerator("ConnectionStatus");
|
||||||
// an interface cannot be used with Q_DECLAREMETATYPE
|
QMetaEnum metaEnum = staticMetaObject.enumerator(index);
|
||||||
switch (status)
|
return metaEnum.valueToKey(status);
|
||||||
{
|
|
||||||
case Disconnected: return "disconnected";
|
|
||||||
case DisconnectedError: return "disconnectedError";
|
|
||||||
case Connecting: return "connecting";
|
|
||||||
case Connected: return "connected";
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
qFatal("Missing value");
|
|
||||||
return ""; // just for compiler warning
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool isConnected() const = 0;
|
virtual bool isConnected() const = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user