Some fixes for interpolation setups

* added missing signal
* refresh list on reload button press
* display pitch value
* list ctor for single object
This commit is contained in:
Klaus Basan
2020-04-15 05:30:48 +02:00
committed by Mat Sutcliffe
parent 9b031bb582
commit 148368ca0c
11 changed files with 77 additions and 55 deletions

View File

@@ -969,7 +969,7 @@ namespace BlackCore
void ISimulator::emitInterpolationSetupChanged() void ISimulator::emitInterpolationSetupChanged()
{ {
QPointer<ISimulator> myself(this); QPointer<ISimulator> myself(this);
QTimer::singleShot(0, this, [ = ] QTimer::singleShot(5, this, [ = ]
{ {
if (!myself) { return; } if (!myself) { return; }
emit this->interpolationAndRenderingSetupChanged(); emit this->interpolationAndRenderingSetupChanged();

View File

@@ -36,7 +36,7 @@ namespace BlackGui
connect(ui->pb_RenderingSetup, &QPushButton::clicked, this, &CInterpolationSetupComponent::requestRenderingRestrictionsWidget); connect(ui->pb_RenderingSetup, &QPushButton::clicked, this, &CInterpolationSetupComponent::requestRenderingRestrictionsWidget);
connect(ui->pb_Save, &QPushButton::clicked, this, &CInterpolationSetupComponent::saveSetup); connect(ui->pb_Save, &QPushButton::clicked, this, &CInterpolationSetupComponent::saveSetup);
connect(ui->pb_DeleteOrReset, &QPushButton::clicked, this, &CInterpolationSetupComponent::removeOrResetSetup); connect(ui->pb_DeleteOrReset, &QPushButton::clicked, this, &CInterpolationSetupComponent::removeOrResetSetup);
connect(ui->pb_Reload, &QPushButton::clicked, this, &CInterpolationSetupComponent::reloadSetup); connect(ui->pb_Reload, &QPushButton::clicked, this, &CInterpolationSetupComponent::reloadSetup, Qt::QueuedConnection);
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::doubleClicked, this, &CInterpolationSetupComponent::onRowDoubleClicked); connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::doubleClicked, this, &CInterpolationSetupComponent::onRowDoubleClicked);
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelChanged, this, &CInterpolationSetupComponent::onModelChanged, Qt::QueuedConnection); connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelChanged, this, &CInterpolationSetupComponent::onModelChanged, Qt::QueuedConnection);
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelDataChanged, this, &CInterpolationSetupComponent::onModelChanged, Qt::QueuedConnection); connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelDataChanged, this, &CInterpolationSetupComponent::onModelChanged, Qt::QueuedConnection);
@@ -106,6 +106,12 @@ namespace BlackGui
// void // void
} }
void CInterpolationSetupComponent::onReloadSetup()
{
this->reloadSetup();
this->displaySetupsPerCallsign();
}
void CInterpolationSetupComponent::reloadSetup() void CInterpolationSetupComponent::reloadSetup()
{ {
const bool global = (this->getSetupMode() == CInterpolationSetupComponent::SetupGlobal); const bool global = (this->getSetupMode() == CInterpolationSetupComponent::SetupGlobal);
@@ -268,7 +274,7 @@ namespace BlackGui
CInterpolationSetupList setups = ui->tvp_InterpolationSetup->container(); CInterpolationSetupList setups = ui->tvp_InterpolationSetup->container();
setups.removeByCallsigns(deletedSetups.getCallsigns()); setups.removeByCallsigns(deletedSetups.getCallsigns());
const bool set = this->setSetupsToContext(setups, true); const bool set = this->setSetupsToContext(setups, true);
Q_UNUSED(set); Q_UNUSED(set)
} }
} }
} // ns } // ns

View File

