From 68e9cc2c3e33257ef18714d0aafe2752f0d8cb05 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Fri, 2 May 2014 14:01:25 +0200 Subject: [PATCH] Move IVoice enum registration into static method refs #183 --- samples/blackgui/main.cpp | 2 ++ samples/blackgui2/main.cpp | 2 ++ samples/voiceclient/main.cpp | 2 ++ src/blackcore/blackcorefreefunctions.cpp | 17 +++++++++++++++++ src/blackcore/blackcorefreefunctions.h | 21 +++++++++++++++++++++ src/blackcore/context_runtime.cpp | 2 ++ src/blackcore/voice.cpp | 13 ++++++++----- src/blackcore/voice.h | 3 +++ 8 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 src/blackcore/blackcorefreefunctions.cpp create mode 100644 src/blackcore/blackcorefreefunctions.h diff --git a/samples/blackgui/main.cpp b/samples/blackgui/main.cpp index 35f7f1896..93638d6bc 100644 --- a/samples/blackgui/main.cpp +++ b/samples/blackgui/main.cpp @@ -1,6 +1,7 @@ #include "introwindow.h" #include "mainwindow.h" #include "guimodeenums.h" +#include "blackcore/blackcorefreefunctions.h" #include "blackcore/context_runtime_config.h" #include "blacksim/blacksimfreefunctions.h" #include "blackmisc/blackmiscfreefunctions.h" @@ -23,6 +24,7 @@ int main(int argc, char *argv[]) BlackMisc::initResources(); BlackMisc::registerMetadata(); BlackSim::registerMetadata(); + BlackCore::registerMetadata(); // BlackMisc::displayAllUserMetatypesTypes(); QFile file(":blackmisc/translations/blackmisc_i18n_de.qm"); diff --git a/samples/blackgui2/main.cpp b/samples/blackgui2/main.cpp index 3808e4319..dfd8c7e0b 100644 --- a/samples/blackgui2/main.cpp +++ b/samples/blackgui2/main.cpp @@ -1,6 +1,7 @@ #include "introwindow.h" #include "dockwindow.h" #include "guimodeenums.h" +#include "blackcore/blackcorefreefunctions.h" #include "blackmisc/blackmiscfreefunctions.h" #include #include @@ -19,6 +20,7 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(blackgui); BlackMisc::initResources(); BlackMisc::registerMetadata(); + BlackCore::registerMetadata(); // BlackMisc::displayAllUserMetatypesTypes(); QFile file(":blackmisc/translations/blackmisc_i18n_de.qm"); diff --git a/samples/voiceclient/main.cpp b/samples/voiceclient/main.cpp index bb6915da1..5d31ef8b9 100644 --- a/samples/voiceclient/main.cpp +++ b/samples/voiceclient/main.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "blackcore/voice_vatlib.h" +#include "blackcore/blackcorefreefunctions.h" #include "blackmisc/blackmiscfreefunctions.h" #include "client.h" @@ -20,6 +21,7 @@ int main(int argc, char *argv[]) QCoreApplication app (argc, argv); Client client(&app); BlackMisc::registerMetadata(); + BlackCore::registerMetadata(); BlackCore::IVoice *m_voice = new BlackCore::CVoiceVatlib(); QThread m_voiceThread; m_voice->moveToThread(&m_voiceThread); diff --git a/src/blackcore/blackcorefreefunctions.cpp b/src/blackcore/blackcorefreefunctions.cpp new file mode 100644 index 000000000..86249a165 --- /dev/null +++ b/src/blackcore/blackcorefreefunctions.cpp @@ -0,0 +1,17 @@ +/* Copyright (C) 2013 VATSIM Community / contributors + * 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 "blackcorefreefunctions.h" +#include "voice.h" + + +namespace BlackCore +{ + void registerMetadata() + { + IVoice::registerMetadata(); + } + +} // namespace diff --git a/src/blackcore/blackcorefreefunctions.h b/src/blackcore/blackcorefreefunctions.h new file mode 100644 index 000000000..9df9bc844 --- /dev/null +++ b/src/blackcore/blackcorefreefunctions.h @@ -0,0 +1,21 @@ +/* Copyright (C) 2013 VATSIM Community / contributors + * 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/. */ + +#ifndef BLACKCORE_FREEFUNCTIONS_H +#define BLACKCORE_FREEFUNCTIONS_H + +/*! + * Free functions in BlackSim + */ +namespace BlackCore +{ + /*! + * \brief Register all relevant metadata in BlackCore + */ + void registerMetadata(); + +} // BlackCore + +#endif // guard diff --git a/src/blackcore/context_runtime.cpp b/src/blackcore/context_runtime.cpp index e7fb720f6..81b8bd95e 100644 --- a/src/blackcore/context_runtime.cpp +++ b/src/blackcore/context_runtime.cpp @@ -1,6 +1,7 @@ #include "blackcore/context_runtime.h" #include "blackcore/context_all_impl.h" #include "blackcore/context_all_proxies.h" +#include "blackcore/blackcorefreefunctions.h" #include "blacksim/blacksimfreefunctions.h" @@ -224,6 +225,7 @@ namespace BlackCore BlackMisc::registerMetadata(); BlackMisc::initResources(); BlackSim::registerMetadata(); + BlackCore::registerMetadata(); // upfront reading of settings, as DBus server already relies on settings CContextSettings *settings = nullptr; diff --git a/src/blackcore/voice.cpp b/src/blackcore/voice.cpp index 125bb4543..b54fe32e9 100644 --- a/src/blackcore/voice.cpp +++ b/src/blackcore/voice.cpp @@ -9,10 +9,13 @@ namespace BlackCore { IVoice::IVoice(QObject *parent) : QObject(parent) { - // http://qt-project.org/forums/viewthread/27495 - qRegisterMetaType("ComUnit"); - qRegisterMetaType("IVoice::ComUnit"); - qRegisterMetaType("ConnectionStatus"); - qRegisterMetaType("IVoice::ConnectionStatus"); + } + + void IVoice::registerMetadata() + { + qRegisterMetaType(); + qRegisterMetaType("ComUnit"); + qRegisterMetaType(); + qRegisterMetaType("ConnectionStatus"); } } diff --git a/src/blackcore/voice.h b/src/blackcore/voice.h index d78366051..f420fef9b 100644 --- a/src/blackcore/voice.h +++ b/src/blackcore/voice.h @@ -126,6 +126,9 @@ namespace BlackCore */ virtual QString micTestResultAsString() const = 0; + //! \brief Register metadata + static void registerMetadata(); + public slots: /*!