Ref T275, adjusted setup component

* ignore "same as global"
* Qt::QueuedConnection
This commit is contained in:
Klaus Basan
2018-06-21 00:53:42 +02:00
parent d3796fc65a
commit 7b4733fbdd
3 changed files with 48 additions and 16 deletions

View File

@@ -31,6 +31,7 @@ namespace BlackGui
ui(new Ui::CInterpolationSetupComponent) ui(new Ui::CInterpolationSetupComponent)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->cb_IgnoreGlobal->setChecked(true);
ui->tvp_InterpolationSetup->menuAddItems(CInterpolationSetupView::MenuRemoveSelectedRows); ui->tvp_InterpolationSetup->menuAddItems(CInterpolationSetupView::MenuRemoveSelectedRows);
connect(ui->pb_RenderingSetup, &QPushButton::clicked, this, &CInterpolationSetupComponent::requestRenderingRestrictionsWidget); connect(ui->pb_RenderingSetup, &QPushButton::clicked, this, &CInterpolationSetupComponent::requestRenderingRestrictionsWidget);
@@ -38,14 +39,14 @@ namespace BlackGui
connect(ui->pb_Delete, &QPushButton::clicked, this, &CInterpolationSetupComponent::removeSetup); connect(ui->pb_Delete, &QPushButton::clicked, this, &CInterpolationSetupComponent::removeSetup);
connect(ui->pb_Reload, &QPushButton::clicked, this, &CInterpolationSetupComponent::reloadSetup); connect(ui->pb_Reload, &QPushButton::clicked, this, &CInterpolationSetupComponent::reloadSetup);
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); connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelChanged, this, &CInterpolationSetupComponent::onModelChanged, Qt::QueuedConnection);
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelDataChanged, this, &CInterpolationSetupComponent::onModelChanged); connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelDataChanged, this, &CInterpolationSetupComponent::onModelChanged, Qt::QueuedConnection);
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::objectsDeleted, this, &CInterpolationSetupComponent::onObjectsDeleted); connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::objectsDeleted, this, &CInterpolationSetupComponent::onObjectsDeleted, Qt::QueuedConnection);
connect(ui->rb_Callsign, &QRadioButton::released, this, &CInterpolationSetupComponent::onModeChanged); 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()) if (sGui && sGui->getIContextSimulator())
{ {
connect(sGui->getIContextSimulator(), &IContextSimulator::interpolationAndRenderingSetupChanged, this, &CInterpolationSetupComponent::onSetupChanged); connect(sGui->getIContextSimulator(), &IContextSimulator::interpolationAndRenderingSetupChanged, this, &CInterpolationSetupComponent::onSetupChanged, Qt::QueuedConnection);
} }
ui->rb_Global->setChecked(true); ui->rb_Global->setChecked(true);
@@ -100,8 +101,7 @@ namespace BlackGui
void CInterpolationSetupComponent::onModelChanged() void CInterpolationSetupComponent::onModelChanged()
{ {
const CInterpolationSetupList setups = ui->tvp_InterpolationSetup->container(); // void
this->setSetupsToContext(setups);
} }
void CInterpolationSetupComponent::reloadSetup() void CInterpolationSetupComponent::reloadSetup()
@@ -126,9 +126,9 @@ namespace BlackGui
{ {
if (!this->checkPrerequisites(true)) { return; } if (!this->checkPrerequisites(true)) { return; }
CInterpolationAndRenderingSetupPerCallsign setup = ui->form_InterpolationSetup->getValue(); CInterpolationAndRenderingSetupPerCallsign setup = ui->form_InterpolationSetup->getValue();
CInterpolationAndRenderingSetupGlobal gs = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
if (this->getSetupMode() == CInterpolationSetupComponent::Global) if (this->getSetupMode() == CInterpolationSetupComponent::Global)
{ {
CInterpolationAndRenderingSetupGlobal gs = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
gs.setBaseValues(setup); gs.setBaseValues(setup);
gs.setLogInterpolation(false); // that would globally log all values gs.setLogInterpolation(false); // that would globally log all values
sGui->getIContextSimulator()->setInterpolationAndRenderingSetupGlobal(gs); sGui->getIContextSimulator()->setInterpolationAndRenderingSetupGlobal(gs);
@@ -146,6 +146,14 @@ namespace BlackGui
const CCallsign cs = ui->comp_CallsignCompleter->getCallsign(false); const CCallsign cs = ui->comp_CallsignCompleter->getCallsign(false);
if (!cs.isValid()) { return; } if (!cs.isValid()) { return; }
setup.setCallsign(cs); setup.setCallsign(cs);
const bool ignoreGlobal = ui->cb_IgnoreGlobal->isChecked();
if (ignoreGlobal && setup.isEqualToGlobal(gs))
{
static const CStatusMessage m = CStatusMessage(this).validationWarning("Same as global setup");
this->showOverlayMessage(m);
return;
}
CInterpolationSetupList setups = ui->tvp_InterpolationSetup->container(); CInterpolationSetupList setups = ui->tvp_InterpolationSetup->container();
const int replaced = setups.replaceOrAddObjectByCallsign(setup); const int replaced = setups.replaceOrAddObjectByCallsign(setup);
if (replaced < 1) { return; } if (replaced < 1) { return; }
@@ -217,11 +225,12 @@ namespace BlackGui
return true; return true;
} }
bool CInterpolationSetupComponent::setSetupsToContext(const CInterpolationSetupList &setups) bool CInterpolationSetupComponent::setSetupsToContext(const CInterpolationSetupList &setups, bool force)
{ {
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return false; } if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return false; }
if (setups == m_lastSetSetups) { return false; } if (!force && setups == m_lastSetSetups) { return false; }
sGui->getIContextSimulator()->setInterpolationAndRenderingSetupsPerCallsign(setups); const bool ignoreGlobal = ui->cb_IgnoreGlobal->isChecked();
sGui->getIContextSimulator()->setInterpolationAndRenderingSetupsPerCallsign(setups, ignoreGlobal);
m_lastSetSetups = setups; m_lastSetSetups = setups;
return true; return true;
} }
@@ -242,7 +251,7 @@ namespace BlackGui
// it can be they are already in the container, but there is no guarantee // it can be they are already in the container, but there is no guarantee
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); const bool set = this->setSetupsToContext(setups, true);
Q_UNUSED(set); Q_UNUSED(set);
} }
} }

