Ref T373, style

This commit is contained in:
Klaus Basan
2018-09-25 03:20:13 +02:00
parent 84970760c1
commit 5c165c4fe7
7 changed files with 30 additions and 31 deletions

View File

@@ -617,6 +617,8 @@ namespace BlackCore
{ {
Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this)); Q_ASSERT(CThreadUtils::isCurrentThreadObjectThread(this));
if (!this->isConnectedAndNotShuttingDown()) { return; } if (!this->isConnectedAndNotShuttingDown()) { return; }
// URL
const QString trimmedUrl = url.trimmed(); const QString trimmedUrl = url.trimmed();
CPropertyIndexVariantMap vm({ CAtcStation::IndexVoiceRoom, CVoiceRoom::IndexUrl }, trimmedUrl); CPropertyIndexVariantMap vm({ CAtcStation::IndexVoiceRoom, CVoiceRoom::IndexUrl }, trimmedUrl);
const int changedOnline = this->updateOnlineStation(callsign, vm, true, true); const int changedOnline = this->updateOnlineStation(callsign, vm, true, true);

View File

@@ -232,7 +232,7 @@ namespace BlackCore
if (changed) if (changed)
{ {
emit changedSelectedAudioDevices(this->getCurrentAudioDevices()); emit this->changedSelectedAudioDevices(this->getCurrentAudioDevices());
} }
} }
@@ -304,7 +304,7 @@ namespace BlackCore
Q_ASSERT(getIContextOwnAircraft()); Q_ASSERT(getIContextOwnAircraft());
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms; }
CVoiceRoomList currentRooms = getComVoiceRooms(); CVoiceRoomList currentRooms = this->getComVoiceRooms();
CVoiceRoom currentRoomCom1 = currentRooms[0]; CVoiceRoom currentRoomCom1 = currentRooms[0];
CVoiceRoom currentRoomCom2 = currentRooms[1]; CVoiceRoom currentRoomCom2 = currentRooms[1];
CVoiceRoom newRoomCom1 = newRooms[0]; CVoiceRoom newRoomCom1 = newRooms[0];
@@ -316,10 +316,10 @@ namespace BlackCore
// changed rooms? But only compare on "URL", not status as connected etc. // changed rooms? But only compare on "URL", not status as connected etc.
if (currentRoomCom1.getVoiceRoomUrl() != newRoomCom1.getVoiceRoomUrl()) if (currentRoomCom1.getVoiceRoomUrl() != newRoomCom1.getVoiceRoomUrl())
{ {
QSharedPointer<IVoiceChannel> oldVoiceChannel = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com1); QSharedPointer<IVoiceChannel> oldVoiceChannel = m_voiceChannelMapping.value(CComSystem::Com1);
if (oldVoiceChannel) if (oldVoiceChannel)
{ {
m_voiceChannelMapping.remove(BlackMisc::Aviation::CComSystem::Com1); m_voiceChannelMapping.remove(CComSystem::Com1);
// If the voice channel is not used by anybody else // If the voice channel is not used by anybody else
if (!m_voiceChannelMapping.values().contains(oldVoiceChannel)) if (!m_voiceChannelMapping.values().contains(oldVoiceChannel))
@@ -329,13 +329,13 @@ namespace BlackCore
} }
else else
{ {
emit this->changedVoiceRooms(getComVoiceRooms(), false); emit this->changedVoiceRooms(this->getComVoiceRooms(), false);
} }
} }
if (newRoomCom1.isValid()) if (newRoomCom1.isValid())
{ {
QSharedPointer<IVoiceChannel> newVoiceChannel = getVoiceChannelBy(newRoomCom1); QSharedPointer<IVoiceChannel> newVoiceChannel = this->getVoiceChannelBy(newRoomCom1);
newVoiceChannel->setOwnAircraftCallsign(ownCallsign); newVoiceChannel->setOwnAircraftCallsign(ownCallsign);
bool inUse = m_voiceChannelMapping.values().contains(newVoiceChannel); bool inUse = m_voiceChannelMapping.values().contains(newVoiceChannel);
m_voiceChannelMapping.insert(BlackMisc::Aviation::CComSystem::Com1, newVoiceChannel); m_voiceChannelMapping.insert(BlackMisc::Aviation::CComSystem::Com1, newVoiceChannel);
@@ -356,10 +356,10 @@ namespace BlackCore
// changed rooms? But only compare on "URL", not status as connected etc. // changed rooms? But only compare on "URL", not status as connected etc.
if (currentRoomCom2.getVoiceRoomUrl() != newRoomCom2.getVoiceRoomUrl()) if (currentRoomCom2.getVoiceRoomUrl() != newRoomCom2.getVoiceRoomUrl())
{ {
auto oldVoiceChannel = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com2); auto oldVoiceChannel = m_voiceChannelMapping.value(CComSystem::Com2);
if (oldVoiceChannel) if (oldVoiceChannel)
{ {
m_voiceChannelMapping.remove(BlackMisc::Aviation::CComSystem::Com2); m_voiceChannelMapping.remove(CComSystem::Com2);
// If the voice channel is not used by anybody else // If the voice channel is not used by anybody else
if (!m_voiceChannelMapping.values().contains(oldVoiceChannel)) if (!m_voiceChannelMapping.values().contains(oldVoiceChannel))
@@ -369,7 +369,7 @@ namespace BlackCore
} }
else else
{ {
emit this->changedVoiceRooms(getComVoiceRooms(), false); emit this->changedVoiceRooms(this->getComVoiceRooms(), false);
} }
} }

View File

@@ -151,15 +151,12 @@ namespace BlackCore
// voice rooms, if network is already available // voice rooms, if network is already available
if (this->getIContextNetwork()) if (this->getIContextNetwork())
{ {
this->resolveVoiceRooms(); this->resolveVoiceRooms(); // init own aircraft
} }
} }
void CContextOwnAircraft::resolveVoiceRooms() void CContextOwnAircraft::resolveVoiceRooms()
{ {
Q_ASSERT(this->getIContextAudio());
Q_ASSERT(this->getIContextNetwork());
Q_ASSERT(this->getIContextApplication());
if (!this->getIContextNetwork() || !this->getIContextAudio() || !this->getIContextApplication()) { return; } // no chance to resolve rooms if (!this->getIContextNetwork() || !this->getIContextAudio() || !this->getIContextApplication()) { return; } // no chance to resolve rooms
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
@@ -168,11 +165,11 @@ namespace BlackCore
// requires correct frequencies set // requires correct frequencies set
// but local network uses exactly this object here, so if frequencies are set here, // but local network uses exactly this object here, so if frequencies are set here,
// they are for network context as well // they are set for network context as well
CVoiceRoomList rooms = this->getIContextNetwork()->getSelectedVoiceRooms(); CVoiceRoomList rooms = this->getIContextNetwork()->getSelectedVoiceRooms();
if (!m_voiceRoom1UrlOverride.isEmpty()) rooms[0] = CVoiceRoom(m_voiceRoom1UrlOverride); if (!m_voiceRoom1UrlOverride.isEmpty()) { rooms[0] = CVoiceRoom(m_voiceRoom1UrlOverride); }
if (!m_voiceRoom2UrlOverride.isEmpty()) rooms[1] = CVoiceRoom(m_voiceRoom2UrlOverride); if (!m_voiceRoom2UrlOverride.isEmpty()) { rooms[1] = CVoiceRoom(m_voiceRoom2UrlOverride); }
// set the rooms // set the rooms
emit this->getIContextApplication()->fakedSetComVoiceRoom(rooms); emit this->getIContextApplication()->fakedSetComVoiceRoom(rooms);
@@ -233,7 +230,7 @@ namespace BlackCore
return changed; return changed;
} }
bool CContextOwnAircraft::updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const CIdentifier &originator) bool CContextOwnAircraft::updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const CTransponder &transponder, const CIdentifier &originator)
{ {
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << com1 << com2 << transponder; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << com1 << com2 << transponder; }
bool changed; bool changed;
@@ -245,7 +242,7 @@ namespace BlackCore
if (changed) if (changed)
{ {
emit this->changedAircraftCockpit(m_ownAircraft, originator); emit this->changedAircraftCockpit(m_ownAircraft, originator);
this->resolveVoiceRooms(); this->resolveVoiceRooms(); // cockpit COM changed
} }
return changed; return changed;
} }
@@ -326,9 +323,13 @@ namespace BlackCore
{ {
// any of our active frequencies? // any of our active frequencies?
Q_UNUSED(connected); Q_UNUSED(connected);
CSimulatedAircraft myAircraft(getOwnAircraft()); const CSimulatedAircraft myAircraft(this->getOwnAircraft());
if (atcStation.getFrequency() != myAircraft.getCom1System().getFrequencyActive() && atcStation.getFrequency() != myAircraft.getCom2System().getFrequencyActive()) { return; }
this->resolveVoiceRooms(); // relevant frequency
if (myAircraft.getCom1System().isActiveFrequencyWithin8_33kHzChannel(atcStation.getFrequency()) || myAircraft.getCom2System().isActiveFrequencyWithin8_33kHzChannel(atcStation.getFrequency()))
{
this->resolveVoiceRooms(); // online status changed
}
} }
void CContextOwnAircraft::xCtxChangedSimulatorModel(const CAircraftModel &model) void CContextOwnAircraft::xCtxChangedSimulatorModel(const CAircraftModel &model)
@@ -347,7 +348,7 @@ namespace BlackCore
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << voiceRoom1Url << voiceRoom2Url; } if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << voiceRoom1Url << voiceRoom2Url; }
m_voiceRoom1UrlOverride = voiceRoom1Url.trimmed(); m_voiceRoom1UrlOverride = voiceRoom1Url.trimmed();
m_voiceRoom2UrlOverride = voiceRoom2Url.trimmed(); m_voiceRoom2UrlOverride = voiceRoom2Url.trimmed();
this->resolveVoiceRooms(); this->resolveVoiceRooms(); // override
} }
void CContextOwnAircraft::enableAutomaticVoiceRoomResolution(bool enable) void CContextOwnAircraft::enableAutomaticVoiceRoomResolution(bool enable)

