mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Expand up to root when creating a view. Removed use of expandAll()
p4#: 21353
This commit is contained in:
parent
bd211d2115
commit
79e7d3604c
@ -372,15 +372,18 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd
|
||||
|
||||
bool itemIndexIsCollection = false;
|
||||
QModelIndex collectionIndex;
|
||||
int position = 0;
|
||||
if (dynamic_cast<RimReservoirView*>(currentItem->dataObject().p()))
|
||||
{
|
||||
collectionItem = currentItem->parent();
|
||||
collectionIndex = itemIndex.parent();
|
||||
position = itemIndex.row();
|
||||
}
|
||||
else if (dynamic_cast<RimCase*>(currentItem->dataObject().p()))
|
||||
{
|
||||
collectionItem = currentItem;
|
||||
collectionIndex = itemIndex;
|
||||
position = collectionItem->childCount();
|
||||
}
|
||||
|
||||
if (collectionItem)
|
||||
@ -393,14 +396,15 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd
|
||||
// Must be run before buildViewItems, as wells are created in this function
|
||||
insertedView->loadDataAndUpdate();
|
||||
|
||||
int viewCount = rowCount(collectionIndex);
|
||||
beginInsertRows(collectionIndex, viewCount, viewCount);
|
||||
beginInsertRows(collectionIndex, position, position);
|
||||
|
||||
// NOTE: -1 as second argument indicates append
|
||||
caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(collectionItem, -1, insertedView);
|
||||
caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(collectionItem, position, insertedView);
|
||||
|
||||
endInsertRows();
|
||||
|
||||
insertedModelIndex = index(position, 0, collectionIndex);
|
||||
|
||||
return insertedView;
|
||||
}
|
||||
|
||||
|
@ -543,7 +543,11 @@ void RimUiTreeView::slotAddView()
|
||||
|
||||
QModelIndex insertedIndex;
|
||||
myModel->addReservoirView(index, insertedIndex);
|
||||
|
||||
|
||||
// Expand parent collection and inserted view item
|
||||
setExpandedUpToRoot(insertedIndex);
|
||||
|
||||
setCurrentIndex(insertedIndex);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -827,6 +831,8 @@ void RimUiTreeView::slotNewStatisticsCase()
|
||||
QModelIndex insertedIndex;
|
||||
RimStatisticsCase* newObject = myModel->addStatisticalCalculation(currentIndex(), insertedIndex);
|
||||
setCurrentIndex(insertedIndex);
|
||||
|
||||
setExpanded(insertedIndex, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1275,3 +1281,17 @@ void RimUiTreeView::storeTreeViewStateToString(QString& treeViewState)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimUiTreeView::setExpandedUpToRoot(const QModelIndex& itemIndex)
|
||||
{
|
||||
QModelIndex mi = itemIndex;
|
||||
|
||||
while (mi.isValid())
|
||||
{
|
||||
this->setExpanded(mi, true);
|
||||
mi = mi.parent();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,7 @@ private:
|
||||
|
||||
bool checkAndHandleToggleOfMultipleSelection();
|
||||
|
||||
void setExpandedUpToRoot(const QModelIndex& itemIndex);
|
||||
private:
|
||||
QAction* m_pasteAction;
|
||||
};
|
||||
|
@ -921,8 +921,6 @@ void RiuMainWindow::setPdmRoot(caf::PdmObject* pdmRoot)
|
||||
caf::PdmUiTreeItem* treeItemRoot = caf::UiTreeItemBuilderPdm::buildViewItems(NULL, -1, m_pdmRoot);
|
||||
m_treeModelPdm->setRoot(treeItemRoot);
|
||||
|
||||
m_treeView->expandAll();
|
||||
|
||||
if (treeItemRoot && m_treeView->selectionModel())
|
||||
{
|
||||
connect(m_treeView->selectionModel(), SIGNAL(currentChanged ( const QModelIndex & , const QModelIndex & )), SLOT(slotCurrentChanged( const QModelIndex & , const QModelIndex & )));
|
||||
@ -1074,7 +1072,6 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow)
|
||||
}
|
||||
|
||||
m_treeView->setCurrentIndex(newSelectionIndex);
|
||||
//m_treeView->setExpanded(previousViewModelIndex, false);
|
||||
if (newSelectionIndex != newViewModelIndex)
|
||||
{
|
||||
m_treeView->setExpanded(newViewModelIndex, true);
|
||||
@ -1260,7 +1257,6 @@ void RiuMainWindow::slotNewObjectPropertyView()
|
||||
}
|
||||
|
||||
treeView->setModel(m_treeModelPdm);
|
||||
treeView->expandAll();
|
||||
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user