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;
|
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;
|
delete inputProperty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
bool deletePropertyFilter(const QModelIndex& itemIndex);
|
bool deletePropertyFilter(const QModelIndex& itemIndex);
|
||||||
bool deleteReservoirView(const QModelIndex& itemIndex);
|
bool deleteReservoirView(const QModelIndex& itemIndex);
|
||||||
void deleteInputProperty(const QModelIndex& itemIndex);
|
void deleteInputProperty(const QModelIndex& itemIndex);
|
||||||
|
void deleteReservoir(const QModelIndex& itemIndex);
|
||||||
|
|
||||||
RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
|
RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
|
||||||
RimCellRangeFilter* addRangeFilter(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.addAction(QString("Write"), this, SLOT(slotWriteBinaryResultAsInputProperty()));
|
||||||
menu.exec(event->globalPos());
|
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 slotWriteInputProperty();
|
||||||
void slotWriteBinaryResultAsInputProperty();
|
void slotWriteBinaryResultAsInputProperty();
|
||||||
|
|
||||||
|
void slotCloseCase();
|
||||||
|
|
||||||
void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
|
void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@@ -315,7 +315,17 @@ bool UiTreeModelPdm::removeRows(int position, int rows, const QModelIndex &paren
|
|||||||
{
|
{
|
||||||
if (rows <= 0) return true;
|
if (rows <= 0) return true;
|
||||||
|
|
||||||
PdmUiTreeItem* parentItem = getTreeItemFromIndex(parent);
|
PdmUiTreeItem* parentItem = NULL;
|
||||||
|
if (parent.isValid())
|
||||||
|
{
|
||||||
|
parentItem = getTreeItemFromIndex(parent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
parentItem = m_root;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!parentItem) return true;
|
||||||
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user