#3607 Grid items. Hide LGRs folder if there are no LGRs on file

This commit is contained in:
Bjørn Erik Jensen
2018-11-09 09:45:30 +01:00
parent 0a9f00248b
commit 551bf099d3
2 changed files with 21 additions and 1 deletions

View File

@@ -463,7 +463,10 @@ void RimGridCollection::initAfterRead()
void RimGridCollection::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) void RimGridCollection::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
{ {
uiTreeOrdering.add(m_mainGrid()); uiTreeOrdering.add(m_mainGrid());
uiTreeOrdering.add(m_persistentLgrs()); if (hasPersistentLgrs())
{
uiTreeOrdering.add(m_persistentLgrs());
}
uiTreeOrdering.add(m_temporaryLgrs()); uiTreeOrdering.add(m_temporaryLgrs());
uiTreeOrdering.skipRemainingChildren(true); uiTreeOrdering.skipRemainingChildren(true);
} }
@@ -477,3 +480,19 @@ const RigMainGrid* RimGridCollection::mainGrid() const
firstAncestorOrThisOfType(eclipseCase); firstAncestorOrThisOfType(eclipseCase);
return eclipseCase ? eclipseCase->mainGrid() : nullptr; return eclipseCase ? eclipseCase->mainGrid() : nullptr;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGridCollection::hasPersistentLgrs() const
{
auto mainGrid = this->mainGrid();
if (!mainGrid) return 0;
for (int i = 1; i < mainGrid->gridCount(); i++)
{
const auto grid = mainGrid->gridByIndex(i);
if (!grid->isTempGrid()) return true;
}
return false;
}

View File

@@ -116,6 +116,7 @@ protected:
private: private:
const RigMainGrid* mainGrid() const; const RigMainGrid* mainGrid() const;
bool hasPersistentLgrs() const;
caf::PdmField<bool> m_isActive; caf::PdmField<bool> m_isActive;
caf::PdmChildField<RimGridInfo*> m_mainGrid; caf::PdmChildField<RimGridInfo*> m_mainGrid;