mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T739, removed voice room value objects
This commit is contained in:
committed by
Mat Sutcliffe
parent
09e65a2525
commit
7e36e67f89
@@ -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"
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@ namespace BlackMisc
|
||||
{
|
||||
CAudioDeviceInfo::registerMetadata();
|
||||
CAudioDeviceInfoList::registerMetadata();
|
||||
CVoiceRoom::registerMetadata();
|
||||
CVoiceRoomList::registerMetadata();
|
||||
CSettings::registerMetadata();
|
||||
CVoiceSetup::registerMetadata();
|
||||
|
||||
|
||||
@@ -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 <QStringList>
|
||||
#include <QStringBuilder>
|
||||
#include <Qt>
|
||||
|
||||
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<ColumnIndex>();
|
||||
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<CVoiceRoom>(); return; }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexAudioPlaying: this->setAudioPlaying(variant.toBool()); break;
|
||||
case IndexConnected: this->setConnected(variant.toBool()); break;
|
||||
case IndexChannel: this->setChannel(variant.value<QString>()); break;
|
||||
case IndexHostname: this->setHostName(variant.value<QString>()); break;
|
||||
case IndexUrl: this->setVoiceRoomUrl(variant.value<QString>()); 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
|
||||
@@ -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 <QMetaType>
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
//! Value object encapsulating information of a voice room
|
||||
class BLACKMISC_EXPORT CVoiceRoom : public CValueObject<CVoiceRoom>
|
||||
{
|
||||
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
|
||||
@@ -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 <QString>
|
||||
#include <tuple>
|
||||
|
||||
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
|
||||
@@ -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 <QMetaType>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Audio
|
||||
{
|
||||
class CVoiceRoom;
|
||||
|
||||
//! Value object encapsulating a list of voice rooms.
|
||||
class BLACKMISC_EXPORT CVoiceRoomList :
|
||||
public CSequence<CVoiceRoom>,
|
||||
public BlackMisc::Mixin::MetaType<CVoiceRoomList>
|
||||
{
|
||||
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<BlackMisc::Audio::CVoiceRoom>)
|
||||
Q_DECLARE_METATYPE(BlackMisc::CSequence<BlackMisc::Audio::CVoiceRoom>)
|
||||
|
||||
#endif //guard
|
||||
@@ -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<bool>()); 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))
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -146,7 +146,6 @@ namespace BlackMisc
|
||||
GlobalIndexCAircraftCfgEntries = 8800,
|
||||
GlobalIndexCDistributor = 8900,
|
||||
GlobalIndexCVPilotModelRule = 9000,
|
||||
GlobalIndexCVoiceRoom = 10000,
|
||||
GlobalIndexCSettingKeyboardHotkey = 11000,
|
||||
GlobalIndexCKeyboardKey = 11100,
|
||||
GlobalIndexCJoystickButton = 11200,
|
||||
|
||||
@@ -85,8 +85,6 @@ namespace BlackMisc
|
||||
station.setAtis(atis);
|
||||
station.setMetar(metar);
|
||||
}
|
||||
|
||||
station.setVoiceRoomUrl("vvl://foo.bar.baz/room" + QString::number(index));
|
||||
return station;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user