mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
Ref T275, detect when objects have been deleted in view and using that signal in setup component
This commit is contained in:
@@ -39,6 +39,8 @@ namespace BlackGui
|
|||||||
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);
|
||||||
|
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_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())
|
||||||
@@ -228,5 +230,21 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
this->displaySetupsPerCallsign();
|
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
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ namespace BlackGui
|
|||||||
//! Setup chaged
|
//! Setup chaged
|
||||||
void onSetupChanged();
|
void onSetupChanged();
|
||||||
|
|
||||||
|
//! Objects have been deleted
|
||||||
|
void onObjectsDeleted(const BlackMisc::CVariant &deletedObjects);
|
||||||
|
|
||||||
BlackMisc::Simulation::CInterpolationSetupList m_lastSetSetups; //!< last setups set to context
|
BlackMisc::Simulation::CInterpolationSetupList m_lastSetSetups; //!< last setups set to context
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -1164,21 +1164,27 @@ namespace BlackGui
|
|||||||
if (this->isEmpty()) { return 0; }
|
if (this->isEmpty()) { return 0; }
|
||||||
|
|
||||||
const int currentRows = this->rowCount();
|
const int currentRows = this->rowCount();
|
||||||
|
const ContainerType selected(selectedObjects());
|
||||||
|
const CVariant deletedObjsVariant = CVariant::from(selected);
|
||||||
|
int delta = 0;
|
||||||
|
|
||||||
if (!this->hasFilter() && currentRows == this->selectedRowCount())
|
if (!this->hasFilter() && currentRows == this->selectedRowCount())
|
||||||
{
|
{
|
||||||
// shortcut if all are selected
|
// shortcut if all are selected
|
||||||
this->clear(); // clear all
|
this->clear(); // clear all
|
||||||
return currentRows;
|
delta = currentRows;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
const ContainerType selected(selectedObjects());
|
|
||||||
ContainerType unselectedObjects(container());
|
|
||||||
for (const ObjectType &obj : selected)
|
|
||||||
{
|
{
|
||||||
unselectedObjects.remove(obj);
|
ContainerType unselectedObjects(container());
|
||||||
|
for (const ObjectType &obj : selected)
|
||||||
|
{
|
||||||
|
unselectedObjects.remove(obj);
|
||||||
|
}
|
||||||
|
this->updateContainerMaybeAsync(unselectedObjects);
|
||||||
|
delta = currentRows - unselectedObjects.size();
|
||||||
}
|
}
|
||||||
const int delta = currentRows - unselectedObjects.size();
|
emit this->objectsDeleted(deletedObjsVariant);
|
||||||
this->updateContainerMaybeAsync(unselectedObjects);
|
|
||||||
return delta;
|
return delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -321,6 +321,9 @@ namespace BlackGui
|
|||||||
//! Object has been double clicked
|
//! Object has been double clicked
|
||||||
void objectSelected(const BlackMisc::CVariant &object);
|
void objectSelected(const BlackMisc::CVariant &object);
|
||||||
|
|
||||||
|
//! Objects deleted from model
|
||||||
|
void objectsDeleted(const BlackMisc::CVariant &objectContainer);
|
||||||
|
|
||||||
//! JSON data load from disk completed, the BlackMisc::CStatusMessage represents the success
|
//! JSON data load from disk completed, the BlackMisc::CStatusMessage represents the success
|
||||||
void jsonLoadCompleted(const BlackMisc::CStatusMessage &msg);
|
void jsonLoadCompleted(const BlackMisc::CStatusMessage &msg);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user