From 7e36e67f8951b52e0a66ee3b41f45b1fdfce1d7c Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 4 Oct 2019 23:50:11 +0200 Subject: [PATCH] Ref T739, removed voice room value objects --- src/blackmisc/audio/audio.h | 2 - src/blackmisc/audio/registermetadataaudio.cpp | 2 - src/blackmisc/audio/voiceroom.cpp | 100 -------------- src/blackmisc/audio/voiceroom.h | 126 ------------------ src/blackmisc/audio/voiceroomlist.cpp | 48 ------- src/blackmisc/audio/voiceroomlist.h | 57 -------- src/blackmisc/aviation/atcstation.cpp | 6 - src/blackmisc/aviation/atcstation.h | 22 +-- src/blackmisc/aviation/atcstationlist.cpp | 5 - src/blackmisc/aviation/atcstationlist.h | 4 - src/blackmisc/propertyindex.h | 1 - src/blackmisc/test/testing.cpp | 2 - 12 files changed, 1 insertion(+), 374 deletions(-) delete mode 100644 src/blackmisc/audio/voiceroom.cpp delete mode 100644 src/blackmisc/audio/voiceroom.h delete mode 100644 src/blackmisc/audio/voiceroomlist.cpp delete mode 100644 src/blackmisc/audio/voiceroomlist.h diff --git a/src/blackmisc/audio/audio.h b/src/blackmisc/audio/audio.h index 0c1d86270..e7d40db02 100644 --- a/src/blackmisc/audio/audio.h +++ b/src/blackmisc/audio/audio.h @@ -18,8 +18,6 @@ #include "blackmisc/audio/audiodeviceinfo.h" #include "blackmisc/audio/audiodeviceinfolist.h" -#include "blackmisc/audio/voiceroom.h" -#include "blackmisc/audio/voiceroomlist.h" #include "blackmisc/audio/audiosettings.h" #include "blackmisc/audio/voicesetup.h" diff --git a/src/blackmisc/audio/registermetadataaudio.cpp b/src/blackmisc/audio/registermetadataaudio.cpp index 67822bf7f..46ff12faa 100644 --- a/src/blackmisc/audio/registermetadataaudio.cpp +++ b/src/blackmisc/audio/registermetadataaudio.cpp @@ -20,8 +20,6 @@ namespace BlackMisc { CAudioDeviceInfo::registerMetadata(); CAudioDeviceInfoList::registerMetadata(); - CVoiceRoom::registerMetadata(); - CVoiceRoomList::registerMetadata(); CSettings::registerMetadata(); CVoiceSetup::registerMetadata(); diff --git a/src/blackmisc/audio/voiceroom.cpp b/src/blackmisc/audio/voiceroom.cpp deleted file mode 100644 index f318b6925..000000000 --- a/src/blackmisc/audio/voiceroom.cpp +++ /dev/null @@ -1,100 +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. 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 "blackmisc/audio/voiceroom.h" -#include "blackmisc/propertyindex.h" -#include "blackmisc/variant.h" - -#include -#include -#include - -namespace BlackMisc -{ - namespace Audio - { - CVoiceRoom::CVoiceRoom(const QString &voiceRoomUrl, bool connected) : - m_connected(connected), m_audioPlaying(false) - { - this->setVoiceRoomUrl(voiceRoomUrl); - } - - CVariant CVoiceRoom::propertyByIndex(const CPropertyIndex &index) const - { - if (index.isMyself()) { return CVariant::from(*this); } - const ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexAudioPlaying: return CVariant::from(this->isAudioPlaying()); - case IndexConnected: return CVariant::from(this->isConnected()); - case IndexChannel: return CVariant::from(this->getChannel()); - case IndexHostname: return CVariant::from(this->getHostname()); - case IndexUrl: return CVariant::from(this->getVoiceRoomUrl()); - default: return CValueObject::propertyByIndex(index); - } - } - - void CVoiceRoom::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant) - { - if (index.isMyself()) { (*this) = variant.to(); return; } - const ColumnIndex i = index.frontCasted(); - switch (i) - { - case IndexAudioPlaying: this->setAudioPlaying(variant.toBool()); break; - case IndexConnected: this->setConnected(variant.toBool()); break; - case IndexChannel: this->setChannel(variant.value()); break; - case IndexHostname: this->setHostName(variant.value()); break; - case IndexUrl: this->setVoiceRoomUrl(variant.value()); break; - default: CValueObject::setPropertyByIndex(index, variant); break; - } - } - - QString CVoiceRoom::convertToQString(bool i18n) const - { - Q_UNUSED(i18n); - if (!this->isValid()) { return QStringLiteral("Invalid"); } - return this->getVoiceRoomUrl(false) % - (this->isConnected() ? u" connected" : u" unconnected") % - (m_audioPlaying ? u" playing" : u""); - } - - QString CVoiceRoom::getVoiceRoomUrl(bool noProtocol) const - { - if (!this->isValid()) { return {}; } - return (noProtocol ? QStringLiteral("") : CVoiceRoom::protocolComplete()) % m_hostname % u"/" % m_channel; - } - - void CVoiceRoom::setVoiceRoomUrl(const QString &serverUrl) - { - if (serverUrl.isEmpty()) - { - m_hostname.clear(); - m_channel.clear(); - } - else if (serverUrl.contains("/")) - { - QString url = serverUrl.trimmed().toLower(); - url.replace(CVoiceRoom::protocolComplete(), ""); - url.replace(CVoiceRoom::protocol(), ""); - const QStringList splitParts = url.split("/"); - m_hostname = splitParts.at(0); - m_channel = splitParts.at(1); - } - } - - bool CVoiceRoom::isAtis() const - { - return (m_channel.contains("ATIS", Qt::CaseInsensitive)); - } - - bool CVoiceRoom::canTalkTo() const - { - return this->isConnected() && !this->isAtis(); - } - } // ns -} // ns diff --git a/src/blackmisc/audio/voiceroom.h b/src/blackmisc/audio/voiceroom.h deleted file mode 100644 index 030f84d6e..000000000 --- a/src/blackmisc/audio/voiceroom.h +++ /dev/null @@ -1,126 +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. 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_AUDIO_VOICEROOM_H -#define BLACKMISC_AUDIO_VOICEROOM_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/metaclass.h" -#include "blackmisc/propertyindex.h" -#include "blackmisc/valueobject.h" -#include "blackmisc/variant.h" - -#include -#include - -namespace BlackMisc -{ - namespace Audio - { - //! Value object encapsulating information of a voice room - class BLACKMISC_EXPORT CVoiceRoom : public CValueObject - { - public: - //! Properties by index - enum ColumnIndex - { - IndexHostname = CPropertyIndex::GlobalIndexCVoiceRoom, - IndexChannel, - IndexUrl, - IndexConnected, - IndexAudioPlaying - }; - - //! Default constructor. - CVoiceRoom() : m_connected(false), m_audioPlaying(false) {} - - //! Constructor. - CVoiceRoom(const QString &hostname, const QString &channel) : - m_hostname(hostname), m_channel(channel), m_connected(false), m_audioPlaying(false) {} - - //! Constructor. - CVoiceRoom(const QString &voiceRoomUrl, bool connected = false); - - //! Get the host name - const QString &getHostname() const { return m_hostname; } - - //! Get the voice room channel - const QString &getChannel() const { return m_channel; } - - //! Set the host name - void setHostName(const QString &hostName) { m_hostname = hostName; } - - //! Set the voice channel - void setChannel(const QString &channel) { m_channel = channel; } - - //! Server URL - //! \param noProtocol either with (pseudo) protocol prefix or without - QString getVoiceRoomUrl(bool noProtocol = true) const; - - //! Set voice room URL - void setVoiceRoomUrl(const QString &serverUrl); - - //! Valid voice room object? - bool isValid() const { return !m_hostname.isEmpty() && !m_channel.isEmpty(); } - - //! Is connected? - bool isConnected() const { return this->isValid() && m_connected; } - - //! Set connection status - void setConnected(bool isConnected) { m_connected = isConnected; } - - //! Is audio playing in this room? - bool isAudioPlaying() const { return m_audioPlaying; } - - //! Set audio playing - void setAudioPlaying(bool playing) { m_audioPlaying = playing; } - - //! Is ATIS voice channel - bool isAtis() const; - - //! Can talk to channel - bool canTalkTo() const; - - //! \copydoc BlackMisc::Mixin::Index::propertyByIndex - CVariant propertyByIndex(const BlackMisc::CPropertyIndex &index) const; - - //! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex - void setPropertyByIndex(const BlackMisc::CPropertyIndex &index, const CVariant &variant); - - //! Protocol prefix "vvl" - static const QString &protocol() { static QString p("vvl"); return p; } - - //! Protocol - //! \return with protocol prefix or without - static const QString &protocolComplete() { static QString p("vvl://"); return p; } - - //! \copydoc BlackMisc::Mixin::String::toQString - QString convertToQString(bool i18n = false) const; - - private: - QString m_hostname; - QString m_channel; - bool m_connected; - bool m_audioPlaying; - - BLACK_METACLASS( - CVoiceRoom, - BLACK_METAMEMBER(hostname), - BLACK_METAMEMBER(channel), - BLACK_METAMEMBER(connected), - BLACK_METAMEMBER(audioPlaying) - ); - }; - } // ns -} // ns - -Q_DECLARE_METATYPE(BlackMisc::Audio::CVoiceRoom) - -#endif // guard diff --git a/src/blackmisc/audio/voiceroomlist.cpp b/src/blackmisc/audio/voiceroomlist.cpp deleted file mode 100644 index 76ea62fa0..000000000 --- a/src/blackmisc/audio/voiceroomlist.cpp +++ /dev/null @@ -1,48 +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. 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 "blackmisc/audio/voiceroom.h" -#include "blackmisc/audio/voiceroomlist.h" - -#include -#include - -namespace BlackMisc -{ - namespace Audio - { - - CVoiceRoomList::CVoiceRoomList() { } - - CVoiceRoomList::CVoiceRoomList(const CSequence &other) : - CSequence(other) - { } - - int CVoiceRoomList::countCanTalkTo() const - { - int c = 0; - for (const CVoiceRoom &r : *this) - { - if (r.canTalkTo()) { c++; } - } - return c; - } - - const CVoiceRoomList &CVoiceRoomList::twoEmptyRooms() - { - static CVoiceRoomList emptyRooms; - if (emptyRooms.isEmpty()) - { - emptyRooms.push_back(CVoiceRoom()); - emptyRooms.push_back(CVoiceRoom()); - } - return emptyRooms; - } - - } // namespace -} // namespace diff --git a/src/blackmisc/audio/voiceroomlist.h b/src/blackmisc/audio/voiceroomlist.h deleted file mode 100644 index 231f407dd..000000000 --- a/src/blackmisc/audio/voiceroomlist.h +++ /dev/null @@ -1,57 +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. 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_AUDIO_VOICEROOMLIST_H -#define BLACKMISC_AUDIO_VOICEROOMLIST_H - -#include "blackmisc/blackmiscexport.h" -#include "blackmisc/collection.h" -#include "blackmisc/sequence.h" -#include "blackmisc/variant.h" -#include "voiceroom.h" - -#include - -namespace BlackMisc -{ - namespace Audio - { - class CVoiceRoom; - - //! Value object encapsulating a list of voice rooms. - class BLACKMISC_EXPORT CVoiceRoomList : - public CSequence, - public BlackMisc::Mixin::MetaType - { - public: - BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CVoiceRoomList) - using CSequence::CSequence; - - //! Default constructor. - CVoiceRoomList(); - - //! Construct from a base class object. - CVoiceRoomList(const CSequence &other); - - //! Count how many rooms can be talked to - int countCanTalkTo() const; - - //! Frequently needed for voice room resolutions - static const CVoiceRoomList &twoEmptyRooms(); - }; - - } //namespace -} // namespace - -Q_DECLARE_METATYPE(BlackMisc::Audio::CVoiceRoomList) -Q_DECLARE_METATYPE(BlackMisc::CCollection) -Q_DECLARE_METATYPE(BlackMisc::CSequence) - -#endif //guard diff --git a/src/blackmisc/aviation/atcstation.cpp b/src/blackmisc/aviation/atcstation.cpp index 6b43d9bd3..1219fc323 100644 --- a/src/blackmisc/aviation/atcstation.cpp +++ b/src/blackmisc/aviation/atcstation.cpp @@ -7,7 +7,6 @@ */ #include "blackmisc/aviation/atcstation.h" -#include "blackmisc/audio/voiceroom.h" #include "blackmisc/aviation/comsystem.h" #include "blackmisc/compare.h" #include "blackmisc/pq/physicalquantity.h" @@ -24,7 +23,6 @@ using namespace BlackMisc; using namespace BlackMisc::PhysicalQuantities; using namespace BlackMisc::Geo; using namespace BlackMisc::Network; -using namespace BlackMisc::Audio; namespace BlackMisc { @@ -155,7 +153,6 @@ namespace BlackMisc (void)QT_TRANSLATE_NOOP("Aviation", "until(UTC)"); (void)QT_TRANSLATE_NOOP("Aviation", "range"); (void)QT_TRANSLATE_NOOP("Aviation", "distance"); - (void)QT_TRANSLATE_NOOP("Network", "voiceroom"); } void CAtcStation::setFrequency(const CFrequency &frequency) @@ -389,7 +386,6 @@ namespace BlackMisc case IndexIsInRange: return CVariant::fromValue(isInRange()); case IndexAtis: return m_atis.propertyByIndex(index.copyFrontRemoved()); case IndexMetar: return m_metar.propertyByIndex(index.copyFrontRemoved()); - case IndexVoiceRoom: return m_voiceRoom.propertyByIndex(index.copyFrontRemoved()); case IndexIsAfvCrossCoupled: return CVariant::from(m_isAfvCrossCoupled); default: return (ICoordinateWithRelativePosition::canHandleIndex(index)) ? @@ -414,7 +410,6 @@ namespace BlackMisc case IndexRange: m_range.setPropertyByIndex(index.copyFrontRemoved(), variant); break; case IndexAtis: m_atis.setPropertyByIndex(index.copyFrontRemoved(), variant); break; case IndexMetar: m_metar.setPropertyByIndex(index.copyFrontRemoved(), variant); break; - case IndexVoiceRoom: m_voiceRoom.setPropertyByIndex(index.copyFrontRemoved(), variant); break; case IndexIsAfvCrossCoupled: this->setAfvCrossCoupled(variant.value()); break; case IndexCallsignString: case IndexCallsignStringCrossCopuled: @@ -459,7 +454,6 @@ namespace BlackMisc case IndexIsInRange: return Compare::compare(this->isInRange(), compareValue.isInRange()); case IndexAtis: return m_atis.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getAtis()); case IndexMetar: return m_metar.comparePropertyByIndex(index.copyFrontRemoved(), compareValue.getMetar()); - case IndexVoiceRoom: return this->getVoiceRoom().getVoiceRoomUrl().compare(compareValue.getVoiceRoom().getVoiceRoomUrl()); case IndexIsAfvCrossCoupled: return Compare::compare(this->isAfvCrossCoupled(), compareValue.isAfvCrossCoupled()); default: if (ICoordinateWithRelativePosition::canHandleIndex(index)) diff --git a/src/blackmisc/aviation/atcstation.h b/src/blackmisc/aviation/atcstation.h index 658abdf99..20bc7dce1 100644 --- a/src/blackmisc/aviation/atcstation.h +++ b/src/blackmisc/aviation/atcstation.h @@ -11,7 +11,6 @@ #ifndef BLACKMISC_AVIATION_ATCSTATION_H #define BLACKMISC_AVIATION_ATCSTATION_H -#include "blackmisc/audio/voiceroom.h" #include "blackmisc/aviation/callsign.h" #include "blackmisc/aviation/comsystem.h" #include "blackmisc/aviation/informationmessage.h" @@ -62,8 +61,7 @@ namespace BlackMisc IndexLatitude, IndexLongitude, IndexAtis, - IndexMetar, - IndexVoiceRoom, //!< @deprecated + IndexMetar }; //! Default constructor. @@ -181,22 +179,6 @@ namespace BlackMisc //! Set AFV cross coupled void setAfvCrossCoupled(bool coupled) { m_isAfvCrossCoupled = coupled; } - //! Get voice room - //! \deprecated - const Audio::CVoiceRoom &getVoiceRoom() const { return m_voiceRoom; } - - //! Set voice room - //! \deprecated - void setVoiceRoom(const Audio::CVoiceRoom &voiceRoom) { m_voiceRoom = voiceRoom; } - - //! Set voice room URL - //! \deprecated - void setVoiceRoomUrl(const QString &url) { m_voiceRoom.setVoiceRoomUrl(url); } - - //! Valid voice room? - //! \deprecated - bool hasValidVoiceRoom() const { return m_voiceRoom.isValid(); } - //! Booked date/time if any. //! This represents the closest booking within a time frame as there can be multiple bookings. const QDateTime &getBookedFromUtc() const { return m_bookedFromUtc; } @@ -301,7 +283,6 @@ namespace BlackMisc QDateTime m_bookedUntilUtc; CInformationMessage m_atis { CInformationMessage::ATIS }; CInformationMessage m_metar { CInformationMessage::METAR }; - Audio::CVoiceRoom m_voiceRoom; BLACK_METACLASS( CAtcStation, @@ -316,7 +297,6 @@ namespace BlackMisc BLACK_METAMEMBER(bookedUntilUtc), BLACK_METAMEMBER(atis), BLACK_METAMEMBER(metar), - BLACK_METAMEMBER(voiceRoom), BLACK_METAMEMBER(relativeDistance), BLACK_METAMEMBER(relativeBearing) ); diff --git a/src/blackmisc/aviation/atcstationlist.cpp b/src/blackmisc/aviation/atcstationlist.cpp index 04119f3ae..b55f28ade 100644 --- a/src/blackmisc/aviation/atcstationlist.cpp +++ b/src/blackmisc/aviation/atcstationlist.cpp @@ -95,11 +95,6 @@ namespace BlackMisc return c; } - CAtcStationList CAtcStationList::stationsWithValidVoiceRoom() const - { - return this->findBy(&CAtcStation::hasValidVoiceRoom, true); - } - CAtcStationList CAtcStationList::stationsWithValidFrequency() const { return this->findBy(&CAtcStation::hasValidFrequency, true); diff --git a/src/blackmisc/aviation/atcstationlist.h b/src/blackmisc/aviation/atcstationlist.h index e97eba08e..721c53718 100644 --- a/src/blackmisc/aviation/atcstationlist.h +++ b/src/blackmisc/aviation/atcstationlist.h @@ -61,10 +61,6 @@ namespace BlackMisc //! Set online status int setOnline(const CCallsign &callsign, bool online); - //! Find 0..n stations with valid voice room - //! \sa CAtcStation::hasValidVoiceRoom - CAtcStationList stationsWithValidVoiceRoom() const; - //! Find 0..n stations with valid COM frequency //! \sa CAtcStation::hasValidFrequency CAtcStationList stationsWithValidFrequency() const; diff --git a/src/blackmisc/propertyindex.h b/src/blackmisc/propertyindex.h index f7b7e7f6d..d52490cf2 100644 --- a/src/blackmisc/propertyindex.h +++ b/src/blackmisc/propertyindex.h @@ -146,7 +146,6 @@ namespace BlackMisc GlobalIndexCAircraftCfgEntries = 8800, GlobalIndexCDistributor = 8900, GlobalIndexCVPilotModelRule = 9000, - GlobalIndexCVoiceRoom = 10000, GlobalIndexCSettingKeyboardHotkey = 11000, GlobalIndexCKeyboardKey = 11100, GlobalIndexCJoystickButton = 11200, diff --git a/src/blackmisc/test/testing.cpp b/src/blackmisc/test/testing.cpp index 86b55d434..5ec871b85 100644 --- a/src/blackmisc/test/testing.cpp +++ b/src/blackmisc/test/testing.cpp @@ -85,8 +85,6 @@ namespace BlackMisc station.setAtis(atis); station.setMetar(metar); } - - station.setVoiceRoomUrl("vvl://foo.bar.baz/room" + QString::number(index)); return station; }