@@ -39,7 +39,7 @@ namespace BlackGui
explicit CInterpolationSetupComponent(QWidget *parent = nullptr); explicit CInterpolationSetupComponent(QWidget *parent = nullptr);
//! Destructor //! Destructor
virtual ~CInterpolationSetupComponent(); virtual ~CInterpolationSetupComponent() override;
//! Setup mode //! Setup mode
Mode getSetupMode() const; Mode getSetupMode() const;
@@ -60,6 +60,9 @@ namespace BlackGui
//! View has been changed //! View has been changed
void onModelChanged(); void onModelChanged();
//! Requested reload
void onReloadSetup();
//! Reload //! Reload
void reloadSetup(); void reloadSetup();

View File

@@ -82,13 +82,13 @@ namespace BlackGui
CStatusMessageList CInterpolationSetupForm::validate(bool nested) const CStatusMessageList CInterpolationSetupForm::validate(bool nested) const
{ {
Q_UNUSED(nested); Q_UNUSED(nested)
return CStatusMessageList(); return CStatusMessageList();
} }
void CInterpolationSetupForm::onCheckboxChanged(int state) void CInterpolationSetupForm::onCheckboxChanged(int state)
{ {
Q_UNUSED(state); Q_UNUSED(state)
emit this->valueChanged(); emit this->valueChanged();
} }
@@ -112,7 +112,7 @@ namespace BlackGui
void CInterpolationSetupForm::onInterpolatorModeChanged(bool checked) void CInterpolationSetupForm::onInterpolatorModeChanged(bool checked)
{ {
Q_UNUSED(checked); Q_UNUSED(checked)
emit this->valueChanged(); emit this->valueChanged();
} }
@@ -126,7 +126,7 @@ namespace BlackGui
{ {
CAngle pitch; CAngle pitch;
const QString p = ui->le_PitchOnGround->text().trimmed(); const QString p = ui->le_PitchOnGround->text().trimmed();
pitch.parseFromString(p, CPqString::SeparatorBestGuess); pitch.parseFromString(p, CPqString::SeparatorBestGuess, CAngleUnit::deg());
return pitch; return pitch;
} }

View File

@@ -13,6 +13,7 @@
#include <QtGlobal> #include <QtGlobal>
using namespace BlackMisc; using namespace BlackMisc;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Aviation; using namespace BlackMisc::Aviation;
using namespace BlackMisc::Simulation; using namespace BlackMisc::Simulation;
@@ -31,6 +32,8 @@ namespace BlackGui
m_columns.addColumn(CColumn("full int.", "full interpolation", CInterpolationAndRenderingSetupPerCallsign::IndexForceFullInterpolation, new CBoolIconFormatter("full int.", "full interpolation"))); m_columns.addColumn(CColumn("full int.", "full interpolation", CInterpolationAndRenderingSetupPerCallsign::IndexForceFullInterpolation, new CBoolIconFormatter("full int.", "full interpolation")));
m_columns.addColumn(CColumn("sim.dbg.", "simulator debug", CInterpolationAndRenderingSetupPerCallsign::IndexSimulatorDebugMessages, new CBoolIconFormatter("sim.dbg.", "simulator debug"))); m_columns.addColumn(CColumn("sim.dbg.", "simulator debug", CInterpolationAndRenderingSetupPerCallsign::IndexSimulatorDebugMessages, new CBoolIconFormatter("sim.dbg.", "simulator debug")));
m_columns.addColumn(CColumn("log.int.", "log.interpolation", CInterpolationAndRenderingSetupPerCallsign::IndexLogInterpolation, new CBoolIconFormatter("log.int.", "log.interpolation"))); m_columns.addColumn(CColumn("log.int.", "log.interpolation", CInterpolationAndRenderingSetupPerCallsign::IndexLogInterpolation, new CBoolIconFormatter("log.int.", "log.interpolation")));
m_columns.addColumn(CColumn("gnd.pitch", "pitch on ground", CInterpolationAndRenderingSetupPerCallsign::IndexPitchOnGround, new CPhysiqalQuantiyFormatter<CAngleUnit, CAngle>(CAngleUnit::deg(), 1)));
// default sort order // default sort order
this->setSortColumnByPropertyIndex(CCountry::IndexIsoCode); this->setSortColumnByPropertyIndex(CCountry::IndexIsoCode);
m_sortOrder = Qt::AscendingOrder; m_sortOrder = Qt::AscendingOrder;

