From cb749b747d0a431725f536ef3968850032282dbb Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 20 Jan 2016 16:24:56 +0300 Subject: [PATCH] Clean history: correction for parameters. --- src/XGUI/XGUI_ContextMenuMgr.cpp | 5 +++-- src/XGUI/XGUI_Workshop.cpp | 29 +++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 648abd6cc..2f831b59f 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -217,7 +217,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() else if (hasFeature && myWorkshop->canMoveFeature()) action("MOVE_CMD")->setEnabled(true); - else if (hasFeature) + else if (hasFeature || hasParameter) action("CLEAN_HISTORY_CMD")->setEnabled(true); if( aMgr->activeDocument() == aObject->document() ) @@ -246,7 +246,7 @@ void XGUI_ContextMenuMgr::updateObjectBrowserMenu() if (hasFeature || hasParameter) action("DELETE_CMD")->setEnabled(true); } - if (allActive && hasFeature) + if (allActive && (hasFeature|| hasParameter)) action("CLEAN_HISTORY_CMD")->setEnabled(true); } @@ -384,6 +384,7 @@ void XGUI_ContextMenuMgr::buildObjBrowserMenu() aList.clear(); aList.append(action("DELETE_CMD")); + aList.append(action("CLEAN_HISTORY_CMD")); aList.append(mySeparator); aList.append(action("RENAME_CMD")); myObjBrowserMenus[ModelAPI_ResultParameter::group()] = aList; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 61d1796be..1747b7495 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -108,6 +108,7 @@ QString XGUI_Workshop::MOVE_TO_END_COMMAND = QObject::tr("Move to the end"); //#define DEBUG_DELETE +//#define DEBUG_FEATURE_NAME XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) : QObject(), @@ -597,7 +598,13 @@ void XGUI_Workshop::setPropertyPanel(ModuleBase_Operation* theOperation) myModule->propertyPanelDefined(theOperation); +#ifndef DEBUG_FEATURE_NAME myPropertyPanel->setWindowTitle(theOperation->getDescription()->description()); +#else + std::string aFeatureName = aFeature->name(); + myPropertyPanel->setWindowTitle(QString("%1: %2").arg(theOperation->getDescription()->description()) + .arg(aFeatureName.c_str())); +#endif myErrorMgr->setPropertyPanel(myPropertyPanel); } @@ -1212,29 +1219,35 @@ void XGUI_Workshop::cleanHistory() QObjectPtrList anObjects = mySelector->selection()->selectedObjects(); // 1. find all referenced features - std::set anUnusedFeatures; + QList anUnusedObjects; std::set aDirectRefFeatures; foreach (ObjectPtr anObject, anObjects) { FeaturePtr aFeature = std::dynamic_pointer_cast(anObject); + // for parameter result, use the corresponded reature to be removed + if (!aFeature.get() && anObject->groupName() == ModelAPI_ResultParameter::group()) { + aFeature = ModelAPI_Feature::feature(anObject); + } if (aFeature.get()) { std::set alreadyProcessed; aDirectRefFeatures.clear(); - XGUI_Tools::refsDirectToFeatureInAllDocuments(anObject, anObject, anObjects, + XGUI_Tools::refsDirectToFeatureInAllDocuments(aFeature, aFeature, anObjects, aDirectRefFeatures, alreadyProcessed); - if (aDirectRefFeatures.empty() && anUnusedFeatures.find(aFeature) == anUnusedFeatures.end()) - anUnusedFeatures.insert(aFeature); + if (aDirectRefFeatures.empty() && !anUnusedObjects.contains(aFeature)) + anUnusedObjects.append(aFeature); } } // 2. warn about the references remove, break the delete operation if the user chose it - if (!anUnusedFeatures.empty()) { + if (!anUnusedObjects.empty()) { QStringList aNames; - foreach (const FeaturePtr& aFeature, anUnusedFeatures) + foreach (const ObjectPtr& anObject, anUnusedObjects) { + FeaturePtr aFeature = std::dynamic_pointer_cast(anObject); aNames.append(aFeature->name().c_str()); + } QString anUnusedNames = aNames.join(", "); QString anActionId = "CLEAN_HISTORY_CMD"; - QString aDescription = contextMenuMgr()->action("DELETE_CMD")->text(); + QString aDescription = contextMenuMgr()->action(anActionId)->text(); QMessageBox aMessageBox(desktop()); aMessageBox.setWindowTitle(aDescription); @@ -1254,7 +1267,7 @@ void XGUI_Workshop::cleanHistory() operationMgr()->startOperation(anOpAction); std::set anIgnoredFeatures; - if (removeFeatures(anObjects, anIgnoredFeatures, anActionId)) { + if (removeFeatures(anUnusedObjects, anIgnoredFeatures, anActionId)) { operationMgr()->commitOperation(); } else { -- 2.39.2