New Case groups is now correctly positioned in the tree.

The context command was not quite up to speed.
This commit is contained in:
Jacob Støren 2013-10-02 15:51:25 +02:00
parent 756b5543f0
commit 56590a8c55

View File

@ -591,38 +591,28 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(QModelIndex& inserted
RimProject* proj = RiaApplication::instance()->project();
CVF_ASSERT(proj);
QModelIndex scriptModelIndex = getModelIndexFromPdmObject(proj->scriptCollection());
if (!scriptModelIndex.isValid()) return NULL;
caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(scriptModelIndex);
if (!currentItem) return NULL;
QModelIndex rootIndex = scriptModelIndex.parent();
caf::PdmUiTreeItem* rootTreeItem = currentItem->parent();
// New case group is inserted before the last item, the script item
int position = rootTreeItem->childCount() - 1;
beginInsertRows(rootIndex, position, position);
RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup;
proj->assignIdToCaseGroup(createdObject);
RimCase* createdReservoir = createdObject->createAndAppendStatisticsCase();
proj->assignCaseIdToCase(createdReservoir);
createdObject->name = QString("Grid Case Group %1").arg(position + 1);
RimAnalysisModels* analysisModels = proj->activeOilField() ? proj->activeOilField()->analysisModels() : NULL;
if (analysisModels)
{
RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup;
proj->assignIdToCaseGroup(createdObject);
RimCase* createdReservoir = createdObject->createAndAppendStatisticsCase();
proj->assignCaseIdToCase(createdReservoir);
createdObject->name = QString("Grid Case Group %1").arg(analysisModels->caseGroups().size() + 1);
analysisModels->caseGroups().push_back(createdObject);
this->updateUiSubTree(analysisModels);
insertedModelIndex = getModelIndexFromPdmObject(createdObject);
return createdObject;
}
else
{
return NULL;
}
caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject);
endInsertRows();
insertedModelIndex = index(position, 0, rootIndex);
return createdObject;
}
//--------------------------------------------------------------------------------------------------