View File

@@ -31,7 +31,7 @@ namespace BlackGui
explicit CInterpolationSetupListModel(QObject *parent = nullptr); explicit CInterpolationSetupListModel(QObject *parent = nullptr);
//! Destructor //! Destructor
virtual ~CInterpolationSetupListModel() {} virtual ~CInterpolationSetupListModel() override {}
}; };
} // ns } // ns
} // ns } // ns

View File

@@ -136,7 +136,7 @@ namespace BlackMisc
QString CInterpolationAndRenderingSetupBase::convertToQString(bool i18n) const QString CInterpolationAndRenderingSetupBase::convertToQString(bool i18n) const
{ {
Q_UNUSED(i18n); Q_UNUSED(i18n)
return return
QStringLiteral("Interpolator: ") % this->getInterpolatorModeAsString() % QStringLiteral("Interpolator: ") % this->getInterpolatorModeAsString() %
QStringLiteral(" | Dbg.sim.msgs: ") % boolToYesNo(m_simulatorDebugMessages) % QStringLiteral(" | Dbg.sim.msgs: ") % boolToYesNo(m_simulatorDebugMessages) %
@@ -276,7 +276,7 @@ namespace BlackMisc
QString CInterpolationAndRenderingSetupGlobal::convertToQString(bool i18n) const QString CInterpolationAndRenderingSetupGlobal::convertToQString(bool i18n) const
{ {
Q_UNUSED(i18n); Q_UNUSED(i18n)
return return
CInterpolationAndRenderingSetupBase::convertToQString(i18n) % CInterpolationAndRenderingSetupBase::convertToQString(i18n) %
QStringLiteral(" max.aircraft:") % QString::number(m_maxRenderedAircraft) % QStringLiteral(" max.aircraft:") % QString::number(m_maxRenderedAircraft) %
@@ -335,6 +335,7 @@ namespace BlackMisc
if (this->isAircraftPartsEnabled() != globalSetup.isAircraftPartsEnabled()) { diff.push_back(IndexEnabledAircraftParts); } if (this->isAircraftPartsEnabled() != globalSetup.isAircraftPartsEnabled()) { diff.push_back(IndexEnabledAircraftParts); }
if (this->isSendingGndFlagToSimulator() != globalSetup.isSendingGndFlagToSimulator()) { diff.push_back(IndexSendGndFlagToSimulator); } if (this->isSendingGndFlagToSimulator() != globalSetup.isSendingGndFlagToSimulator()) { diff.push_back(IndexSendGndFlagToSimulator); }
if (this->isFixingSceneryOffset() != globalSetup.isFixingSceneryOffset()) { diff.push_back(IndexFixSceneryOffset); } if (this->isFixingSceneryOffset() != globalSetup.isFixingSceneryOffset()) { diff.push_back(IndexFixSceneryOffset); }
if (this->getPitchOnGround() != globalSetup.getPitchOnGround()) { diff.push_back(IndexPitchOnGround); }
return diff; return diff;
} }

View File

@@ -14,8 +14,14 @@ namespace BlackMisc
{ {
CInterpolationSetupList::CInterpolationSetupList() { } CInterpolationSetupList::CInterpolationSetupList() { }
CInterpolationSetupList::CInterpolationSetupList(const CInterpolationAndRenderingSetupPerCallsign &setup)
{
this->push_back(setup);
}
CInterpolationSetupList::CInterpolationSetupList(const CSequence<CInterpolationAndRenderingSetupPerCallsign> &other) : CInterpolationSetupList::CInterpolationSetupList(const CSequence<CInterpolationAndRenderingSetupPerCallsign> &other) :
CSequence<CInterpolationAndRenderingSetupPerCallsign>(other) CSequence<CInterpolationAndRenderingSetupPerCallsign>(other)
{ } { }
} // namespace } // namespace
} // namespace } // namespace

View File

@@ -35,6 +35,9 @@ namespace BlackMisc
//! Default constructor. //! Default constructor.
CInterpolationSetupList(); CInterpolationSetupList();
//! Single object
CInterpolationSetupList(const CInterpolationAndRenderingSetupPerCallsign &setup);
//! Construct from a base class object. //! Construct from a base class object.
CInterpolationSetupList(const CSequence<CInterpolationAndRenderingSetupPerCallsign> &other); CInterpolationSetupList(const CSequence<CInterpolationAndRenderingSetupPerCallsign> &other);
}; };

