mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added context menu for adding new case group
p4#: 20905
This commit is contained in:
@@ -498,3 +498,37 @@ RimStatisticalCalculation* RimUiTreeModelPdm::addStatisticalCalculation(const QM
|
||||
return createdObject;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex)
|
||||
{
|
||||
RimProject* proj = RIApplication::instance()->project();
|
||||
CVF_ASSERT(proj);
|
||||
|
||||
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex);
|
||||
|
||||
if (dynamic_cast<RimIdenticalGridCaseGroup*>(currentItem->dataObject().p()))
|
||||
{
|
||||
QModelIndex rootIndex = itemIndex.parent();
|
||||
caf::PdmUiTreeItem* rootTreeItem = currentItem->parent();
|
||||
|
||||
int position = rootTreeItem->childCount();
|
||||
|
||||
beginInsertRows(rootIndex, position, position);
|
||||
|
||||
RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup;
|
||||
proj->caseGroups().push_back(createdObject);
|
||||
|
||||
caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(rootTreeItem, position, createdObject);
|
||||
|
||||
endInsertRows();
|
||||
|
||||
insertedModelIndex = index(position, 0, rootIndex);
|
||||
|
||||
return createdObject;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ class RimCellRangeFilter;
|
||||
class RimReservoirView;
|
||||
class RimInputProperty;
|
||||
class RimStatisticalCalculation;
|
||||
class RimIdenticalGridCaseGroup;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -57,6 +58,7 @@ public:
|
||||
void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames);
|
||||
|
||||
RimStatisticalCalculation* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
|
||||
RimIdenticalGridCaseGroup* addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex);
|
||||
|
||||
void updateScriptPaths();
|
||||
|
||||
|
||||
@@ -165,6 +165,12 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event)
|
||||
menu.addAction(QString("New View"), this, SLOT(slotAddView()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
else if (dynamic_cast<RimIdenticalGridCaseGroup*>(uiItem->dataObject().p()))
|
||||
{
|
||||
QMenu menu;
|
||||
menu.addAction(QString("New Case Group"), this, SLOT(slotAddCaseGroup()));
|
||||
menu.exec(event->globalPos());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -796,3 +802,17 @@ void RimUiTreeView::slotComputeStatisticalCases()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::slotAddCaseGroup()
|
||||
{
|
||||
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
|
||||
if (myModel)
|
||||
{
|
||||
QModelIndex insertedIndex;
|
||||
myModel->addCaseGroup(currentIndex(), insertedIndex);
|
||||
setCurrentIndex(insertedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ private slots:
|
||||
|
||||
void slotNewStatisticalCase();
|
||||
void slotComputeStatisticalCases();
|
||||
void slotAddCaseGroup();
|
||||
|
||||
void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user