From 9129370ff85bfb4c0c37d9f32f9d107041ec2fe8 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 20 Aug 2015 16:30:43 +0300 Subject: [PATCH] Update Part item on activation of loaded document --- src/PartSet/PartSet_Module.cpp | 2 -- src/SketcherPrs/SketcherPrs_Angle.h | 13 +++++++++++++ src/XGUI/XGUI_DataModel.cpp | 20 +++++++++++++++----- 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 src/SketcherPrs/SketcherPrs_Angle.h diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 03b29dd75..3f14bed77 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -908,8 +908,6 @@ void PartSet_Module::processEvent(const std::shared_ptr& theMess } } #else - // Problem with MPV: At first time on creation it doesn't work because Part feature - // creation event will be sent after if (aActivePartIndex.isValid()) aTreeView->setExpanded(aActivePartIndex, false); XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel(); diff --git a/src/SketcherPrs/SketcherPrs_Angle.h b/src/SketcherPrs/SketcherPrs_Angle.h new file mode 100644 index 000000000..365e82bc2 --- /dev/null +++ b/src/SketcherPrs/SketcherPrs_Angle.h @@ -0,0 +1,13 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: SketcherPrs_Angle.h +// Created: 26 March 2015 +// Author: Vitaly SMETANNIKOV + + +#ifndef SketcherPrs_Angle_H +#define SketcherPrs_Angle_H + + + +#endif \ No newline at end of file diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 40e5c8136..0b2724532 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -61,6 +61,7 @@ XGUI_DataModel::XGUI_DataModel(QObject* theParent) : QAbstractItemModel(theParen Events_Loop* aLoop = Events_Loop::loop(); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_CREATED)); aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_DELETED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED)); } //****************************************************** @@ -128,9 +129,8 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess } } #ifdef _DEBUG - else { + else Events_Error::send("Problem with Data Model definition of sub-document"); - } #endif } } @@ -186,12 +186,22 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& theMess } } #ifdef _DEBUG - else { + else Events_Error::send("Problem with Data Model definition of sub-document"); - } #endif } } + } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) { + DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument(); + if (aDoc != aRootDoc) { + QModelIndex aDocRoot = findDocumentRootIndex(aDoc.get()); + if (aDocRoot.isValid()) + emit dataChanged(aDocRoot, aDocRoot); +#ifdef _DEBUG + else + Events_Error::send("Problem with Data Model definition of sub-document"); +#endif + } } } @@ -584,7 +594,7 @@ bool XGUI_DataModel::hasChildren(const QModelIndex& theParent) const // Check for Part feature ResultPartPtr aPartRes = getPartResult(aObj); if (aPartRes.get()) - return true; + return aPartRes->partDoc().get() != NULL; else { // Check for composite object ModelAPI_CompositeFeature* aCompFeature = dynamic_cast(aObj); -- 2.39.2