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()
{
QPointer<ISimulator> myself(this);
QTimer::singleShot(0, this, [ = ]
QTimer::singleShot(5, this, [ = ]
{
if (!myself) { return; }
emit this->interpolationAndRenderingSetupChanged();

View File

@@ -34,15 +34,15 @@ namespace BlackGui
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);
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::doubleClicked, this, &CInterpolationSetupComponent::onRowDoubleClicked);
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelChanged, this, &CInterpolationSetupComponent::onModelChanged, Qt::QueuedConnection);
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, Qt::QueuedConnection);
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::modelDataChanged, this, &CInterpolationSetupComponent::onModelChanged, Qt::QueuedConnection);
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::objectsDeleted, this, &CInterpolationSetupComponent::onObjectsDeleted, Qt::QueuedConnection);
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::objectsDeleted, this, &CInterpolationSetupComponent::onObjectsDeleted, Qt::QueuedConnection);
connect(ui->rb_Callsign, &QRadioButton::released, this, &CInterpolationSetupComponent::onModeChanged);
connect(ui->rb_Global, &QRadioButton::released, this, &CInterpolationSetupComponent::onModeChanged);
connect(ui->rb_Global, &QRadioButton::released, this, &CInterpolationSetupComponent::onModeChanged);
if (sGui && sGui->getIContextSimulator())
{
connect(sGui->getIContextSimulator(), &IContextSimulator::interpolationAndRenderingSetupChanged, this, &CInterpolationSetupComponent::onSetupChanged, Qt::QueuedConnection);
@@ -106,9 +106,15 @@ namespace BlackGui
// void
}
void CInterpolationSetupComponent::onReloadSetup()
{
this->reloadSetup();
this->displaySetupsPerCallsign();
}
void CInterpolationSetupComponent::reloadSetup()
{
const bool global = (this->getSetupMode() == CInterpolationSetupComponent::SetupGlobal);
const bool global = (this->getSetupMode() == CInterpolationSetupComponent::SetupGlobal);
const bool overlay = QObject::sender() == ui->pb_Reload;
if (!this->checkPrerequisites(!global, overlay)) { return; }
if (global)
@@ -268,7 +274,7 @@ namespace BlackGui
CInterpolationSetupList setups = ui->tvp_InterpolationSetup->container();
setups.removeByCallsigns(deletedSetups.getCallsigns());
const bool set = this->setSetupsToContext(setups, true);
Q_UNUSED(set);
Q_UNUSED(set)
}
}
} // ns

View File

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

View File

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

View File

@@ -13,6 +13,7 @@
#include <QtGlobal>
using namespace BlackMisc;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Simulation;
@@ -24,13 +25,15 @@ namespace BlackGui
CListModelCallsignObjects("CInterpolationSetupListModel", parent)
{
m_columns.addColumn(CColumn::standardValueObject("cs.", "callsign", CInterpolationAndRenderingSetupPerCallsign::IndexCallsign, CCallsign::IndexCallsignString));
this->m_columns.addColumn(CColumn::standardString("interpolator", CInterpolationAndRenderingSetupPerCallsign::IndexInterpolatorModeAsString));
m_columns.addColumn(CColumn("parts", "aircraft parts", CInterpolationAndRenderingSetupPerCallsign::IndexEnabledAircraftParts, new CBoolIconFormatter("parts", "aircraft parts")));
m_columns.addColumn(CColumn("send gnd.", "send gnd.", CInterpolationAndRenderingSetupPerCallsign::IndexSendGndFlagToSimulator, new CBoolIconFormatter("send gnd.", "send gnd.")));
m_columns.addColumn(CColumn("sc.os.", "fix scenery offset", CInterpolationAndRenderingSetupPerCallsign::IndexFixSceneryOffset, new CBoolIconFormatter("sc.os.", "fix scenery offset")));
this->m_columns.addColumn(CColumn::standardString("interpolator", CInterpolationAndRenderingSetupPerCallsign::IndexInterpolatorModeAsString));
m_columns.addColumn(CColumn("parts", "aircraft parts", CInterpolationAndRenderingSetupPerCallsign::IndexEnabledAircraftParts, new CBoolIconFormatter("parts", "aircraft parts")));
m_columns.addColumn(CColumn("send gnd.", "send gnd.", CInterpolationAndRenderingSetupPerCallsign::IndexSendGndFlagToSimulator, new CBoolIconFormatter("send gnd.", "send gnd.")));
m_columns.addColumn(CColumn("sc.os.", "fix scenery offset", CInterpolationAndRenderingSetupPerCallsign::IndexFixSceneryOffset, new CBoolIconFormatter("sc.os.", "fix scenery offset")));
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("log.int.", "log.interpolation", CInterpolationAndRenderingSetupPerCallsign::IndexLogInterpolation, new CBoolIconFormatter("log.int.", "log.interpolation")));
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("gnd.pitch", "pitch on ground", CInterpolationAndRenderingSetupPerCallsign::IndexPitchOnGround, new CPhysiqalQuantiyFormatter<CAngleUnit, CAngle>(CAngleUnit::deg(), 1)));
// default sort order
this->setSortColumnByPropertyIndex(CCountry::IndexIsoCode);
m_sortOrder = Qt::AscendingOrder;

