X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FXGUI%2FXGUI_PartDataModel.cpp;h=66f8d8b961ef4ef8d6ebe489fc439ffe04d5734b;hb=b2a34ee4bab2fe2d97f900cbdafcaf122344c46c;hp=16adcadf747f9e3fbfcf66828a8913dae2443fa9;hpb=cd9217d7e87997ec8bc150a6d8c389e742ca0f84;p=modules%2Fshaper.git diff --git a/src/XGUI/XGUI_PartDataModel.cpp b/src/XGUI/XGUI_PartDataModel.cpp index 16adcadf7..66f8d8b96 100644 --- a/src/XGUI/XGUI_PartDataModel.cpp +++ b/src/XGUI/XGUI_PartDataModel.cpp @@ -1,7 +1,7 @@ #include "XGUI_PartDataModel.h" #include "XGUI_Workshop.h" -#include +#include #include #include #include @@ -42,7 +42,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const case ParamsFolder: return tr("Parameters") + QString(" (%1)").arg(rowCount(theIndex)); case ParamObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row()); if (aObject) return aObject->data()->name().c_str(); @@ -51,7 +51,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const case ConstructFolder: return tr("Constructions") + QString(" (%1)").arg(rowCount(theIndex)); case ConstructObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row()); if (aObject) @@ -61,7 +61,7 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const case BodiesFolder: return tr("Bodies") + QString(" (%1)").arg(rowCount(theIndex)); case BodiesObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultBody::group(), theIndex.row()); if (aObject) return aObject->data()->name().c_str(); @@ -78,8 +78,16 @@ QVariant XGUI_TopDataModel::data(const QModelIndex& theIndex, int theRole) const case ConstructFolder: return QIcon(":pictures/constr_folder.png"); case ConstructObject: - case BodiesObject: + case BodiesObject: { + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); + std::string aGroup = theIndex.internalId() == ConstructObject ? + ModelAPI_ResultConstruction::group() : ModelAPI_ResultBody::group(); + ObjectPtr anObject = aRootDoc->object(aGroup, theIndex.row()); + if (anObject && anObject->data() && anObject->data()->mustBeUpdated()) { + return QIcon(":pictures/constr_object_modified.png"); + } return QIcon(":pictures/constr_object.png"); + } } break; @@ -103,7 +111,7 @@ int XGUI_TopDataModel::rowCount(const QModelIndex& theParent) const if (!theParent.isValid()) return 3; - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); if (theParent.internalId() == ParamsFolder) return aRootDoc->size(ModelAPI_ResultParameters::group()); @@ -175,15 +183,15 @@ ObjectPtr XGUI_TopDataModel::object(const QModelIndex& theIndex) const case BodiesFolder: return ObjectPtr(); case ParamObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); return aRootDoc->object(ModelAPI_ResultParameters::group(), theIndex.row()); } case ConstructObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); return aRootDoc->object(ModelAPI_ResultConstruction::group(), theIndex.row()); } case BodiesObject: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); return aRootDoc->object(ModelAPI_ResultBody::group(), theIndex.row()); } } @@ -210,7 +218,7 @@ QModelIndex XGUI_TopDataModel::objectIndex(const ObjectPtr& theObject) const { QModelIndex aIndex; if (theObject) { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); std::string aGroup = theObject->groupName(); int aNb = aRootDoc->size(aGroup); int aRow = -1; @@ -251,7 +259,7 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons // return a name switch (theIndex.internalId()) { case MyRoot: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId); if (aObject) return boost::dynamic_pointer_cast(aObject)->data()->name().c_str(); @@ -297,8 +305,15 @@ QVariant XGUI_PartDataModel::data(const QModelIndex& theIndex, int theRole) cons case BodiesFolder: return QIcon(":pictures/constr_folder.png"); case ConstructObject: - case BodiesObject: + case BodiesObject: { + std::string aGroup = theIndex.internalId() == ConstructObject ? + ModelAPI_ResultConstruction::group() : ModelAPI_ResultBody::group(); + ObjectPtr anObject = partDocument()->object(aGroup, theIndex.row()); + if (anObject && anObject->data() && anObject->data()->mustBeUpdated()) { + return QIcon(":pictures/constr_object_modified.png"); + } return QIcon(":pictures/constr_object.png"); + } case HistoryObject: { ObjectPtr aObject = partDocument()->object(ModelAPI_Feature::group(), theIndex.row() - 3); FeaturePtr aFeature = boost::dynamic_pointer_cast(aObject); @@ -325,7 +340,7 @@ QVariant XGUI_PartDataModel::headerData(int section, Qt::Orientation orientation int XGUI_PartDataModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid()) { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); if (aRootDoc->object(ModelAPI_ResultPart::group(), myId)) return 1; else @@ -333,7 +348,13 @@ int XGUI_PartDataModel::rowCount(const QModelIndex& parent) const } switch (parent.internalId()) { case MyRoot: - return 3 + partDocument()->size(ModelAPI_Feature::group()); + { + DocumentPtr aDoc = partDocument(); + if (aDoc) + return 3 + aDoc->size(ModelAPI_Feature::group()); + else + return 0; + } case ParamsFolder: return partDocument()->size(ModelAPI_ResultParameters::group()); case ConstructFolder: @@ -404,7 +425,7 @@ bool XGUI_PartDataModel::hasChildren(const QModelIndex& theParent) const DocumentPtr XGUI_PartDataModel::partDocument() const { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); ObjectPtr aObject = aRootDoc->object(ModelAPI_ResultPart::group(), myId); ResultPartPtr aPart = boost::dynamic_pointer_cast(aObject); return aPart->partDoc(); @@ -414,7 +435,7 @@ ObjectPtr XGUI_PartDataModel::object(const QModelIndex& theIndex) const { switch (theIndex.internalId()) { case MyRoot: { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); return aRootDoc->object(ModelAPI_ResultPart::group(), myId); } case ParamsFolder: @@ -456,7 +477,7 @@ QModelIndex XGUI_PartDataModel::findGroup(const std::string& theGroup) const ResultPartPtr XGUI_PartDataModel::part() const { - DocumentPtr aRootDoc = ModelAPI_PluginManager::get()->rootDocument(); + DocumentPtr aRootDoc = ModelAPI_Session::get()->moduleDocument(); ObjectPtr aObj = aRootDoc->object(ModelAPI_ResultPart::group(), myId); return boost::dynamic_pointer_cast(aObj); }