From 2ecef24c912029efc38643006fa0ef19dceeb9ac Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 20 Jun 2014 00:43:05 +0200 Subject: [PATCH] Register ENUMs in ISimulator like it is done in IVoice --- src/blackcore/blackcorefreefunctions.cpp | 3 ++- src/blackcore/simulator.cpp | 19 +++++++++++++++++ src/blackcore/simulator.h | 26 +++++++++++++++--------- src/blackcore/voice.cpp | 4 ++-- 4 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 src/blackcore/simulator.cpp diff --git a/src/blackcore/blackcorefreefunctions.cpp b/src/blackcore/blackcorefreefunctions.cpp index 86249a165..8c6e1f4d5 100644 --- a/src/blackcore/blackcorefreefunctions.cpp +++ b/src/blackcore/blackcorefreefunctions.cpp @@ -5,13 +5,14 @@ #include "blackcorefreefunctions.h" #include "voice.h" - +#include "simulator.h" namespace BlackCore { void registerMetadata() { IVoice::registerMetadata(); + ISimulator::registerMetadata(); } } // namespace diff --git a/src/blackcore/simulator.cpp b/src/blackcore/simulator.cpp new file mode 100644 index 000000000..4882ec19d --- /dev/null +++ b/src/blackcore/simulator.cpp @@ -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(); + qRegisterMetaType("Status"); + } +} diff --git a/src/blackcore/simulator.h b/src/blackcore/simulator.h index ba1554521..0f1c05b18 100644 --- a/src/blackcore/simulator.h +++ b/src/blackcore/simulator.h @@ -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 diff --git a/src/blackcore/voice.cpp b/src/blackcore/voice.cpp index b54fe32e9..d7aa963f5 100644 --- a/src/blackcore/voice.cpp +++ b/src/blackcore/voice.cpp @@ -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(); qRegisterMetaType("ComUnit"); qRegisterMetaType();