View File

@@ -80,7 +80,7 @@ namespace BlackGui
bool checkPrerequisites(bool showOverlay); bool checkPrerequisites(bool showOverlay);
//! Send to context //! Send to context
bool setSetupsToContext(const BlackMisc::Simulation::CInterpolationSetupList &setups); bool setSetupsToContext(const BlackMisc::Simulation::CInterpolationSetupList &setups, bool force = false);
//! Setup chaged //! Setup chaged
void onSetupChanged(); void onSetupChanged();

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>299</width> <width>317</width>
<height>341</height> <height>339</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -126,9 +126,12 @@
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QPushButton" name="pb_RenderingSetup"> <widget class="QCheckBox" name="cb_IgnoreGlobal">
<property name="toolTip">
<string>no setups same as global setup</string>
</property>
<property name="text"> <property name="text">
<string> rendering setup </string> <string>≠global</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -145,6 +148,16 @@
</property> </property>
</spacer> </spacer>
</item> </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> <item>
<widget class="QPushButton" name="pb_Delete"> <widget class="QPushButton" name="pb_Delete">
<property name="text"> <property name="text">
@@ -183,6 +196,16 @@
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops>
<tabstop>tvp_InterpolationSetup</tabstop>
<tabstop>rb_Callsign</tabstop>
<tabstop>rb_Global</tabstop>
<tabstop>pb_Reload</tabstop>
<tabstop>cb_IgnoreGlobal</tabstop>
<tabstop>pb_RenderingSetup</tabstop>
<tabstop>pb_Delete</tabstop>
<tabstop>pb_Save</tabstop>
</tabstops>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>