Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple regression fixes #310

Merged
merged 8 commits into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions src/core/context/contextaudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,29 +321,14 @@ namespace swift::core::context
return this->getAudioDevices().getOutputDevices();
}

CAudioDeviceInfoList CContextAudioBase::getAudioDevicesPlusDefault() const
{
return CAudioDeviceInfoList::allDevicesPlusDefault();
}

CAudioDeviceInfoList CContextAudioBase::getAudioInputDevicesPlusDefault() const
{
return this->getAudioDevicesPlusDefault().getInputDevices();
}

CAudioDeviceInfoList CContextAudioBase::getAudioOutputDevicesPlusDefault() const
{
return this->getAudioDevicesPlusDefault().getOutputDevices();
}

CAudioDeviceInfoList CContextAudioBase::getCurrentAudioDevices() const
{
const QString inputDeviceName = m_inputDeviceSetting.get();
const CAudioDeviceInfo inputDevice = this->getAudioInputDevicesPlusDefault().findByNameOrDefault(
const CAudioDeviceInfo inputDevice = this->getAudioInputDevices().findByNameOrDefault(
inputDeviceName, CAudioDeviceInfo::getDefaultInputDevice());

const QString outputDeviceName = m_outputDeviceSetting.get();
const CAudioDeviceInfo outputDevice = this->getAudioOutputDevicesPlusDefault().findByNameOrDefault(
const CAudioDeviceInfo outputDevice = this->getAudioOutputDevices().findByNameOrDefault(
outputDeviceName, CAudioDeviceInfo::getDefaultOutputDevice());

CAudioDeviceInfoList devices;
Expand Down
3 changes: 0 additions & 3 deletions src/core/context/contextaudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ namespace swift::core
swift::misc::audio::CAudioDeviceInfoList getAudioDevices() const;
swift::misc::audio::CAudioDeviceInfoList getAudioInputDevices() const;
swift::misc::audio::CAudioDeviceInfoList getAudioOutputDevices() const;
swift::misc::audio::CAudioDeviceInfoList getAudioDevicesPlusDefault() const;
swift::misc::audio::CAudioDeviceInfoList getAudioInputDevicesPlusDefault() const;
swift::misc::audio::CAudioDeviceInfoList getAudioOutputDevicesPlusDefault() const;
//! @}

//! Get current audio device
Expand Down
9 changes: 6 additions & 3 deletions src/core/fsd/fsdclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,8 +1215,9 @@ namespace swift::core::fsd
CSpeed(dataUpdate.m_groundSpeed, CSpeedUnit::kts()));
situation.setPressureAltitude(CAltitude(dataUpdate.m_altitudePressure, CAltitude::MeanSeaLevel,
CAltitude::PressureAltitude, CLengthUnit::ft()));
// NotSetGroundDetails because here we do not know if this FSD protocol actually utilizes this flag
const COnGroundInfo og(dataUpdate.m_onGround ? COnGroundInfo::OnGround : COnGroundInfo::NotOnGround,
COnGroundInfo::InFromNetwork);
COnGroundInfo::NotSetGroundDetails);
situation.setOnGroundInfo(og);

// Ref T297, default offset time
Expand Down Expand Up @@ -1255,8 +1256,9 @@ namespace swift::core::fsd
CHeading(data.m_heading, CAngleUnit::deg()),
CAngle(-data.m_pitch, CAngleUnit::deg()), CAngle(-data.m_bank, CAngleUnit::deg()),
CSpeed(data.m_groundSpeed, CSpeedUnit::kts()));
// NotSetGroundDetails because here we do not know if this FSD protocol actually utilizes this flag
const COnGroundInfo og(data.m_onGround ? COnGroundInfo::OnGround : COnGroundInfo::NotOnGround,
COnGroundInfo::InFromNetwork);
COnGroundInfo::NotSetGroundDetails);
situation.setOnGroundInfo(og);

