Added close on context menu for reservoir case

p4#: 19266
This commit is contained in:
Magne Sjaastad
2012-10-23 11:12:47 +02:00
parent f4a328b4cb
commit f833244b68
5 changed files with 55 additions and 1 deletions

View File

@@ -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;
} }

View File

@@ -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);

View File

@@ -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());
}
}

View File

@@ -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:

View File

@@ -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;