From 551bf099d3aa6c7ec1981ac85eff5cad72786a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 9 Nov 2018 09:45:30 +0100 Subject: [PATCH] #3607 Grid items. Hide LGRs folder if there are no LGRs on file --- .../ProjectDataModel/RimGridCollection.cpp | 21 ++++++++++++++++++- .../ProjectDataModel/RimGridCollection.h | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp index 8706a4976d..1b9c856314 100644 --- a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp @@ -463,7 +463,10 @@ void RimGridCollection::initAfterRead() void RimGridCollection::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) { uiTreeOrdering.add(m_mainGrid()); - uiTreeOrdering.add(m_persistentLgrs()); + if (hasPersistentLgrs()) + { + uiTreeOrdering.add(m_persistentLgrs()); + } uiTreeOrdering.add(m_temporaryLgrs()); uiTreeOrdering.skipRemainingChildren(true); } @@ -477,3 +480,19 @@ const RigMainGrid* RimGridCollection::mainGrid() const firstAncestorOrThisOfType(eclipseCase); 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; +} diff --git a/ApplicationCode/ProjectDataModel/RimGridCollection.h b/ApplicationCode/ProjectDataModel/RimGridCollection.h index 002f8af181..6cbbbccf4a 100644 --- a/ApplicationCode/ProjectDataModel/RimGridCollection.h +++ b/ApplicationCode/ProjectDataModel/RimGridCollection.h @@ -116,6 +116,7 @@ protected: private: const RigMainGrid* mainGrid() const; + bool hasPersistentLgrs() const; caf::PdmField m_isActive; caf::PdmChildField m_mainGrid;