View File

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

View File

@@ -100,15 +100,15 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexLogInterpolation: return CVariant::fromValue(m_logInterpolation);
case IndexLogInterpolation: return CVariant::fromValue(m_logInterpolation);
case IndexSimulatorDebugMessages: return CVariant::fromValue(m_simulatorDebugMessages);
case IndexForceFullInterpolation: return CVariant::fromValue(m_forceFullInterpolation);
case IndexEnabledAircraftParts: return CVariant::fromValue(m_enabledAircraftParts);
case IndexEnabledAircraftParts: return CVariant::fromValue(m_enabledAircraftParts);
case IndexSendGndFlagToSimulator: return CVariant::fromValue(m_sendGndToSim);
case IndexInterpolatorMode: return CVariant::fromValue(m_interpolatorMode);
case IndexInterpolatorMode: return CVariant::fromValue(m_interpolatorMode);
case IndexInterpolatorModeAsString: return CVariant::fromValue(this->getInterpolatorModeAsString());
case IndexFixSceneryOffset: return CVariant::fromValue(m_fixSceneryOffset);
case IndexPitchOnGround: return CVariant::fromValue(m_pitchOnGround);
case IndexPitchOnGround: return CVariant::fromValue(m_pitchOnGround);
default: break;
}
BLACK_VERIFY_X(false, Q_FUNC_INFO, "Cannot handle index");
@@ -120,15 +120,15 @@ namespace BlackMisc
const ColumnIndex i = index.frontCasted<ColumnIndex>();
switch (i)
{
case IndexLogInterpolation: m_logInterpolation = variant.toBool(); return;
case IndexLogInterpolation: m_logInterpolation = variant.toBool(); return;
case IndexSimulatorDebugMessages: m_simulatorDebugMessages = variant.toBool(); return;
case IndexForceFullInterpolation: m_forceFullInterpolation = variant.toBool(); return;
case IndexEnabledAircraftParts: m_enabledAircraftParts = variant.toBool(); return;
case IndexEnabledAircraftParts: m_enabledAircraftParts = variant.toBool(); return;
case IndexSendGndFlagToSimulator: m_sendGndToSim = variant.toBool(); return;
case IndexInterpolatorMode: m_interpolatorMode = variant.toInt(); return;
case IndexInterpolatorMode: m_interpolatorMode = variant.toInt(); return;
case IndexInterpolatorModeAsString: this->setInterpolatorMode(variant.toQString()); return;
case IndexFixSceneryOffset: m_fixSceneryOffset = variant.toBool(); return;
case IndexPitchOnGround: m_pitchOnGround.setPropertyByIndex(index.copyFrontRemoved(), variant); return;
case IndexPitchOnGround: m_pitchOnGround.setPropertyByIndex(index.copyFrontRemoved(), variant); return;
default: break;
}
BLACK_VERIFY_X(false, Q_FUNC_INFO, "Cannot handle index");
@@ -136,7 +136,7 @@ namespace BlackMisc
QString CInterpolationAndRenderingSetupBase::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
Q_UNUSED(i18n)
return
QStringLiteral("Interpolator: ") % this->getInterpolatorModeAsString() %
QStringLiteral(" | Dbg.sim.msgs: ") % boolToYesNo(m_simulatorDebugMessages) %
@@ -276,7 +276,7 @@ namespace BlackMisc
QString CInterpolationAndRenderingSetupGlobal::convertToQString(bool i18n) const
{
Q_UNUSED(i18n);
Q_UNUSED(i18n)
return
CInterpolationAndRenderingSetupBase::convertToQString(i18n) %
QStringLiteral(" max.aircraft:") % QString::number(m_maxRenderedAircraft) %
@@ -329,12 +329,13 @@ namespace BlackMisc
CPropertyIndexList CInterpolationAndRenderingSetupPerCallsign::unequalToGlobal(const CInterpolationAndRenderingSetupGlobal &globalSetup) const
{
CPropertyIndexList diff;
if (this->logInterpolation() != globalSetup.logInterpolation()) { diff.push_back(IndexLogInterpolation); }
if (this->showSimulatorDebugMessages() != globalSetup.showSimulatorDebugMessages()) { diff.push_back(IndexSimulatorDebugMessages); }
if (this->isForcingFullInterpolation() != globalSetup.isForcingFullInterpolation()) { diff.push_back(IndexForceFullInterpolation); }
if (this->isAircraftPartsEnabled() != globalSetup.isAircraftPartsEnabled()) { diff.push_back(IndexEnabledAircraftParts); }
if (this->logInterpolation() != globalSetup.logInterpolation()) { diff.push_back(IndexLogInterpolation); }
if (this->showSimulatorDebugMessages() != globalSetup.showSimulatorDebugMessages()) { diff.push_back(IndexSimulatorDebugMessages); }
if (this->isForcingFullInterpolation() != globalSetup.isForcingFullInterpolation()) { diff.push_back(IndexForceFullInterpolation); }
if (this->isAircraftPartsEnabled() != globalSetup.isAircraftPartsEnabled()) { diff.push_back(IndexEnabledAircraftParts); }
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;
}

View File

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

View File

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

View File

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

View File

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