Ref T275, detect when objects have been deleted in view and using that signal in setup component

This commit is contained in:
Klaus Basan
2018-06-19 16:47:57 +02:00
parent 73ea22530c
commit 0aa5836b62
4 changed files with 38 additions and 8 deletions

View File

@@ -39,6 +39,8 @@ namespace BlackGui
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);
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelDataChanged, this, &CInterpolationSetupComponent::onModelChanged);
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::objectsDeleted, this, &CInterpolationSetupComponent::onObjectsDeleted);
connect(ui->rb_Callsign, &QRadioButton::released, this, &CInterpolationSetupComponent::onModeChanged);
connect(ui->rb_Global, &QRadioButton::released, this, &CInterpolationSetupComponent::onModeChanged);
if (sGui && sGui->getIContextSimulator())
@@ -228,5 +230,21 @@ namespace BlackGui
{
this->displaySetupsPerCallsign();
}
void CInterpolationSetupComponent::onObjectsDeleted(const CVariant &deletedObjects)
{
if (deletedObjects.canConvert<CInterpolationSetupList>())
{
const CInterpolationSetupList deletedSetups = deletedObjects.value<CInterpolationSetupList>();
if (deletedSetups.isEmpty()) { return; }
// make sure the setups are really deleted
// it can be they are already in the container, but there is no guarantee
CInterpolationSetupList setups = ui->tvp_InterpolationSetup->container();
setups.removeByCallsigns(deletedSetups.getCallsigns());
const bool set = this->setSetupsToContext(setups);
Q_UNUSED(set);
}
}
} // ns
} // ns