From 520cfd89532f711382722d5bec2f1db6addccd8d Mon Sep 17 00:00:00 2001 From: donovaly Date: Tue, 25 Feb 2020 03:25:52 +0100 Subject: [PATCH] [FEM] constraint contact: sort out already available function additionally add some comments in TaskFemConstraint.cpp --- src/Mod/Fem/Gui/TaskFemConstraint.cpp | 24 +++++++++++--------- src/Mod/Fem/Gui/TaskFemConstraintContact.cpp | 18 --------------- src/Mod/Fem/Gui/TaskFemConstraintContact.h | 2 -- 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/src/Mod/Fem/Gui/TaskFemConstraint.cpp b/src/Mod/Fem/Gui/TaskFemConstraint.cpp index 0e85d3a5f1..f1c2f6827c 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraint.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraint.cpp @@ -136,21 +136,23 @@ const std::string TaskFemConstraint::getScale() const //OvG: Return pre-calculat } void TaskFemConstraint::setSelection(QListWidgetItem* item) { - std::string s = item->text().toStdString(); + // highlights the list item in the model + + // get the document name std::string docName = ConstraintView->getObject()->getDocument()->getName(); - + // name of the item + std::string ItemName = item->text().toStdString(); + // the object name is the part of the before the ':' of the item name std::string delimiter = ":"; - size_t pos = 0; - std::string objName; - std::string subName; - pos = s.find(delimiter); - objName = s.substr(0, pos); - s.erase(0, pos + delimiter.length()); - subName = s; - + pos = ItemName.find(delimiter); + std::string objName = ItemName.substr(0, pos); + // the subName is the name part tbehind the ':' + ItemName.erase(0, pos + delimiter.length()); + // clear existing selection Gui::Selection().clearSelection(); - Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0); + // highligh the selected item + Gui::Selection().addSelection(docName.c_str(), objName.c_str(), ItemName.c_str(), 0, 0, 0); } void TaskFemConstraint::onReferenceDeleted(const int row) { diff --git a/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp b/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp index 6cbf8947bb..2536e42993 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintContact.cpp @@ -384,24 +384,6 @@ void TaskFemConstraintContact::removeFromSelectionMaster() updateUI(); } -void TaskFemConstraintContact::setSelection(QListWidgetItem* item){ - std::string docName=ConstraintView->getObject()->getDocument()->getName(); - - std::string s = item->text().toStdString(); - std::string delimiter = ":"; - - size_t pos = 0; - std::string objName; - std::string subName; - pos = s.find(delimiter); - objName = s.substr(0, pos); - s.erase(0, pos + delimiter.length()); - subName=s; - - Gui::Selection().clearSelection(); - Gui::Selection().addSelection(docName.c_str(),objName.c_str(),subName.c_str(),0,0,0); -} - void TaskFemConstraintContact::onReferenceDeletedSlave() { TaskFemConstraintContact::removeFromSelectionSlave(); } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintContact.h b/src/Mod/Fem/Gui/TaskFemConstraintContact.h index b7390788ae..3e5d919027 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintContact.h +++ b/src/Mod/Fem/Gui/TaskFemConstraintContact.h @@ -38,7 +38,6 @@ #include #include #include -#include class Ui_TaskFemConstraintContact; @@ -61,7 +60,6 @@ private Q_SLOTS: void removeFromSelectionSlave(); void addToSelectionMaster(); void removeFromSelectionMaster(); - void setSelection(QListWidgetItem* item); protected: void changeEvent(QEvent *e);