Added context menu for adding new case group

p4#: 20905
This commit is contained in:
Magne Sjaastad
2013-03-14 09:50:40 +01:00
parent 469c5a9657
commit e92ed43fc3
4 changed files with 57 additions and 0 deletions

View File

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

View File

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

View File

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

View File

@@ -71,6 +71,7 @@ private slots:
void slotNewStatisticalCase();
void slotComputeStatisticalCases();
void slotAddCaseGroup();
void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected);