Updated riGetSelectedCases to use a string as type name

Improved how to get currently selected cases
p4#: 21625
This commit is contained in:
Magne Sjaastad committed 2013-05-15 12:03:36 +02:00
1 parent b5f5f49572
commit 97c3a330f6
7 files changed
+88 -64

No files matched your search

@@ -785,11 +785,7 @@ void RimUiTreeView::slotCloseCase()
caf::PdmObjectGroup group;
QModelIndexList mil = m->selectedRows();
for (int i = 0; i < mil.size(); i++)
{
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(mil.at(i));
group.addObject(uiItem->dataObject().p());
}
populateObjectGroupFromModelIndexList(mil, &group);
std::vector<caf::PdmPointer<RimCase> > typedObjects;
group.objectsByType(&typedObjects);
@@ -928,11 +924,7 @@ void RimUiTreeView::createPdmObjectsFromClipboard(caf::PdmObjectGroup* objectGro
if (!mdWithIndexes) return;
QModelIndexList indexList = mdWithIndexes->indexes();
for (int i = 0; i < indexList.size(); i++)
{
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(indexList.at(i));
objectGroup->addObject(uiItem->dataObject().p());
}
populateObjectGroupFromModelIndexList(indexList, objectGroup);
}
//--------------------------------------------------------------------------------------------------
@@ -1465,3 +1457,24 @@ void RimUiTreeView::slotToggleItemsOff()
executeSelectionToggleOperation(TOGGLE_OFF);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimUiTreeView::populateObjectGroupFromModelIndexList(const QModelIndexList& modelIndexList, caf::PdmObjectGroup* objectGroup)
{
CVF_ASSERT(objectGroup);
RimUiTreeModelPdm* myModel = dynamic_cast<RimUiTreeModelPdm*>(model());
if (!myModel) return;
for (int i = 0; i < modelIndexList.size(); i++)
{
caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(modelIndexList.at(i));
if (uiItem && uiItem->dataObject() && uiItem->dataObject().p())
{
objectGroup->addObject(uiItem->dataObject().p());
}
}
}
@@ -46,6 +46,8 @@ public:
void applyTreeViewStateFromString(const QString& treeViewState);
void storeTreeViewStateToString(QString& treeViewState);
void populateObjectGroupFromModelIndexList(const QModelIndexList& modelIndexList, caf::PdmObjectGroup* objectGroup);
static void applyCurrentIndexFromString(QAbstractItemView& itemView, const QString& currentIndexString);
static void storeCurrentIndexToString(const QAbstractItemView& itemView, QString& currentIndexString);