#2934 Delete all selected cases, not just the first one when right clicking and choosing close.

This commit is contained in:
Gaute Lindkvist 2018-05-18 14:01:04 +02:00
parent 2c2a2c6102
commit 3119ab24cb
2 changed files with 37 additions and 39 deletions

View File

@ -52,7 +52,7 @@ CAF_CMD_SOURCE_INIT(RicCloseCaseFeature, "RicCloseCaseFeature");
//--------------------------------------------------------------------------------------------------
bool RicCloseCaseFeature::isCommandEnabled()
{
return selectedEclipseCase() != nullptr || selectedGeoMechCase() != nullptr;
return !selectedCases().empty();
}
//--------------------------------------------------------------------------------------------------
@ -60,24 +60,44 @@ bool RicCloseCaseFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicCloseCaseFeature::onActionTriggered(bool isChecked)
{
RimEclipseCase* eclipseCase = selectedEclipseCase();
RimGeoMechCase* geoMechCase = selectedGeoMechCase();
if (eclipseCase)
std::vector<RimCase*> rimCases = selectedCases();
std::vector<RimEclipseCase*> eclipseCases;
std::vector<RimGeoMechCase*> geoMechCases;
for (RimCase* rimCase : selectedCases())
{
std::vector<RimEclipseCase*> casesToBeDeleted;
casesToBeDeleted.push_back(eclipseCase);
if (userConfirmedGridCaseGroupChange(casesToBeDeleted))
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(rimCase);
if (eclipseCase)
{
deleteEclipseCase(eclipseCase);
eclipseCases.push_back(eclipseCase);
}
else
{
RimGeoMechCase* geoMechCase = dynamic_cast<RimGeoMechCase*>(rimCase);
if (geoMechCase)
{
geoMechCases.push_back(geoMechCase);
}
}
}
if (!eclipseCases.empty())
{
if (userConfirmedGridCaseGroupChange(eclipseCases))
{
for (RimEclipseCase* eclipseCase : eclipseCases)
{
deleteEclipseCase(eclipseCase);
}
RiuMainWindow::instance()->cleanupGuiCaseClose();
}
}
else if (geoMechCase)
if (!geoMechCases.empty())
{
deleteGeoMechCase(geoMechCase);
for (RimGeoMechCase* geoMechCase : geoMechCases)
{
deleteGeoMechCase(geoMechCase);
}
RiuMainWindow::instance()->cleanupGuiCaseClose();
}
}
@ -95,33 +115,11 @@ void RicCloseCaseFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RicCloseCaseFeature::selectedEclipseCase() const
std::vector<RimCase*> RicCloseCaseFeature::selectedCases() const
{
std::vector<RimEclipseCase*> selection;
std::vector<RimCase*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
if (selection.size() > 0)
{
return selection[0];
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimGeoMechCase* RicCloseCaseFeature::selectedGeoMechCase() const
{
std::vector<RimGeoMechCase*> selection;
caf::SelectionManager::instance()->objectsByType(&selection);
if (selection.size() > 0)
{
return selection[0];
}
return nullptr;
return selection;
}
//--------------------------------------------------------------------------------------------------

View File

@ -25,6 +25,7 @@
class RimEclipseCase;
class RimGeoMechCase;
class RimCase;
class RimIdenticalGridCaseGroup;
//==================================================================================================
@ -45,8 +46,7 @@ protected:
virtual void setupActionLook( QAction* actionToSetup );
private:
RimEclipseCase* selectedEclipseCase() const;
RimGeoMechCase* selectedGeoMechCase() const;
std::vector<RimCase*> selectedCases() const;
void deleteGeoMechCase(RimGeoMechCase* geoMechCase);