From 0df40de2e7a7abc2a0f13b222c30bdcb26fbda5d Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 26 Aug 2015 15:34:41 +0300 Subject: [PATCH] Issue #834: Show prefix "Not loaded" for not loaded parts. --- src/XGUI/XGUI_DataModel.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 7ca9f562c..075317acb 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -338,14 +338,24 @@ QVariant XGUI_DataModel::data(const QModelIndex& theIndex, int theRole) const ModelAPI_Object* aObj = (ModelAPI_Object*)theIndex.internalPointer(); switch (theRole) { case Qt::DisplayRole: - if (aObj->groupName() == ModelAPI_ResultParameter::group()) { - ModelAPI_ResultParameter* aParam = dynamic_cast(aObj); - AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); - QString aVal = QString::number(aValueAttribute->value()); - QString aTitle = QString(aObj->data()->name().c_str()); - return aTitle + " = " + aVal; + { + if (aObj->groupName() == ModelAPI_ResultParameter::group()) { + ModelAPI_ResultParameter* aParam = dynamic_cast(aObj); + AttributeDoublePtr aValueAttribute = aParam->data()->real(ModelAPI_ResultParameter::VALUE()); + QString aVal = QString::number(aValueAttribute->value()); + QString aTitle = QString(aObj->data()->name().c_str()); + return aTitle + " = " + aVal; + } + QString aPrefix; + if (aObj->groupName() == myXMLReader.subType()) { + ResultPartPtr aPartRes = getPartResult(aObj); + if (aPartRes.get()) { + if (aPartRes->partDoc().get() == NULL) + aPrefix = "Not loaded "; + } + } + return aPrefix + aObj->data()->name().c_str(); } - return aObj->data()->name().c_str(); case Qt::DecorationRole: return ModuleBase_IconFactory::get()->getIcon(object(theIndex)); } @@ -401,6 +411,9 @@ int XGUI_DataModel::rowCount(const QModelIndex& theParent) const ResultPartPtr aPartRes = getPartResult(aObj); if (aPartRes.get()) { DocumentPtr aSubDoc = aPartRes->partDoc(); + if (!aSubDoc.get()) + return 0; + int aNbSubFolders = foldersCount(aSubDoc.get()); int aNbSubItems = 0; std::string aSubType = myXMLReader.subType(); -- 2.39.2