View File

@@ -629,7 +629,7 @@ namespace BlackCore
void CContextSimulator::xCtxNetworkConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to) void CContextSimulator::xCtxNetworkConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
{ {
Q_UNUSED(from); Q_UNUSED(from);
BLACK_VERIFY_X(getIContextNetwork(), Q_FUNC_INFO, "Missing network context"); BLACK_VERIFY_X(this->getIContextNetwork(), Q_FUNC_INFO, "Missing network context");
if (to == INetwork::Connected && this->getIContextNetwork()) if (to == INetwork::Connected && this->getIContextNetwork())
{ {
m_networkSessionId = this->getIContextNetwork()->getConnectedServer().getServerSessionId(); m_networkSessionId = this->getIContextNetwork()->getConnectedServer().getServerSessionId();

View File

@@ -261,8 +261,7 @@ namespace BlackCore
{ {
Q_ASSERT(m_contextApplication); Q_ASSERT(m_contextApplication);
Q_ASSERT(m_contextOwnAircraft); Q_ASSERT(m_contextOwnAircraft);
c = connect(m_contextApplication, &IContextApplication::fakedSetComVoiceRoom, c = connect(m_contextApplication, &IContextApplication::fakedSetComVoiceRoom, this->getCContextAudio(), &CContextAudio::setComVoiceRooms);
this->getCContextAudio(), &CContextAudio::setComVoiceRooms);
Q_ASSERT(c); Q_ASSERT(c);
c = connect(m_contextOwnAircraft, &IContextOwnAircraft::changedCallsign, this->getCContextAudio(), &IContextAudio::setOwnCallsignForRooms); c = connect(m_contextOwnAircraft, &IContextOwnAircraft::changedCallsign, this->getCContextAudio(), &IContextAudio::setOwnCallsignForRooms);
Q_ASSERT(c); Q_ASSERT(c);

View File

@@ -37,6 +37,7 @@ namespace BlackGui
QFrame(parent), QFrame(parent),
ui(new Ui::CVoiceRoomsComponent) ui(new Ui::CVoiceRoomsComponent)
{ {
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui");
ui->setupUi(this); ui->setupUi(this);
this->setVoiceRoomUrlFieldsReadOnlyState(); this->setVoiceRoomUrlFieldsReadOnlyState();
connect(ui->cb_CockpitVoiceRoom1Override, &QCheckBox::toggled, this, &CVoiceRoomsComponent::onVoiceRoomOverrideChanged); connect(ui->cb_CockpitVoiceRoom1Override, &QCheckBox::toggled, this, &CVoiceRoomsComponent::onVoiceRoomOverrideChanged);

View File

@@ -19,17 +19,13 @@
#include <QObject> #include <QObject>
#include <QScopedPointer> #include <QScopedPointer>
class QWidget;
namespace Ui { class CVoiceRoomsComponent; } namespace Ui { class CVoiceRoomsComponent; }
namespace BlackGui namespace BlackGui
{ {
namespace Components namespace Components
{ {
//! Displays the voice rooms //! Displays the voice rooms
class BLACKGUI_EXPORT CVoiceRoomsComponent : class BLACKGUI_EXPORT CVoiceRoomsComponent : public QFrame
public QFrame
{ {
Q_OBJECT Q_OBJECT