View File

@@ -17,8 +17,8 @@ namespace BlackMisc
CInterpolationAndRenderingSetupPerCallsign IInterpolationSetupProvider::getInterpolationSetupPerCallsignOrDefault(const CCallsign &callsign) const CInterpolationAndRenderingSetupPerCallsign IInterpolationSetupProvider::getInterpolationSetupPerCallsignOrDefault(const CCallsign &callsign) const
{ {
QReadLocker l(&m_lockSetup); QReadLocker l(&m_lockSetup);
if (!m_setups.contains(callsign)) { return CInterpolationAndRenderingSetupPerCallsign(callsign, m_globalSetup); } if (!m_setupsPerCallsign.contains(callsign)) { return CInterpolationAndRenderingSetupPerCallsign(callsign, m_globalSetup); }
return m_setups.value(callsign); return m_setupsPerCallsign.value(callsign);
} }
CInterpolationSetupList IInterpolationSetupProvider::getInterpolationSetupsPerCallsign() const CInterpolationSetupList IInterpolationSetupProvider::getInterpolationSetupsPerCallsign() const
@@ -30,7 +30,7 @@ namespace BlackMisc
bool IInterpolationSetupProvider::hasSetupsPerCallsign() const bool IInterpolationSetupProvider::hasSetupsPerCallsign() const
{ {
QReadLocker l(&m_lockSetup); QReadLocker l(&m_lockSetup);
return !m_setups.isEmpty(); return !m_setupsPerCallsign.isEmpty();
} }
bool IInterpolationSetupProvider::setInterpolationSetupsPerCallsign(const CInterpolationSetupList &setups, bool ignoreSameAsGlobal) bool IInterpolationSetupProvider::setInterpolationSetupsPerCallsign(const CInterpolationSetupList &setups, bool ignoreSameAsGlobal)
@@ -42,12 +42,12 @@ namespace BlackMisc
if (ignoreSameAsGlobal && setup.isEqualToGlobal(gs)) { continue; } if (ignoreSameAsGlobal && setup.isEqualToGlobal(gs)) { continue; }
setupsPerCs.insert(setup.getCallsign(), setup); setupsPerCs.insert(setup.getCallsign(), setup);
} }
{ {
QWriteLocker l(&m_lockSetup); QWriteLocker l(&m_lockSetup);
if (m_setups.isEmpty() && setupsPerCs.isEmpty()) { return false; } if (m_setupsPerCallsign.isEmpty() && setupsPerCs.isEmpty()) { return false; }
m_setups = setupsPerCs; m_setupsPerCallsign = setupsPerCs;
} }
this->emitInterpolationSetupChanged();
return true; return true;
} }
@@ -61,7 +61,7 @@ namespace BlackMisc
{ {
const SetupsPerCallsign setups = this->getSetupsPerCallsign(); const SetupsPerCallsign setups = this->getSetupsPerCallsign();
CCallsignSet callsigns; CCallsignSet callsigns;
for (const auto &pair : makePairsRange(setups)) for (const auto pair : makePairsRange(setups))
{ {
if (pair.second.logInterpolation()) { callsigns.insert(pair.first); } if (pair.second.logInterpolation()) { callsigns.insert(pair.first); }
} }
@@ -71,8 +71,8 @@ namespace BlackMisc
bool IInterpolationSetupProvider::isLogCallsign(const CCallsign &callsign) const bool IInterpolationSetupProvider::isLogCallsign(const CCallsign &callsign) const
{ {
QReadLocker l(&m_lockSetup); QReadLocker l(&m_lockSetup);
if (!m_setups.contains(callsign)) { return false; } if (!m_setupsPerCallsign.contains(callsign)) { return false; }
return m_setups[callsign].logInterpolation(); return m_setupsPerCallsign[callsign].logInterpolation();
} }
bool IInterpolationSetupProvider::setInterpolationMode(const QString &modeAsString, const CCallsign &callsign) bool IInterpolationSetupProvider::setInterpolationMode(const QString &modeAsString, const CCallsign &callsign)
@@ -112,13 +112,13 @@ namespace BlackMisc
if (setup.isEqualToGlobal(gs)) if (setup.isEqualToGlobal(gs))
{ {
QWriteLocker l(&m_lockSetup); QWriteLocker l(&m_lockSetup);
m_setups.remove(callsign); m_setupsPerCallsign.remove(callsign);
return false; return false;
} }
} }
{ {
QWriteLocker l(&m_lockSetup); QWriteLocker l(&m_lockSetup);
m_setups[callsign] = setup; m_setupsPerCallsign[callsign] = setup;
} }
this->emitInterpolationSetupChanged(); this->emitInterpolationSetupChanged();
return true; return true;
@@ -129,7 +129,7 @@ namespace BlackMisc
bool removed = false; bool removed = false;
{ {
QWriteLocker l(&m_lockSetup); QWriteLocker l(&m_lockSetup);
removed = m_setups.remove(callsign) > 0; removed = m_setupsPerCallsign.remove(callsign) > 0;
} }
if (removed) { this->emitInterpolationSetupChanged(); } if (removed) { this->emitInterpolationSetupChanged(); }
return removed; return removed;
@@ -152,7 +152,7 @@ namespace BlackMisc
// on the other side, we keep locks for a minimal time frame // on the other side, we keep locks for a minimal time frame
SetupsPerCallsign setupsToKeep; SetupsPerCallsign setupsToKeep;
CInterpolationAndRenderingSetupGlobal global = this->getInterpolationSetupGlobal(); CInterpolationAndRenderingSetupGlobal global = this->getInterpolationSetupGlobal();
for (const auto &pair : makePairsRange(setupsCopy)) for (const auto pair : makePairsRange(setupsCopy))
{ {
CInterpolationAndRenderingSetupPerCallsign setup = pair.second; CInterpolationAndRenderingSetupPerCallsign setup = pair.second;
setup.setLogInterpolation(false); setup.setLogInterpolation(false);
@@ -161,7 +161,7 @@ namespace BlackMisc
} }
{ {
QWriteLocker l(&m_lockSetup); QWriteLocker l(&m_lockSetup);
m_setups = setupsToKeep; m_setupsPerCallsign = setupsToKeep;
} }
this->emitInterpolationSetupChanged(); this->emitInterpolationSetupChanged();
} }
@@ -171,8 +171,8 @@ namespace BlackMisc
int r = 0; int r = 0;
{ {
QWriteLocker l(&m_lockSetup); QWriteLocker l(&m_lockSetup);
r = m_setups.size(); r = m_setupsPerCallsign.size();
m_setups.clear(); m_setupsPerCallsign.clear();
} }
if (r > 0) { this->emitInterpolationSetupChanged(); } if (r > 0) { this->emitInterpolationSetupChanged(); }
@@ -193,7 +193,7 @@ namespace BlackMisc
IInterpolationSetupProvider::SetupsPerCallsign IInterpolationSetupProvider::getSetupsPerCallsign() const IInterpolationSetupProvider::SetupsPerCallsign IInterpolationSetupProvider::getSetupsPerCallsign() const
{ {
QReadLocker l(&m_lockSetup); QReadLocker l(&m_lockSetup);
return m_setups; return m_setupsPerCallsign;
} }
// pin vtables to this file // pin vtables to this file

View File

@@ -102,7 +102,7 @@ namespace BlackMisc
private: private:
CInterpolationAndRenderingSetupGlobal m_globalSetup; CInterpolationAndRenderingSetupGlobal m_globalSetup;
SetupsPerCallsign m_setups; SetupsPerCallsign m_setupsPerCallsign;
mutable QReadWriteLock m_lockSetup; //!< lock clients mutable QReadWriteLock m_lockSetup; //!< lock clients
}; };