// Ref T297, default offset time
Expand Down Expand Up @@ -1756,9 +1758,10 @@ namespace swift::core::fsd
CAngle(interimPilotDataUpdate.m_pitch, CAngleUnit::deg()),
CAngle(interimPilotDataUpdate.m_bank, CAngleUnit::deg()),
CSpeed(interimPilotDataUpdate.m_groundSpeed, CSpeedUnit::kts()));
// NotSetGroundDetails because here we do not know if this FSD protocol actually utilizes this flag
const COnGroundInfo og(interimPilotDataUpdate.m_onGround ? COnGroundInfo::OnGround :
COnGroundInfo::NotOnGround,
COnGroundInfo::InFromNetwork);
COnGroundInfo::NotSetGroundDetails);
situation.setOnGroundInfo(og);

// Ref T297, default offset time
Expand Down
6 changes: 3 additions & 3 deletions src/gui/components/audiodevicevolumesetupcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ namespace swift::gui::components
void CAudioDeviceVolumeSetupComponent::initAudioDeviceLists()
{
if (!this->hasAudio()) { return; }
const bool changed = this->onAudioDevicesChanged(sGui->getCContextAudioBase()->getAudioDevicesPlusDefault());
const bool changed = this->onAudioDevicesChanged(sGui->getCContextAudioBase()->getAudioDevices());
if (!changed) { return; }
const CAudioDeviceInfoList currentDevices = sGui->getCContextAudioBase()->getCurrentAudioDevices();
this->onAudioStarted(currentDevices.getInputDevices().frontOrDefault(),
Expand Down Expand Up @@ -525,14 +525,14 @@ namespace swift::gui::components
CAudioDeviceInfo CAudioDeviceVolumeSetupComponent::getSelectedInputDevice() const
{
if (!hasAudio()) { return CAudioDeviceInfo(); }
const CAudioDeviceInfoList devices = sGui->getCContextAudioBase()->getAudioInputDevicesPlusDefault();
const CAudioDeviceInfoList devices = sGui->getCContextAudioBase()->getAudioInputDevices();
return devices.findByName(ui->cb_SetupAudioInputDevice->currentText());
}

CAudioDeviceInfo CAudioDeviceVolumeSetupComponent::getSelectedOutputDevice() const
{
if (!hasAudio()) { return CAudioDeviceInfo(); }
const CAudioDeviceInfoList devices = sGui->getCContextAudioBase()->getAudioOutputDevicesPlusDefault();
const CAudioDeviceInfoList devices = sGui->getCContextAudioBase()->getAudioOutputDevices();
return devices.findByName(ui->cb_SetupAudioOutputDevice->currentText());
}

Expand Down
2 changes: 0 additions & 2 deletions src/gui/components/interpolationcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ namespace swift::gui::components
ui->setupUi(this);
ui->tw_InterpolationSetup->setCurrentIndex(0);

connect(ui->comp_InterpolationSetup, &CInterpolationSetupComponent::requestRenderingRestrictionsWidget, this,
&CInterpolationComponent::requestRenderingRestrictionsWidget);
connect(ui->comp_CallsignCompleter, &CCallsignCompleter::validChangedCallsignEntered, this,
&CInterpolationComponent::displayInterpolationMessages);
connect(ui->pb_ReloadInterpolationMessages, &QPushButton::released, this,
Expand Down
4 changes: 0 additions & 4 deletions src/gui/components/interpolationcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ namespace swift::gui::components
//! Destructor
virtual ~CInterpolationComponent() override;

signals:
//! Request redering restrictions widget
void requestRenderingRestrictionsWidget();

private:
QScopedPointer<Ui::CInterpolationComponent> ui;

Expand Down
2 changes: 0 additions & 2 deletions src/gui/components/interpolationsetupcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ namespace swift::gui::components
ui->cb_IgnoreGlobal->setChecked(true);
ui->tvp_InterpolationSetup->menuAddItems(CInterpolationSetupView::MenuRemoveSelectedRows);

connect(ui->pb_RenderingSetup, &QPushButton::clicked, this,
&CInterpolationSetupComponent::requestRenderingRestrictionsWidget);
connect(ui->pb_Save, &QPushButton::clicked, this, &CInterpolationSetupComponent::saveSetup);
connect(ui->pb_DeleteOrReset, &QPushButton::clicked, this, &CInterpolationSetupComponent::removeOrResetSetup);
connect(ui->pb_Reload, &QPushButton::clicked, this, &CInterpolationSetupComponent::reloadSetup,
Expand Down
4 changes: 0 additions & 4 deletions src/gui/components/interpolationsetupcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ namespace swift::gui::components
//! Setup mode
Mode getSetupMode() const;

signals:
//! Request restrictions UI
void requestRenderingRestrictionsWidget();

private:
QScopedPointer<Ui::CInterpolationSetupComponent> ui;

Expand Down
11 changes: 0 additions & 11 deletions src/gui/components/interpolationsetupcomponent.ui
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pb_RenderingSetup">
<property name="toolTip">
<string>goto rendering setup</string>
</property>
<property name="text">
<string> rendering</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_DeleteOrReset">
<property name="text">
Expand Down Expand Up @@ -215,7 +205,6 @@
<tabstop>rb_Global</tabstop>
<tabstop>pb_Reload</tabstop>
<tabstop>cb_IgnoreGlobal</tabstop>
<tabstop>pb_RenderingSetup</tabstop>
<tabstop>pb_DeleteOrReset</tabstop>
<tabstop>pb_Save</tabstop>
</tabstops>
Expand Down
2 changes: 2 additions & 0 deletions src/gui/models/aircraftsituationlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace swift::gui::models
m_columns.addColumn(CColumn("latitude", CAircraftSituation::IndexLatitude, new CLatLonFormatter()));
m_columns.addColumn(CColumn("longitude", CAircraftSituation::IndexLongitude, new CLatLonFormatter()));
m_columns.addColumn(CColumn("gs.", CAircraftSituation::IndexGroundSpeed, new CSpeedKtsFormatter()));
m_columns.addColumn(CColumn::standardValueObject("gnd factor", CAircraftSituation::IndexIsOnGroundInfo,
CDefaultFormatter::alignRightVCenter()));
m_columns.addColumn(CColumn::standardString("PBH", "pitch bank heading", CAircraftSituation::IndexPBHInfo));
m_columns.addColumn(CColumn::standardString("gnd.elv.", CAircraftSituation::IndexGroundElevationPlusInfo));
m_columns.addColumn(CColumn::standardString("gnd.elv.alt.", { CAircraftSituation::IndexGroundElevationPlane,
Expand Down
3 changes: 3 additions & 0 deletions src/gui/views/viewbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ namespace swift::gui
//! Settings have been changed
void settingsChanged();

//! Select all rows
void selectAll() override;

//! @{
//! Change selection modes
void setMultiSelection();
Expand Down
12 changes: 12 additions & 0 deletions src/gui/views/viewbasenontemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,18 @@ namespace swift::gui::views
m_displayAutomatically = a->isChecked();
}

void CViewBaseNonTemplate::selectAll()
{
// FIXME: Workaround to implement the logic on our own because the default selectAll() implementation does not
// seem to work
this->clearSelection();
QItemSelection selectedItems;
const int columns = this->model()->columnCount() - 1;
const int rows = this->model()->rowCount() - 1;
selectedItems.select(this->model()->index(0, 0), this->model()->index(rows, columns));
this->selectionModel()->select(selectedItems, QItemSelectionModel::Select);
}

void CViewBaseNonTemplate::setSingleSelection() { this->setSelectionMode(SingleSelection); }

void CViewBaseNonTemplate::setExtendedSelection()
Expand Down
21 changes: 0 additions & 21 deletions src/misc/audio/audiodeviceinfolist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,27 +157,6 @@ namespace swift::misc::audio
return i;
}

CAudioDeviceInfoList CAudioDeviceInfoList::allInputDevicesPlusDefault()
{
CAudioDeviceInfoList i = allInputDevices();
i.push_back(CAudioDeviceInfoList::defaultInputDevice());
return i;
}

CAudioDeviceInfoList CAudioDeviceInfoList::allOutputDevicesPlusDefault()
{
CAudioDeviceInfoList o = allOutputDevices();
o.push_back(CAudioDeviceInfoList::defaultOutputDevice());
return o;
}

CAudioDeviceInfoList CAudioDeviceInfoList::allDevicesPlusDefault()
{
CAudioDeviceInfoList i = allInputDevicesPlusDefault();
i.push_back(allOutputDevicesPlusDefault());
return i;
}

QList<QAudioDevice> CAudioDeviceInfoList::allQtInputDevices()
{
const QList<QAudioDevice> devices = QMediaDevices::audioInputs();
Expand Down
3 changes: 0 additions & 3 deletions src/misc/audio/audiodeviceinfolist.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ namespace swift::misc::audio
static CAudioDeviceInfoList allInputDevices();
static CAudioDeviceInfoList allOutputDevices();
static CAudioDeviceInfoList allDevices();
static CAudioDeviceInfoList allInputDevicesPlusDefault();
static CAudioDeviceInfoList allOutputDevicesPlusDefault();
static CAudioDeviceInfoList allDevicesPlusDefault();
static QList<QAudioDevice> allQtInputDevices();
static QList<QAudioDevice> allQtOutputDevices();
static QAudioDevice defaultQtInputDevice();
Expand Down
2 changes: 1 addition & 1 deletion src/misc/aviation/ongroundinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace swift::misc::aviation
m_onGroundFactor(interpolatedGndFactor)
{
// Clip small ground factor values
if (m_onGroundFactor < 0.0) { m_onGroundFactor = -1.0; }
if (m_onGroundFactor < -0.1) { m_onGroundFactor = -1.0; }
else if (m_onGroundFactor < 0.001) { m_onGroundFactor = 0.0; }
else if (m_onGroundFactor > 0.999) { m_onGroundFactor = 1.0; }
}
Expand Down
2 changes: 1 addition & 1 deletion src/misc/aviation/ongroundinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace swift::misc::aviation
//! Reliability of on ground information
enum OnGroundDetails
{
NotSetGroundDetails,
NotSetGroundDetails, //!< not set or unknown if correct (e.g. FSD might or might not use the flag)
// interpolated situation
OnGroundByInterpolation, //!< strongest for remote aircraft
OnGroundByElevationAndCG,
Expand Down
2 changes: 0 additions & 2 deletions src/sound/audioutilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ namespace swift::sound
if (supportedDevices.isEmpty()) { return {}; }

QAudioDevice deviceWithLowestLatency = supportedDevices.at(0);
deviceWithLowestLatency =
device.isInputDevice() ? QMediaDevices::defaultAudioInput() : QMediaDevices::defaultAudioOutput();

if (supportedDevices.size() > 1)
{
Expand Down
3 changes: 0 additions & 3 deletions src/swiftguistandard/swiftguistdinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,6 @@ void SwiftGuiStd::initGuiSignals()
// interpolation and validation
connect(ui->comp_MainInfoArea->getMappingComponent(), &CMappingComponent::requestValidationDialog, this,
&SwiftGuiStd::displayValidationDialog);
connect(ui->comp_MainInfoArea->getInterpolationComponent(),
&CInterpolationComponent::requestRenderingRestrictionsWidget,
[=] { this->setSettingsPage(CSettingsComponent::SettingTabSimulator); });

// on top
connect(sGui, &CGuiApplication::alwaysOnTop, this, &SwiftGuiStd::onToggledWindowsOnTop, Qt::QueuedConnection);
Expand Down
6 changes: 6 additions & 0 deletions tests/misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ add_swift_test(
LINK_LIBRARIES misc tests_test Qt::Core
)

add_swift_test(
NAME misc_aviation_ongroundinfo
SOURCES aviation/testongroundinfo.cpp
LINK_LIBRARIES misc tests_test Qt::Core
)

##############
## Geo ##
##############
Expand Down
Loading
Loading