From 050220cc7654c7d7d175a07c72c74b70122f86c7 Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 8 Jul 2015 16:23:33 +0300 Subject: [PATCH] Exclude sub-features from history functionality --- src/ModuleBase/ModuleBase_Tools.cpp | 8 ++++++-- src/ModuleBase/ModuleBase_Tools.h | 3 ++- src/PartSet/PartSet_DocumentDataModel.cpp | 2 ++ src/PartSet/PartSet_Module.cpp | 3 ++- src/PartSet/PartSet_PartDataModel.cpp | 5 +++++ src/XGUI/XGUI_ContextMenuMgr.cpp | 9 ++++++--- src/XGUI/XGUI_Workshop.cpp | 3 ++- 7 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index d62879f7f..d3739e843 100644 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -216,11 +217,12 @@ TopAbs_ShapeEnum shapeType(const QString& theType) return TopAbs_SHAPE; } -void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter) +void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter, bool& hasSubFeature) { hasResult = false; hasFeature = false; hasParameter = false; + hasSubFeature = false; foreach(ObjectPtr aObj, theObjects) { FeaturePtr aFeature = std::dynamic_pointer_cast(aObj); ResultPtr aResult = std::dynamic_pointer_cast(aObj); @@ -229,7 +231,9 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe hasResult = (aResult.get() != NULL); hasFeature = (aFeature.get() != NULL); hasParameter = (aConstruction.get() != NULL); - if (hasFeature && hasResult && hasParameter) + if (hasFeature) + hasSubFeature = (ModelAPI_Tools::compositeOwner(aFeature) != NULL); + if (hasFeature && hasResult && hasParameter && hasSubFeature) break; } } diff --git a/src/ModuleBase/ModuleBase_Tools.h b/src/ModuleBase/ModuleBase_Tools.h index 0bb3e68ee..f0d9ad2b6 100644 --- a/src/ModuleBase/ModuleBase_Tools.h +++ b/src/ModuleBase/ModuleBase_Tools.h @@ -89,8 +89,9 @@ Check types of objects which are in the given list \param hasResult will be set to true if list contains Result objects \param hasFeature will be set to true if list contains Feature objects \param hasParameter will be set to true if list contains Parameter objects +\param hasSubFeature will be set to true if list contains Sub-Feature objects */ -MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter); +MODULEBASE_EXPORT void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, bool& hasParameter, bool& hasSubFeature); } #endif diff --git a/src/PartSet/PartSet_DocumentDataModel.cpp b/src/PartSet/PartSet_DocumentDataModel.cpp index 3ffc164cb..8b5204c7f 100644 --- a/src/PartSet/PartSet_DocumentDataModel.cpp +++ b/src/PartSet/PartSet_DocumentDataModel.cpp @@ -802,6 +802,8 @@ void PartSet_DocumentDataModel::onMouseDoubleClick(const QModelIndex& theIndex) { if (theIndex.column() != 1) return; + if (flags(theIndex) == 0) + return; QTreeView* aTreeView = dynamic_cast(sender()); if ((theIndex.internalId() >= PartsFolder) && (theIndex.internalId() <= PartResult)) { if (myActivePartModel) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 631adfd17..e518c7df3 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -782,7 +782,8 @@ void PartSet_Module::addObjectBrowserMenu(QMenu* theMenu) const bool hasResult = false; bool hasFeature = false; bool hasParameter = false; - ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter); + bool hasSubFeature = false; + ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter, hasSubFeature); ObjectPtr aObject = aObjects.first(); if (aObject) { diff --git a/src/PartSet/PartSet_PartDataModel.cpp b/src/PartSet/PartSet_PartDataModel.cpp index d1a48fdf5..98eed0060 100644 --- a/src/PartSet/PartSet_PartDataModel.cpp +++ b/src/PartSet/PartSet_PartDataModel.cpp @@ -424,10 +424,15 @@ QModelIndex PartSet_PartDataModel::lastHistoryItem() const Qt::ItemFlags PartSet_PartDataModel::flags(const QModelIndex& theIndex) const { + // Disable sub-features at column 1 + if ((theIndex.column() == 1) && (theIndex.internalId() >= 0)) + return 0; + Qt::ItemFlags aFlags = Qt::ItemIsSelectable; if (object(theIndex)) { aFlags |= Qt::ItemIsEditable; } + if (theIndex.internalId() == HistoryObject) { if (theIndex.row() <= lastHistoryRow() || (theIndex.column() == 1)) aFlags |= Qt::ItemIsEnabled; diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 8da4ebda2..fa76cfa4d 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -163,7 +163,8 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() bool hasResult = false; bool hasFeature = false; bool hasParameter = false; - ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter); + bool hasSubFeature = false; + ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter, hasSubFeature); //Process Feature if (aSelected == 1) { @@ -200,8 +201,10 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() action("WIREFRAME_CMD")->setEnabled(true); } } - if (hasFeature || hasParameter) - action("DELETE_CMD")->setEnabled(true); + if (!hasSubFeature) { + if (hasFeature || hasParameter) + action("DELETE_CMD")->setEnabled(true); + } } if (myWorkshop->canChangeColor()) action("COLOR_CMD")->setEnabled(true); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index bf5be2e6b..6df726e2d 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1000,7 +1000,8 @@ void XGUI_Workshop::deleteObjects() bool hasResult = false; bool hasFeature = false; bool hasParameter = false; - ModuleBase_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter); + bool hasSubFeature = false; + ModuleBase_Tools::checkObjects(anObjects, hasResult, hasFeature, hasParameter, hasSubFeature); if (!(hasFeature || hasParameter)) return; -- 2.39.2