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));
if (!this->isConnectedAndNotShuttingDown()) { return; }
// URL
const QString trimmedUrl = url.trimmed();
CPropertyIndexVariantMap vm({ CAtcStation::IndexVoiceRoom, CVoiceRoom::IndexUrl }, trimmedUrl);
const int changedOnline = this->updateOnlineStation(callsign, vm, true, true);

View File

@@ -232,7 +232,7 @@ namespace BlackCore
if (changed)
{
emit changedSelectedAudioDevices(this->getCurrentAudioDevices());
emit this->changedSelectedAudioDevices(this->getCurrentAudioDevices());
}
}
@@ -304,7 +304,7 @@ namespace BlackCore
Q_ASSERT(getIContextOwnAircraft());
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms; }
CVoiceRoomList currentRooms = getComVoiceRooms();
CVoiceRoomList currentRooms = this->getComVoiceRooms();
CVoiceRoom currentRoomCom1 = currentRooms[0];
CVoiceRoom currentRoomCom2 = currentRooms[1];
CVoiceRoom newRoomCom1 = newRooms[0];
@@ -313,13 +313,13 @@ namespace BlackCore
bool changed = false;
// 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())
{
QSharedPointer<IVoiceChannel> oldVoiceChannel = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com1);
QSharedPointer<IVoiceChannel> oldVoiceChannel = m_voiceChannelMapping.value(CComSystem::Com1);
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 (!m_voiceChannelMapping.values().contains(oldVoiceChannel))
@@ -329,13 +329,13 @@ namespace BlackCore
}
else
{
emit this->changedVoiceRooms(getComVoiceRooms(), false);
emit this->changedVoiceRooms(this->getComVoiceRooms(), false);
}
}
if (newRoomCom1.isValid())
{
QSharedPointer<IVoiceChannel> newVoiceChannel = getVoiceChannelBy(newRoomCom1);
QSharedPointer<IVoiceChannel> newVoiceChannel = this->getVoiceChannelBy(newRoomCom1);
newVoiceChannel->setOwnAircraftCallsign(ownCallsign);
bool inUse = m_voiceChannelMapping.values().contains(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.
if (currentRoomCom2.getVoiceRoomUrl() != newRoomCom2.getVoiceRoomUrl())
{
auto oldVoiceChannel = m_voiceChannelMapping.value(BlackMisc::Aviation::CComSystem::Com2);
auto oldVoiceChannel = m_voiceChannelMapping.value(CComSystem::Com2);
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 (!m_voiceChannelMapping.values().contains(oldVoiceChannel))
@@ -369,7 +369,7 @@ namespace BlackCore
}
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
if (this->getIContextNetwork())
{
this->resolveVoiceRooms();
this->resolveVoiceRooms(); // init own aircraft
}
}
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 (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
@@ -168,11 +165,11 @@ namespace BlackCore
// requires correct frequencies set
// 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();
if (!m_voiceRoom1UrlOverride.isEmpty()) rooms[0] = CVoiceRoom(m_voiceRoom1UrlOverride);
if (!m_voiceRoom2UrlOverride.isEmpty()) rooms[1] = CVoiceRoom(m_voiceRoom2UrlOverride);
if (!m_voiceRoom1UrlOverride.isEmpty()) { rooms[0] = CVoiceRoom(m_voiceRoom1UrlOverride); }
if (!m_voiceRoom2UrlOverride.isEmpty()) { rooms[1] = CVoiceRoom(m_voiceRoom2UrlOverride); }
// set the rooms
emit this->getIContextApplication()->fakedSetComVoiceRoom(rooms);
@@ -233,7 +230,7 @@ namespace BlackCore
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; }
bool changed;
@@ -245,7 +242,7 @@ namespace BlackCore
if (changed)
{
emit this->changedAircraftCockpit(m_ownAircraft, originator);
this->resolveVoiceRooms();
this->resolveVoiceRooms(); // cockpit COM changed
}
return changed;
}
@@ -326,9 +323,13 @@ namespace BlackCore
{
// any of our active frequencies?
Q_UNUSED(connected);
CSimulatedAircraft myAircraft(getOwnAircraft());
if (atcStation.getFrequency() != myAircraft.getCom1System().getFrequencyActive() && atcStation.getFrequency() != myAircraft.getCom2System().getFrequencyActive()) { return; }
this->resolveVoiceRooms();
const CSimulatedAircraft myAircraft(this->getOwnAircraft());
// 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)
@@ -347,7 +348,7 @@ namespace BlackCore
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << voiceRoom1Url << voiceRoom2Url; }
m_voiceRoom1UrlOverride = voiceRoom1Url.trimmed();
m_voiceRoom2UrlOverride = voiceRoom2Url.trimmed();
this->resolveVoiceRooms();
this->resolveVoiceRooms(); // override
}
void CContextOwnAircraft::enableAutomaticVoiceRoomResolution(bool enable)

View File

@@ -629,7 +629,7 @@ namespace BlackCore
void CContextSimulator::xCtxNetworkConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to)
{
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())
{
m_networkSessionId = this->getIContextNetwork()->getConnectedServer().getServerSessionId();

View File

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

View File

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

View File

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