Register ENUMs in ISimulator like it is done in IVoice

This commit is contained in:
Klaus Basan
2014-06-20 00:43:05 +02:00
parent c404d4cc5b
commit 2ecef24c91
4 changed files with 39 additions and 13 deletions

View File

@@ -5,13 +5,14 @@
#include "blackcorefreefunctions.h"
#include "voice.h"
#include "simulator.h"
namespace BlackCore
{
void registerMetadata()
{
IVoice::registerMetadata();
ISimulator::registerMetadata();
}
} // namespace

View File

@@ -0,0 +1,19 @@
/* Copyright (C) 2013 VATSIM Community / authors
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "simulator.h"
namespace BlackCore
{
ISimulator::ISimulator(QObject *parent) : QObject(parent)
{ }
void ISimulator::registerMetadata()
{
// for some reasons (ask RW) this is registered twice, see IVoice
qRegisterMetaType<Status>();
qRegisterMetaType<Status>("Status");
}
}

View File

@@ -25,10 +25,11 @@ namespace BlackCore
class ISimulator : public QObject
{
Q_OBJECT
Q_ENUMS(Status)
public:
//! \brief Simulator connection
//! ISimulatorSimulator connection
enum Status
{
Disconnected,
@@ -36,27 +37,31 @@ namespace BlackCore
ConnectionFailed
};
//! \brief Constructor
ISimulator(QObject *parent = nullptr) : QObject(parent) {}
//! ISimulatorConstructor
ISimulator(QObject *parent = nullptr);
//! \brief Destructor
//! ISimulatorDestructor
virtual ~ISimulator() {}
//! \brief Are we connected to the simulator?
//! ISimulatorAre we connected to the simulator?
virtual bool isConnected() const = 0;
//! \brief Can we connect?
//! ISimulatorCan we connect?
virtual bool canConnect() = 0;
//! ISimulatorRegister metadata
static void registerMetadata();
public slots:
//! \brief Connect to simulator
//! ISimulatorConnect to simulator
virtual bool connectTo() = 0;
//! Connect asynchron to simulator
virtual void asyncConnectTo() = 0;
//! \brief Disconnect from simulator
//! ISimulatorDisconnect from simulator
virtual bool disconnectFrom() = 0;
//! Return user aircraft object
@@ -102,11 +107,11 @@ namespace BlackCore
{
public:
//! \brief Virtual destructor
//! ISimulatorVirtual destructor
virtual ~ISimulatorFactory() {}
/*!
* \brief Create a new instance
* ISimulatorCreate a new instance
* \param parent
* \return
*/
@@ -120,5 +125,6 @@ namespace BlackCore
// TODO: Use CProject to store this string
Q_DECLARE_INTERFACE(BlackCore::ISimulatorFactory, "net.vatsim.PilotClient.BlackCore.SimulatorInterface")
Q_DECLARE_METATYPE(BlackCore::ISimulator::Status)
#endif // guard

View File

@@ -8,11 +8,11 @@
namespace BlackCore
{
IVoice::IVoice(QObject *parent) : QObject(parent)
{
}
{ }
void IVoice::registerMetadata()
{
// for some reasons (ask RW) this is registered twice
qRegisterMetaType<ComUnit>();
qRegisterMetaType<ComUnit>("ComUnit");
qRegisterMetaType<ConnectionStatus>();