mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added close on context menu for reservoir case
p4#: 19266
This commit is contained in:
@@ -201,6 +201,28 @@ bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex)
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeModelPdm::deleteReservoir(const QModelIndex& itemIndex)
|
||||
{
|
||||
CVF_ASSERT(itemIndex.isValid());
|
||||
|
||||
caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(itemIndex);
|
||||
CVF_ASSERT(uiItem);
|
||||
|
||||
RimReservoir* reservoir = dynamic_cast<RimReservoir*>(uiItem->dataObject().p());
|
||||
CVF_ASSERT(reservoir);
|
||||
|
||||
// Remove Ui items pointing at the pdm object to delete
|
||||
removeRow(itemIndex.row(), itemIndex.parent());
|
||||
|
||||
RimProject* proj = RIApplication::instance()->project();
|
||||
proj->reservoirs().removeChildObject(reservoir);
|
||||
|
||||
delete reservoir;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -419,3 +441,4 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex)
|
||||
|
||||
delete inputProperty;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
bool deletePropertyFilter(const QModelIndex& itemIndex);
|
||||
bool deleteReservoirView(const QModelIndex& itemIndex);
|
||||
void deleteInputProperty(const QModelIndex& itemIndex);
|
||||
void deleteReservoir(const QModelIndex& itemIndex);
|
||||
|
||||
RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
|
||||
RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
|
||||
|
||||
@@ -142,6 +142,12 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
|
||||
menu.addAction(QString("Write"), this, SLOT(slotWriteBinaryResultAsInputProperty()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimReservoir*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("Close"), this, SLOT(slotCloseCase()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -729,3 +735,15 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotCloseCase()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
myModel->deleteReservoir(currentIndex());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ private slots:
|
||||
void slotWriteInputProperty();
|
||||
void slotWriteBinaryResultAsInputProperty();
|
||||
|
||||
void slotCloseCase();
|
||||
|
||||
void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
|
||||
|
||||
signals:
|
||||
|
||||
Reference in New Issue
Block a user