From d971b073b7af04134c3abb9ef4a7a54708539f6e Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Tue, 30 Jun 2015 20:48:04 +0100 Subject: [PATCH] refs #297 Removed old simulator settings, which were not even used. --- src/blackcore/context_settings.h | 10 -- src/blackcore/context_settings_impl.cpp | 32 ------ src/blackcore/context_settings_impl.h | 4 - src/blackcore/context_settings_proxy.cpp | 9 -- src/blackcore/context_settings_proxy.h | 3 - src/blackcore/context_simulator_impl.cpp | 1 - src/blackcore/settingsallclasses.h | 1 - .../components/settingssimulatorcomponent.cpp | 14 +-- .../components/settingssimulatorcomponent.h | 4 - .../blackmiscfreefunctions_simmeta.cpp | 3 - src/blackmisc/simulation/setsimulator.cpp | 87 ---------------- src/blackmisc/simulation/setsimulator.h | 98 ------------------- 12 files changed, 1 insertion(+), 265 deletions(-) delete mode 100644 src/blackmisc/simulation/setsimulator.cpp delete mode 100644 src/blackmisc/simulation/setsimulator.h diff --git a/src/blackcore/context_settings.h b/src/blackcore/context_settings.h index 7530cbb01..b31bdf75f 100644 --- a/src/blackcore/context_settings.h +++ b/src/blackcore/context_settings.h @@ -94,13 +94,6 @@ namespace BlackCore return s; } - //! Path for simulator settings - static const QString &PathSimulatorSettings() - { - static QString s("simulator"); - return s; - } - //! Root path static const QString &PathRoot() { @@ -136,9 +129,6 @@ namespace BlackCore //! Audio settings virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const = 0; - //! Audio settings - virtual BlackMisc::Simulation::Settings::CSettingsSimulator getSimulatorSettings() const = 0; - //! Hotkeys virtual BlackMisc::Settings::CSettingKeyboardHotkeyList getHotkeys() const = 0; diff --git a/src/blackcore/context_settings_impl.cpp b/src/blackcore/context_settings_impl.cpp index e28c109d2..18f25e179 100644 --- a/src/blackcore/context_settings_impl.cpp +++ b/src/blackcore/context_settings_impl.cpp @@ -16,7 +16,6 @@ using namespace BlackMisc; using namespace BlackMisc::Settings; using namespace BlackMisc::Network; using namespace BlackMisc::Hardware; -using namespace BlackMisc::Simulation::Settings; namespace BlackCore { @@ -71,18 +70,6 @@ namespace BlackCore this->m_settingsAudio.initDefaultValues(); } - // init simulator - if (jsonObject.contains(IContextSettings::PathSimulatorSettings())) - { - this->m_settingsSimulator.convertFromJson( - jsonObject.value(IContextSettings::PathSimulatorSettings()).toObject() - ); - } - else - { - this->m_settingsSimulator.initDefaultValues(); - } - // init own members if (jsonObject.contains(IContextSettings::PathHotkeys())) { @@ -137,7 +124,6 @@ namespace BlackCore this->m_hotkeys.initAsHotkeyList(true); this->m_settingsNetwork.initDefaultValues(); this->m_settingsAudio.initDefaultValues(); - this->m_settingsSimulator.initDefaultValues(); this->emitCompletelyChanged(); if (write) { @@ -163,7 +149,6 @@ namespace BlackCore QJsonObject jsonObject; jsonObject.insert(IContextSettings::PathNetworkSettings(), this->m_settingsNetwork.toJson()); jsonObject.insert(IContextSettings::PathAudioSettings(), this->m_settingsAudio.toJson()); - jsonObject.insert(IContextSettings::PathSimulatorSettings(), this->m_settingsSimulator.toJson()); jsonObject.insert(IContextSettings::PathHotkeys(), this->m_hotkeys.toJson()); QJsonDocument doc(jsonObject); return doc; @@ -204,14 +189,6 @@ namespace BlackCore return this->m_settingsAudio; } - /* - * Simulator settings - */ - CSettingsSimulator CContextSettings::getSimulatorSettings() const - { - return this->m_settingsSimulator; - } - /* * Pass value */ @@ -257,15 +234,6 @@ namespace BlackCore emit this->changedSettings(static_cast(SettingsAudio)); } } - else if (path.startsWith(IContextSettings::PathSimulatorSettings())) - { - msgs.push_back(this->m_settingsSimulator.value(nextLevelPath, command, value, changed)); - if (changed) - { - msgs.push_back(this->write()); - emit this->changedSettings(static_cast(SettingsSimulator)); - } - } else { msgs.push_back( diff --git a/src/blackcore/context_settings_impl.h b/src/blackcore/context_settings_impl.h index 272d54f36..6452caf68 100644 --- a/src/blackcore/context_settings_impl.h +++ b/src/blackcore/context_settings_impl.h @@ -60,9 +60,6 @@ namespace BlackCore //! \copydoc IContextSettings::getAudioSettings() virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override; - //! \copydoc IContextSettings::getSimulatorSettings() - virtual BlackMisc::Simulation::Settings::CSettingsSimulator getSimulatorSettings() const override; - //! \copydoc IContextSettings::getHotkeys() virtual BlackMisc::Settings::CSettingKeyboardHotkeyList getHotkeys() const override; @@ -87,7 +84,6 @@ namespace BlackCore BlackMisc::Settings::CSettingsNetwork m_settingsNetwork; BlackMisc::Settings::CSettingsAudio m_settingsAudio; - BlackMisc::Simulation::Settings::CSettingsSimulator m_settingsSimulator; BlackMisc::Settings::CSettingKeyboardHotkeyList m_hotkeys; QJsonDocument toJsonDocument() const; void emitCompletelyChanged(); diff --git a/src/blackcore/context_settings_proxy.cpp b/src/blackcore/context_settings_proxy.cpp index 1cd18c885..bdf63f364 100644 --- a/src/blackcore/context_settings_proxy.cpp +++ b/src/blackcore/context_settings_proxy.cpp @@ -15,7 +15,6 @@ using namespace BlackMisc; using namespace BlackMisc::Settings; using namespace BlackMisc::Network; using namespace BlackMisc::Hardware; -using namespace BlackMisc::Simulation::Settings; namespace BlackCore { @@ -58,14 +57,6 @@ namespace BlackCore return this->m_dBusInterface->callDBusRet(QLatin1Literal("getAudioSettings")); } - /* - * Relay to DBus - */ - CSettingsSimulator CContextSettingsProxy::getSimulatorSettings() const - { - return this->m_dBusInterface->callDBusRet(QLatin1Literal("getSimulatorSettings")); - } - /* * Relay to DBus */ diff --git a/src/blackcore/context_settings_proxy.h b/src/blackcore/context_settings_proxy.h index 28e2be10d..9656a7acb 100644 --- a/src/blackcore/context_settings_proxy.h +++ b/src/blackcore/context_settings_proxy.h @@ -50,9 +50,6 @@ namespace BlackCore //! \copydoc IContextSettings::getAudioSettings() virtual BlackMisc::Settings::CSettingsAudio getAudioSettings() const override; - //! \copydoc IContextSettings::getSimulatorSettings() - virtual BlackMisc::Simulation::Settings::CSettingsSimulator getSimulatorSettings() const override; - //! \copydoc IContextSettings::getHotkeys() virtual BlackMisc::Settings::CSettingKeyboardHotkeyList getHotkeys() const override; diff --git a/src/blackcore/context_simulator_impl.cpp b/src/blackcore/context_simulator_impl.cpp index 86c4a6f62..cd7dbdfb7 100644 --- a/src/blackcore/context_simulator_impl.cpp +++ b/src/blackcore/context_simulator_impl.cpp @@ -31,7 +31,6 @@ using namespace BlackMisc::Network; using namespace BlackMisc::Simulation; using namespace BlackMisc::Geo; using namespace BlackMisc::Simulation; -using namespace BlackMisc::Simulation::Settings; namespace BlackCore { diff --git a/src/blackcore/settingsallclasses.h b/src/blackcore/settingsallclasses.h index 9b0baf8cc..138e96575 100644 --- a/src/blackcore/settingsallclasses.h +++ b/src/blackcore/settingsallclasses.h @@ -7,6 +7,5 @@ #define BLACKCORE_SETTINGSALLCLASSES_H #include "blackmisc/settingsblackmiscclasses.h" -#include "blackmisc/simulation/setsimulator.h" #endif // guard diff --git a/src/blackgui/components/settingssimulatorcomponent.cpp b/src/blackgui/components/settingssimulatorcomponent.cpp index 11f4f8e83..5789bfb24 100644 --- a/src/blackgui/components/settingssimulatorcomponent.cpp +++ b/src/blackgui/components/settingssimulatorcomponent.cpp @@ -1,11 +1,9 @@ #include "settingssimulatorcomponent.h" #include "ui_settingssimulatorcomponent.h" -#include "blackcore/context_settings.h" #include "blackcore/context_simulator.h" #include "blackcore/context_network.h" #include "blackmisc/simulation/simulatorplugininfolist.h" -#include "blackmisc/simulation/setsimulator.h" #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/logmessage.h" #include "blackmisc/variant.h" @@ -41,7 +39,6 @@ namespace BlackGui void CSettingsSimulatorComponent::runtimeHasBeenSet() { Q_ASSERT_X(this->getIContextSimulator(), Q_FUNC_INFO, "missing simulator"); - Q_ASSERT_X(this->getIContextSettings(), Q_FUNC_INFO, "missing settings"); // set values for (const auto &p : getAvailablePlugins(true)) @@ -51,8 +48,6 @@ namespace BlackGui // connects connect(this->ui->cb_Plugins, static_cast (&QComboBox::currentIndexChanged), this, &CSettingsSimulatorComponent::ps_pluginHasBeenSelectedInComboBox); - connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &CSettingsSimulatorComponent::ps_settingsHaveChanged); - connect(this->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CSettingsSimulatorComponent::ps_simulatorPluginChanged); connect(this->ui->pb_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedAircraft); connect(this->ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyTimeSync); connect(this->ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedDistance); @@ -142,8 +137,7 @@ namespace BlackGui void CSettingsSimulatorComponent::ps_pluginHasBeenSelectedInComboBox(int index) { Q_ASSERT(this->getIContextSimulator()); - Q_ASSERT(this->getIContextSettings()); - if (!this->getIContextSimulator() || !this->getIContextSettings()) { return; } + if (!this->getIContextSimulator()) { return; } CSimulatorPluginInfoList simDrivers(getAvailablePlugins(true)); if (simDrivers.isEmpty()) @@ -164,12 +158,6 @@ namespace BlackGui // changing of GUI state will be done via received signal } - void CSettingsSimulatorComponent::ps_settingsHaveChanged(uint settingsType) - { - Q_ASSERT(this->getIContextSettings()); - Q_UNUSED(settingsType); - } - void CSettingsSimulatorComponent::ps_onApplyMaxRenderedAircraft() { Q_ASSERT(getIContextSimulator()); diff --git a/src/blackgui/components/settingssimulatorcomponent.h b/src/blackgui/components/settingssimulatorcomponent.h index 8816428dc..dfa3eec0e 100644 --- a/src/blackgui/components/settingssimulatorcomponent.h +++ b/src/blackgui/components/settingssimulatorcomponent.h @@ -11,7 +11,6 @@ #define BLACKGUI_SETTINGSSIMULATORCOMPONENT_H #include "blackgui/blackguiexport.h" -#include "blackmisc/simulation/setsimulator.h" #include "blackmisc/simulation/simulatorplugininfolist.h" #include "enableforruntime.h" #include "enableforruntime.h" @@ -43,9 +42,6 @@ namespace BlackGui //! Driver changed void ps_pluginHasBeenSelectedInComboBox(int index); - //! Settings have been changed - void ps_settingsHaveChanged(uint settingsType); - //! Apply max.aircraft void ps_onApplyMaxRenderedAircraft(); diff --git a/src/blackmisc/blackmiscfreefunctions_simmeta.cpp b/src/blackmisc/blackmiscfreefunctions_simmeta.cpp index 4d1274452..486356343 100644 --- a/src/blackmisc/blackmiscfreefunctions_simmeta.cpp +++ b/src/blackmisc/blackmiscfreefunctions_simmeta.cpp @@ -10,7 +10,6 @@ #include "blackmisc/simulation/aircraftmodellist.h" #include "blackmisc/simulation/simulatedaircraftlist.h" #include "blackmisc/simulation/simulatorplugininfolist.h" -#include "blackmisc/simulation/setsimulator.h" #include "blackmisc/simulation/airspaceaircraftsnapshot.h" #include "blackmisc/simulation/simulatorsetup.h" #include "blackmisc/simulation/fsx/simconnectutilities.h" @@ -19,7 +18,6 @@ using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation::Fsx; using namespace BlackMisc::Simulation::FsCommon; -using namespace BlackMisc::Simulation::Settings; /* * Metadata for simulation @@ -31,7 +29,6 @@ void BlackMisc::Simulation::registerMetadata() { CSimulatorPluginInfo::registerMetadata(); CSimulatorPluginInfoList::registerMetadata(); - CSettingsSimulator::registerMetadata(); CAircraftCfgEntries::registerMetadata(); CAircraftCfgEntriesList::registerMetadata(); CSimConnectUtilities::registerMetadata(); diff --git a/src/blackmisc/simulation/setsimulator.cpp b/src/blackmisc/simulation/setsimulator.cpp deleted file mode 100644 index 3a47bb096..000000000 --- a/src/blackmisc/simulation/setsimulator.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -#include "setsimulator.h" -#include "blackmisc/logmessage.h" - -using namespace BlackMisc; -using namespace BlackMisc::Settings; -using namespace BlackMisc::PhysicalQuantities; - -namespace BlackMisc -{ - namespace Simulation - { - namespace Settings - { - - CSettingsSimulator::CSettingsSimulator() - { - this->initDefaultValues(); - } - - QString CSettingsSimulator::convertToQString(bool i18n) const - { - Q_UNUSED(i18n); - QString s("Sel.driver:"); - s.append(" ").append(m_selectedPlugin.toQString(i18n)); - return s; - } - - void CSettingsSimulator::initDefaultValues() - { - this->m_timeSyncOffset = CTime(0, CTimeUnit::hrmin()); - this->m_timeSync = false; - } - - BlackMisc::CStatusMessage CSettingsSimulator::value(const QString &path, const QString &command, const CVariant &value, bool &changedFlag) - { - // TODO: This needs to be refactored to a smarter way to delegate commands - changedFlag = false; - if (path == CSettingsSimulator::ValueSelectedDriver()) - { - if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate()) - { - CSimulatorPluginInfo v = value.value(); - changedFlag = (v != this->m_selectedPlugin); - this->m_selectedPlugin = v; - return CLogMessage(CLogCategory::settingsUpdate()).info("selected driver%1 changed") << (changedFlag ? "" : " not"); - } - return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; - } - else if (path == CSettingsSimulator::ValueSyncTime()) - { - if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate()) - { - bool v = value.value(); - changedFlag = (v != this->m_timeSync); - this->m_timeSync = v; - return CLogMessage(CLogCategory::settingsUpdate()).info("time synchronization%1 changed") << (changedFlag ? "" : " not"); - } - return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; - } - else if (path == CSettingsSimulator::ValueSyncTimeOffset()) - { - if (command == CSettingUtilities::CmdAdd() || command == CSettingUtilities::CmdUpdate()) - { - CTime v = value.value(); - changedFlag = (v != this->m_timeSyncOffset); - this->m_timeSyncOffset = v; - return CLogMessage(CLogCategory::settingsUpdate()).info("time synchronization offset%1 changed") << (changedFlag ? "" : " not"); - } - return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; - } - else - { - return CLogMessage(CLogCategory::validation()).error("wrong path: %1") << path; - } - } - } // namespace - } // namespace -} // namespace diff --git a/src/blackmisc/simulation/setsimulator.h b/src/blackmisc/simulation/setsimulator.h deleted file mode 100644 index d1fe16d56..000000000 --- a/src/blackmisc/simulation/setsimulator.h +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (C) 2013 - * swift project Community / Contributors - * - * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level - * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, - * including this file, may be copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE file. - */ - -//! \file - -#ifndef BLACKMISC_SETTINGS_SIMULATOR_H -#define BLACKMISC_SETTINGS_SIMULATOR_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/valueobject.h" -#include "blackmisc/statusmessagelist.h" -#include "blackmisc/settingutilities.h" -#include "blackmisc/pq/time.h" -#include "simulatorplugininfo.h" - -namespace BlackMisc -{ - namespace Simulation - { - namespace Settings - { - //! Value object encapsulating information of simulator related settings. - //! \deprecated will be removed with new MS settings - class BLACKMISC_EXPORT CSettingsSimulator : public BlackMisc::CValueObject - { - public: - //! Default constructor. - CSettingsSimulator(); - - //! Path - static const QString &ValueSelectedDriver() - { - static const QString value("selecteddriver"); - return value; - } - - //! Path - static const QString &ValueSyncTimeOffset() - { - static const QString value("synctimeoffset"); - return value; - } - - //! Path - static const QString &ValueSyncTime() - { - static const QString value("synctime"); - return value; - } - - //! Selected driver - const BlackMisc::Simulation::CSimulatorPluginInfo &getSelectedPlugin() const { return this->m_selectedPlugin; } - - //! Selected driver - void setSelectedPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &plugin) { this->m_selectedPlugin = plugin; } - - //! Time synchronization offset time - const BlackMisc::PhysicalQuantities::CTime &getSyncTimeOffset() const { return this->m_timeSyncOffset;} - - //! Set time synchronization offset time - void setSyncTimeOffset(const BlackMisc::PhysicalQuantities::CTime &offset) { this->m_timeSyncOffset = offset; this->m_timeSyncOffset.switchUnit(BlackMisc::PhysicalQuantities::CTimeUnit::hrmin());} - - //! Time syncronization enabled? - bool isTimeSyncEnabled() const { return this->m_timeSync;} - - //! Set time synchronization - void setTimeSyncEnabled(bool enabled) { this->m_timeSync = enabled; } - - //! Init with meaningful default values - void initDefaultValues(); - - //! \copydoc BlackCore::IContextSettings::value - BlackMisc::CStatusMessage value(const QString &path, const QString &command, const BlackMisc::CVariant &value, bool &changedFlag); - - //! \copydoc CValueObject::convertToQString - QString convertToQString(bool i18n = false) const; - - private: - BLACK_ENABLE_TUPLE_CONVERSION(CSettingsSimulator) - BlackMisc::Simulation::CSimulatorPluginInfo m_selectedPlugin; - bool m_timeSync = false; - BlackMisc::PhysicalQuantities::CTime m_timeSyncOffset; - }; - - } // namespace - } // namespace -} // namespace - -Q_DECLARE_METATYPE(BlackMisc::Simulation::Settings::CSettingsSimulator) -BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::Settings::CSettingsSimulator, (o.m_selectedPlugin, o.m_timeSync, o.m_timeSyncOffset)) - -#endif // guard