From ca5c799ce207d5a04c03cf87bf6060dc65882abd Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 7 Dec 2021 14:17:07 +0100 Subject: [PATCH] Gui: rename methods of SelectionObserver to clarify intention in client code --- src/Gui/DlgPropertyLink.cpp | 12 ++-- src/Gui/PropertyView.cpp | 2 +- src/Gui/Selection.cpp | 35 +++++----- src/Gui/Selection.h | 8 +-- src/Gui/Tree.cpp | 64 +++++++++---------- src/Mod/Part/Gui/DlgFilletEdges.cpp | 4 +- src/Mod/Part/Gui/TaskDimension.cpp | 32 +++++----- src/Mod/Part/Gui/TaskShapeBuilder.cpp | 4 +- .../PartDesign/Gui/TaskExtrudeParameters.cpp | 2 - src/Mod/PartDesign/Gui/TaskLoftParameters.cpp | 8 +-- src/Mod/PartDesign/Gui/TaskPipeParameters.cpp | 6 +- .../Gui/TaskSketchBasedParameters.cpp | 6 +- .../Sketcher/Gui/TaskSketcherConstraints.cpp | 12 ++-- src/Mod/Sketcher/Gui/TaskSketcherElements.cpp | 4 +- src/Mod/TechDraw/Gui/MDIViewPage.cpp | 40 ++++++------ src/Mod/TechDraw/Gui/MDIViewPage.h | 2 +- src/Mod/TechDraw/Gui/QGIViewPart.cpp | 4 +- .../TechDraw/Gui/ViewProviderDrawingView.cpp | 4 +- 18 files changed, 123 insertions(+), 126 deletions(-) diff --git a/src/Gui/DlgPropertyLink.cpp b/src/Gui/DlgPropertyLink.cpp index ff99b918ed..7b7af21c2d 100644 --- a/src/Gui/DlgPropertyLink.cpp +++ b/src/Gui/DlgPropertyLink.cpp @@ -424,7 +424,7 @@ void DlgPropertyLink::closeEvent(QCloseEvent *ev) { } void DlgPropertyLink::attachObserver() { - if(isConnectionAttached()) + if(isSelectionAttached()) return; Gui::Selection().selStackPush(); @@ -443,7 +443,7 @@ void DlgPropertyLink::attachObserver() { } auto view = qobject_cast(parentView.data()); if(view) - view->blockConnection(true); + view->blockSelection(true); } void DlgPropertyLink::showEvent(QShowEvent *ev) { @@ -465,7 +465,7 @@ void DlgPropertyLink::leaveEvent(QEvent *ev) { } void DlgPropertyLink::detachObserver() { - if(isConnectionAttached()) + if(isSelectionAttached()) detachSelection(); auto view = qobject_cast(parentView.data()); @@ -480,7 +480,7 @@ void DlgPropertyLink::detachObserver() { savedSelections.clear(); } if(view) - view->blockConnection(false); + view->blockSelection(false); parentView = nullptr; } @@ -521,13 +521,13 @@ void DlgPropertyLink::onItemSelectionChanged() // Sync 3d view selection. To give a better visual feedback, we // only keep the latest selection. - bool blocked = blockConnection(true); + bool blocked = blockSelection(true); Gui::Selection().clearSelection(); for(auto &sobj : sobjs) Gui::Selection().addSelection(sobj.getDocumentName().c_str(), sobj.getObjectName().c_str(), sobj.getSubName().c_str()); - blockConnection(blocked); + blockSelection(blocked); // Enforce single parent if(singleParent && currentObj && currentObj!=obj) { diff --git a/src/Gui/PropertyView.cpp b/src/Gui/PropertyView.cpp index 4bae844d0a..3e8ce61fb2 100644 --- a/src/Gui/PropertyView.cpp +++ b/src/Gui/PropertyView.cpp @@ -351,7 +351,7 @@ void PropertyView::onTimer() { clearPropertyItemSelection(); timer->stop(); - if(!this->isConnectionAttached()) + if(!this->isSelectionAttached()) return; if(!Gui::Selection().hasSelection()) { diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index d9bc56029b..f025bf59f7 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -85,21 +85,23 @@ bool SelectionGateFilterExternal::allow(App::Document *doc ,App::DocumentObject ////////////////////////////////////////////////////////////////////////////////////////// -SelectionObserver::SelectionObserver(bool attach,int resolve) - :resolve(resolve),blockSelection(false) +SelectionObserver::SelectionObserver(bool attach, int resolve) + : resolve(resolve) + , blockedSelection(false) { - if(attach) + if (attach) attachSelection(); } -SelectionObserver::SelectionObserver(const ViewProviderDocumentObject *vp,bool attach,int resolve) - :resolve(resolve),blockSelection(false) +SelectionObserver::SelectionObserver(const ViewProviderDocumentObject *vp,bool attach, int resolve) + : resolve(resolve) + , blockedSelection(false) { - if(vp && vp->getObject() && vp->getObject()->getDocument()) { + if (vp && vp->getObject() && vp->getObject()->getDocument()) { filterDocName = vp->getObject()->getDocument()->getName(); filterObjName = vp->getObject()->getNameInDocument(); } - if(attach) + if (attach) attachSelection(); } @@ -109,22 +111,19 @@ SelectionObserver::~SelectionObserver() detachSelection(); } -bool SelectionObserver::blockConnection(bool block) +bool SelectionObserver::blockSelection(bool block) { - bool ok = blockSelection; - if (block) - blockSelection = true; - else - blockSelection = false; + bool ok = blockedSelection; + blockedSelection = block; return ok; } -bool SelectionObserver::isConnectionBlocked() const +bool SelectionObserver::isSelectionBlocked() const { - return blockSelection; + return blockedSelection; } -bool SelectionObserver::isConnectionAttached() const +bool SelectionObserver::isSelectionAttached() const { return connectSelection.connected(); } @@ -147,7 +146,7 @@ void SelectionObserver::attachSelection() void SelectionObserver::_onSelectionChanged(const SelectionChanges& msg) { try { - if (blockSelection) + if (blockedSelection) return; onSelectionChanged(msg); } catch (Base::Exception &e) { @@ -164,7 +163,7 @@ void SelectionObserver::detachSelection() { if (connectSelection.connected()) { connectSelection.disconnect(); - if(filterDocName.size()) + if (filterDocName.size()) Selection().rmvSelectionGate(); } } diff --git a/src/Gui/Selection.h b/src/Gui/Selection.h index da62babcd2..c045ef3328 100644 --- a/src/Gui/Selection.h +++ b/src/Gui/Selection.h @@ -232,9 +232,9 @@ public: SelectionObserver(const Gui::ViewProviderDocumentObject *vp, bool attach=true, int resolve=1); virtual ~SelectionObserver(); - bool blockConnection(bool block); - bool isConnectionBlocked() const; - bool isConnectionAttached() const; + bool blockSelection(bool block); + bool isSelectionBlocked() const; + bool isSelectionAttached() const; /** Attaches to the selection. */ void attachSelection(); @@ -251,7 +251,7 @@ private: std::string filterDocName; std::string filterObjName; int resolve; - bool blockSelection; + bool blockedSelection; }; /** diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 2e2c0f41a5..a4f35ac27c 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -628,9 +628,9 @@ void TreeWidget::checkTopParent(App::DocumentObject*& obj, std::string& subname) auto it = tree->DocumentMap.find(Application::Instance->getDocument(obj->getDocument())); if (it != tree->DocumentMap.end()) { if (tree->statusTimer->isActive()) { - bool locked = tree->blockConnection(true); + bool locked = tree->blockSelection(true); tree->_updateStatus(false); - tree->blockConnection(locked); + tree->blockSelection(locked); } auto parent = it->second->getTopParent(obj, subname); if (parent) @@ -1204,7 +1204,7 @@ DocumentItem* TreeWidget::getDocumentItem(const Gui::Document* doc) const { } void TreeWidget::selectAllInstances(const ViewProviderDocumentObject& vpd) { - if (!isConnectionAttached()) + if (!isSelectionAttached()) return; if (selectTimer->isActive()) @@ -1233,9 +1233,9 @@ std::vector TreeWidget::getSelection(App::Document* doc) std::vector ret; TreeWidget* tree = instance(); - if (!tree || !tree->isConnectionAttached()) { + if (!tree || !tree->isSelectionAttached()) { for (auto pTree : Instances) - if (pTree->isConnectionAttached()) { + if (pTree->isSelectionAttached()) { tree = pTree; break; } @@ -1286,7 +1286,7 @@ std::vector TreeWidget::getSelection(App::Document* doc) } void TreeWidget::selectAllLinks(App::DocumentObject* obj) { - if (!isConnectionAttached()) + if (!isSelectionAttached()) return; if (!obj || !obj->getNameInDocument()) { @@ -2620,14 +2620,14 @@ void TreeWidget::onUpdateStatus(void) docItem->_ExpandInfo.reset(); } - if (Selection().hasSelection() && !selectTimer->isActive() && !this->isConnectionBlocked()) { - this->blockConnection(true); + if (Selection().hasSelection() && !selectTimer->isActive() && !this->isSelectionBlocked()) { + this->blockSelection(true); currentDocItem = 0; for (auto& v : DocumentMap) { v.second->setSelected(false); v.second->selectItems(); } - this->blockConnection(false); + this->blockSelection(false); } auto activeDocItem = getDocumentItem(Application::Instance->activeDocument()); @@ -2745,7 +2745,7 @@ void TreeWidget::scrollItemToTop() { auto doc = Application::Instance->activeDocument(); for (auto tree : Instances) { - if (!tree->isConnectionAttached() || tree->isConnectionBlocked()) + if (!tree->isSelectionAttached() || tree->isSelectionBlocked()) continue; tree->_updateStatus(false); @@ -2753,13 +2753,13 @@ void TreeWidget::scrollItemToTop() if (doc && Gui::Selection().hasSelection(doc->getDocument()->getName(), false)) { auto it = tree->DocumentMap.find(doc); if (it != tree->DocumentMap.end()) { - bool lock = tree->blockConnection(true); + bool lock = tree->blockSelection(true); it->second->selectItems(DocumentItem::SR_FORCE_EXPAND); - tree->blockConnection(lock); + tree->blockSelection(lock); } } else { - tree->blockConnection(true); + tree->blockSelection(true); for (int i = 0; i < tree->rootItem->childCount(); i++) { auto docItem = dynamic_cast(tree->rootItem->child(i)); if (!docItem) @@ -2772,7 +2772,7 @@ void TreeWidget::scrollItemToTop() break; } } - tree->blockConnection(false); + tree->blockSelection(false); } tree->selectTimer->stop(); tree->_updateStatus(false); @@ -2781,7 +2781,7 @@ void TreeWidget::scrollItemToTop() void TreeWidget::expandSelectedItems(TreeItemMode mode) { - if (!isConnectionAttached()) + if (!isSelectionAttached()) return; for (auto item : selectedItems()) { @@ -2897,15 +2897,15 @@ void TreeWidget::changeEvent(QEvent* e) void TreeWidget::onItemSelectionChanged() { - if (!this->isConnectionAttached() - || this->isConnectionBlocked() + if (!this->isSelectionAttached() + || this->isSelectionBlocked() || updateBlocked) return; _LastSelectedTreeWidget = this; // block tmp. the connection to avoid to notify us ourself - bool lock = this->blockConnection(true); + bool lock = this->blockSelection(true); if (selectTimer->isActive()) onSelectTimer(); @@ -2972,7 +2972,7 @@ void TreeWidget::onItemSelectionChanged() Gui::Selection().selStackPush(true, true); } - this->blockConnection(lock); + this->blockSelection(lock); } static bool isSelectionCheckBoxesEnabled() { @@ -3020,7 +3020,7 @@ void TreeWidget::onSelectTimer() { _updateStatus(false); bool syncSelect = TreeParams::Instance()->SyncSelection(); - bool locked = this->blockConnection(true); + bool locked = this->blockSelection(true); if (Selection().hasSelection()) { for (auto& v : DocumentMap) { v.second->setSelected(false); @@ -3033,7 +3033,7 @@ void TreeWidget::onSelectTimer() { for (auto& v : DocumentMap) v.second->clearSelection(); } - this->blockConnection(locked); + this->blockSelection(locked); selectTimer->stop(); return; } @@ -3168,7 +3168,7 @@ TreeDockWidget::~TreeDockWidget() } void TreeWidget::selectLinkedObject(App::DocumentObject* linked) { - if (!isConnectionAttached() || isConnectionBlocked()) + if (!isSelectionAttached() || isSelectionBlocked()) return; auto linkedVp = Base::freecad_dynamic_cast( @@ -3469,13 +3469,13 @@ void TreeWidget::_slotDeleteObject(const Gui::ViewProviderDocumentObject& view, if (obj->getDocument() == doc) docItem->_ParentMap.erase(obj); - bool lock = blockConnection(true); + bool lock = blockSelection(true); for (auto cit = items.begin(), citNext = cit; cit != items.end(); cit = citNext) { ++citNext; (*cit)->myOwner = 0; delete* cit; } - blockConnection(lock); + blockSelection(lock); // Check for any child of the deleted object that is not in the tree, and put it // under document item. @@ -3606,9 +3606,9 @@ void DocumentItem::populateItem(DocumentObjectItem* item, bool refresh, bool del if (item->myData->removeChildrenFromRoot) { if (childItem->myData->rootItem) { assert(childItem != childItem->myData->rootItem); - bool lock = getTree()->blockConnection(true); + bool lock = getTree()->blockSelection(true); delete childItem->myData->rootItem; - getTree()->blockConnection(lock); + getTree()->blockSelection(lock); } } else if (childItem->requiredAtRoot()) { @@ -3679,9 +3679,9 @@ void DocumentItem::populateItem(DocumentObjectItem* item, bool refresh, bool del } } - bool lock = getTree()->blockConnection(true); + bool lock = getTree()->blockSelection(true); delete ci; - getTree()->blockConnection(lock); + getTree()->blockSelection(lock); } if (updated) getTree()->_updateStatus(); @@ -4517,7 +4517,7 @@ void DocumentItem::selectAllInstances(const ViewProviderDocumentObject& vpd) { if (ObjectMap.find(pObject) == ObjectMap.end()) return; - bool lock = getTree()->blockConnection(true); + bool lock = getTree()->blockSelection(true); // We are trying to select all items corresponding to a given view // provider, i.e. all appearance of the object inside all its parent items @@ -4542,7 +4542,7 @@ void DocumentItem::selectAllInstances(const ViewProviderDocumentObject& vpd) { first = item; END_FOREACH_ITEM; - getTree()->blockConnection(lock); + getTree()->blockSelection(lock); if (first) { treeWidget()->scrollToItem(first); updateSelection(); @@ -4594,9 +4594,9 @@ void DocumentItem::updateItemsVisibility(QTreeWidgetItem* item, bool show) { } void DocumentItem::updateSelection() { - bool lock = getTree()->blockConnection(true); + bool lock = getTree()->blockSelection(true); updateSelection(this, false); - getTree()->blockConnection(lock); + getTree()->blockSelection(lock); } // ---------------------------------------------------------------------------- diff --git a/src/Mod/Part/Gui/DlgFilletEdges.cpp b/src/Mod/Part/Gui/DlgFilletEdges.cpp index 1b2315afac..af7f702a06 100644 --- a/src/Mod/Part/Gui/DlgFilletEdges.cpp +++ b/src/Mod/Part/Gui/DlgFilletEdges.cpp @@ -506,7 +506,7 @@ void DlgFilletEdges::toggleCheckState(const QModelIndex& index) QString name = QString::fromLatin1("Edge%1").arg(id); Qt::CheckState checkState = static_cast(check.toInt()); - bool block = this->blockConnection(true); + bool block = this->blockSelection(true); // is item checked if (checkState & Qt::Checked) { @@ -522,7 +522,7 @@ void DlgFilletEdges::toggleCheckState(const QModelIndex& index) (const char*)name.toLatin1()); } - this->blockConnection(block); + this->blockSelection(block); } void DlgFilletEdges::findShapes() diff --git a/src/Mod/Part/Gui/TaskDimension.cpp b/src/Mod/Part/Gui/TaskDimension.cpp index 0b411e5207..328120e039 100644 --- a/src/Mod/Part/Gui/TaskDimension.cpp +++ b/src/Mod/Part/Gui/TaskDimension.cpp @@ -583,9 +583,9 @@ void PartGui::TaskMeasureLinear::selectionClearDelayedSlot() //clearing selections are not working as I hoped. Apparently the observer callback gets called //before the actual selection takes place. Resulting in selections being left. this addresses this //by being called from the event loop. - this->blockConnection(true); + this->blockSelection(true); Gui::Selection().clearSelection(); - this->blockConnection(false); + this->blockSelection(false); } void PartGui::TaskMeasureLinear::buildDimension() { @@ -663,13 +663,13 @@ void PartGui::TaskMeasureLinear::selection1Slot(bool checked) } buttonSelectedIndex = 0; - this->blockConnection(true); + this->blockSelection(true); Gui::Selection().clearSelection(); //we should only be working with 1 entity, but oh well do the loop anyway. std::vector::const_iterator it; for (it = selections1.selections.begin(); it != selections1.selections.end(); ++it) Gui::Selection().addSelection(it->documentName.c_str(), it->objectName.c_str(), it->subObjectName.c_str()); - this->blockConnection(false); + this->blockSelection(false); } void PartGui::TaskMeasureLinear::selection2Slot(bool checked) @@ -677,22 +677,22 @@ void PartGui::TaskMeasureLinear::selection2Slot(bool checked) if (!checked) return; buttonSelectedIndex = 1; - this->blockConnection(true); + this->blockSelection(true); Gui::Selection().clearSelection(); std::vector::const_iterator it; for (it = selections2.selections.begin(); it != selections2.selections.end(); ++it) Gui::Selection().addSelection(it->documentName.c_str(), it->objectName.c_str(), it->subObjectName.c_str()); - this->blockConnection(false); + this->blockSelection(false); } void PartGui::TaskMeasureLinear::resetDialogSlot(bool) { clearSelectionStrings(); - this->blockConnection(true); + this->blockSelection(true); Gui::Selection().clearSelection(); stepped->getButton(0)->setChecked(true); stepped->getButton(1)->setEnabled(false); - this->blockConnection(false); + this->blockSelection(false); } void PartGui::TaskMeasureLinear::toggle3dSlot(bool) @@ -1664,9 +1664,9 @@ void PartGui::TaskMeasureAngular::selectionClearDelayedSlot() //clearing selections are not working as I hoped. Apparently the observer callback gets called //before the actual selection takes place. Resulting in selections being left. this addresses this //by being called from the event loop. - this->blockConnection(true); + this->blockSelection(true); Gui::Selection().clearSelection(); - this->blockConnection(false); + this->blockSelection(false); } PartGui::VectorAdapter PartGui::TaskMeasureAngular::buildAdapter(const PartGui::DimSelections& selection) @@ -1796,12 +1796,12 @@ void PartGui::TaskMeasureAngular::selection1Slot(bool checked) if (checked) { buttonSelectedIndex = 0; - this->blockConnection(true); + this->blockSelection(true); Gui::Selection().clearSelection(); std::vector::const_iterator it; for (it = selections1.selections.begin(); it != selections1.selections.end(); ++it) Gui::Selection().addSelection(it->documentName.c_str(), it->objectName.c_str(), it->subObjectName.c_str()); - this->blockConnection(false); + this->blockSelection(false); } else { @@ -1814,22 +1814,22 @@ void PartGui::TaskMeasureAngular::selection2Slot(bool checked) { if (checked) buttonSelectedIndex = 1; - this->blockConnection(true); + this->blockSelection(true); Gui::Selection().clearSelection(); std::vector::const_iterator it; for (it = selections2.selections.begin(); it != selections2.selections.end(); ++it) Gui::Selection().addSelection(it->documentName.c_str(), it->objectName.c_str(), it->subObjectName.c_str()); - this->blockConnection(false); + this->blockSelection(false); } void PartGui::TaskMeasureAngular::resetDialogSlot(bool) { clearSelection(); - this->blockConnection(true); + this->blockSelection(true); Gui::Selection().clearSelection(); stepped->getButton(0)->setChecked(true); stepped->getButton(1)->setEnabled(false); - this->blockConnection(false); + this->blockSelection(false); } void PartGui::TaskMeasureAngular::toggle3dSlot(bool) diff --git a/src/Mod/Part/Gui/TaskShapeBuilder.cpp b/src/Mod/Part/Gui/TaskShapeBuilder.cpp index f75b3b46eb..8d8b8e5407 100644 --- a/src/Mod/Part/Gui/TaskShapeBuilder.cpp +++ b/src/Mod/Part/Gui/TaskShapeBuilder.cpp @@ -144,7 +144,7 @@ void ShapeBuilderWidget::onSelectionChanged(const Gui::SelectionChanges& msg) std::string subName(msg.pSubName); if (!subName.empty()) { // From the shape get all faces and add them to the selection - bool blocked = blockConnection(true); + bool blocked = blockSelection(true); App::Document* doc = App::GetApplication().getDocument(msg.pDocName); App::DocumentObject* obj = doc->getObject(msg.pObjectName); if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { @@ -161,7 +161,7 @@ void ShapeBuilderWidget::onSelectionChanged(const Gui::SelectionChanges& msg) } } - blockConnection(blocked); + blockSelection(blocked); } } } diff --git a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp index 8f16ac5af4..efc8c70dc0 100644 --- a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp @@ -406,8 +406,6 @@ void TaskExtrudeParameters::onDirectionCBChanged(int num) // or we are normal to a face App::PropertyLinkSub& lnk = *(axesInList[num]); if (num == DirectionModes::Select) { - // enter reference selection mode - this->blockConnection(false); // to distinguish that this is the direction selection selectionFace = false; setDirectionMode(num); diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp index 9cc95c3972..7618e116dd 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp @@ -304,7 +304,7 @@ void TaskLoftParameters::exitSelectionMode() { selectionMode = none; Gui::Selection().clearSelection(); - this->blockConnection(true); + this->blockSelection(true); } void TaskLoftParameters::changeEvent(QEvent * /*e*/) @@ -327,7 +327,7 @@ void TaskLoftParameters::onProfileButton(bool checked) clearButtons(refProfile); Gui::Selection().clearSelection(); selectionMode = refProfile; - this->blockConnection(false); + this->blockSelection(false); //static_cast(vp)->highlightReferences(true, true); } } @@ -338,7 +338,7 @@ void TaskLoftParameters::onRefButtonAdd(bool checked) clearButtons(refAdd); Gui::Selection().clearSelection(); selectionMode = refAdd; - this->blockConnection(false); + this->blockSelection(false); //static_cast(vp)->highlightReferences(true, true); } } @@ -349,7 +349,7 @@ void TaskLoftParameters::onRefButtonRemove(bool checked) clearButtons(refRemove); Gui::Selection().clearSelection(); selectionMode = refRemove; - this->blockConnection(false); + this->blockSelection(false); //static_cast(vp)->highlightReferences(true, true); } } diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index fe6d28604e..e91022cd28 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -149,7 +149,7 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView, bool /*newObj ui->comboBoxTransition->setCurrentIndex(pipe->Transition.getValue()); updateUI(); - this->blockConnection(false); + this->blockSelection(false); } TaskPipeParameters::~TaskPipeParameters() @@ -664,7 +664,7 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, bool /*newO // should be called after panel has become visible QMetaObject::invokeMethod(this, "updateUI", Qt::QueuedConnection, QGenericReturnArgument(), Q_ARG(int,pipe->Mode.getValue())); - this->blockConnection(false); + this->blockSelection(false); } TaskPipeOrientation::~TaskPipeOrientation() @@ -960,7 +960,7 @@ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool /*newObj*/, QW // should be called after panel has become visible QMetaObject::invokeMethod(this, "updateUI", Qt::QueuedConnection, QGenericReturnArgument(), Q_ARG(int,pipe->Transformation.getValue())); - this->blockConnection(false); + this->blockSelection(false); } TaskPipeScaling::~TaskPipeScaling() diff --git a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp index dee0812702..1f1c5ba27c 100644 --- a/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskSketchBasedParameters.cpp @@ -64,7 +64,7 @@ TaskSketchBasedParameters::TaskSketchBasedParameters(PartDesignGui::ViewProvider : TaskFeatureParameters(vp, parent, pixmapname, parname) { // disable selection - this->blockConnection(true); + this->blockSelection(true); } const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChanges& msg) @@ -123,14 +123,14 @@ void TaskSketchBasedParameters::onSelectReference(AllowSelectionFlags allow) { if (AllowSelectionFlags::Int(allow) != int(AllowSelection::NONE)) { startReferenceSelection(pcSketchBased, prevSolid); - this->blockConnection(false); + this->blockSelection(false); Gui::Selection().clearSelection(); Gui::Selection().addSelectionGate(new ReferenceSelection(prevSolid, allow)); } else { Gui::Selection().rmvSelectionGate(); finishReferenceSelection(pcSketchBased, prevSolid); - this->blockConnection(true); + this->blockSelection(true); } } } diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp index 93ec845a5e..c67fa66a62 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp @@ -951,9 +951,9 @@ void TaskSketcherConstraints::onSelectionChanged(const Gui::SelectionChanges& ms if(isFilter(ConstraintFilter::SpecialFilterValue::Selection)) { updateSelectionFilter(); - bool block = this->blockConnection(true); // avoid to be notified by itself + bool block = this->blockSelection(true); // avoid to be notified by itself updateList(); - this->blockConnection(block); + this->blockSelection(block); } else if (isFilter(ConstraintFilter::SpecialFilterValue::AssociatedConstraints)) { associatedConstraintsFilter.clear(); @@ -988,9 +988,9 @@ void TaskSketcherConstraints::onSelectionChanged(const Gui::SelectionChanges& ms if(isFilter(ConstraintFilter::SpecialFilterValue::Selection)) { updateSelectionFilter(); - bool block = this->blockConnection(true); // avoid to be notified by itself + bool block = this->blockSelection(true); // avoid to be notified by itself updateList(); - this->blockConnection(block); + this->blockSelection(block); } } } @@ -1116,7 +1116,7 @@ void TaskSketcherConstraints::on_listWidgetConstraints_itemSelectionChanged(void std::string doc_name = sketchView->getSketchObject()->getDocument()->getName(); std::string obj_name = sketchView->getSketchObject()->getNameInDocument(); - bool block = this->blockConnection(true); // avoid to be notified by itself + bool block = this->blockSelection(true); // avoid to be notified by itself Gui::Selection().clearSelection(); std::vector constraintSubNames; @@ -1129,7 +1129,7 @@ void TaskSketcherConstraints::on_listWidgetConstraints_itemSelectionChanged(void if(!constraintSubNames.empty()) Gui::Selection().addSelections(doc_name.c_str(), obj_name.c_str(), constraintSubNames); - this->blockConnection(block); + this->blockSelection(block); } void TaskSketcherConstraints::on_listWidgetConstraints_itemActivated(QListWidgetItem *item) diff --git a/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp b/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp index f19ffbd650..0e06d85084 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp @@ -509,7 +509,7 @@ void TaskSketcherElements::on_listWidgetElements_itemSelectionChanged(void) std::string doc_name = sketchView->getSketchObject()->getDocument()->getName(); std::string obj_name = sketchView->getSketchObject()->getNameInDocument(); - bool block = this->blockConnection(true); // avoid to be notified by itself + bool block = this->blockSelection(true); // avoid to be notified by itself Gui::Selection().clearSelection(); std::vector elementSubNames; @@ -603,7 +603,7 @@ void TaskSketcherElements::on_listWidgetElements_itemSelectionChanged(void) Gui::Selection().addSelections(doc_name.c_str(), obj_name.c_str(), elementSubNames); } - this->blockConnection(block); + this->blockSelection(block); ui->listWidgetElements->blockSignals(false); if (focusItemIndex>-1 && focusItemIndexlistWidgetElements->count()) diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.cpp b/src/Mod/TechDraw/Gui/MDIViewPage.cpp index 8b305bf0bd..8d143d5932 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.cpp +++ b/src/Mod/TechDraw/Gui/MDIViewPage.cpp @@ -293,7 +293,7 @@ void MDIViewPage::closeEvent(QCloseEvent* ev) return; detachSelection(); - blockSelection(true); + blockSceneSelection(true); // when closing the view from GUI notify the view provider to mark it invisible if (_pcDocument && !m_objectName.empty()) { App::Document* doc = _pcDocument->getDocument(); @@ -304,7 +304,7 @@ void MDIViewPage::closeEvent(QCloseEvent* ev) vp->hide(); } } - blockSelection(false); + blockSceneSelection(false); } void MDIViewPage::attachTemplate(TechDraw::DrawTemplate *obj) @@ -406,11 +406,11 @@ bool MDIViewPage::attachView(App::DocumentObject *obj) void MDIViewPage::onDeleteObject(const App::DocumentObject& obj) { //if this page has a QView for this obj, delete it. - blockSelection(true); + blockSceneSelection(true); if (obj.isDerivedFrom(TechDraw::DrawView::getClassTypeId())) { (void) m_view->removeQViewByName(obj.getNameInDocument()); } - blockSelection(false); + blockSceneSelection(false); } void MDIViewPage::onTimer() { @@ -774,7 +774,7 @@ void MDIViewPage::print(QPrinter* printer) #endif //bool block = - static_cast (blockConnection(true)); // avoid to be notified by itself + static_cast (blockSelection(true)); // avoid to be notified by itself Gui::Selection().clearSelection(); bool saveState = m_vpPage->getFrameState(); @@ -801,7 +801,7 @@ void MDIViewPage::print(QPrinter* printer) m_vpPage->setTemplateMarkers(saveState); m_view->refreshViews(); //bool block = - static_cast (blockConnection(false)); + static_cast (blockSelection(false)); } PyObject* MDIViewPage::getPyObject() @@ -851,7 +851,7 @@ void MDIViewPage::saveSVG() if (fn.isEmpty()) { return; } - static_cast (blockConnection(true)); // avoid to be notified by itself + static_cast (blockSelection(true)); // avoid to be notified by itself m_view->saveSvg(fn); } @@ -967,7 +967,7 @@ void MDIViewPage::preSelectionChanged(const QPoint &pos) } //flag to prevent selection activity within mdivp -void MDIViewPage::blockSelection(const bool state) +void MDIViewPage::blockSceneSelection(const bool state) { isSelectionBlocked = state; } @@ -977,7 +977,7 @@ void MDIViewPage::blockSelection(const bool state) void MDIViewPage::clearSceneSelection() { // Base::Console().Message("MDIVP::clearSceneSelection()\n"); - blockSelection(true); + blockSceneSelection(true); m_qgSceneSelected.clear(); std::vector views = m_view->getViews(); @@ -1004,7 +1004,7 @@ void MDIViewPage::clearSceneSelection() } } - blockSelection(false); + blockSceneSelection(false); } //!Update QGIView's selection state based on Selection made outside Drawing Interface @@ -1012,12 +1012,12 @@ void MDIViewPage::selectQGIView(App::DocumentObject *obj, const bool isSelected) { QGIView *view = m_view->findQViewForDocObj(obj); - blockSelection(true); + blockSceneSelection(true); if(view) { view->setGroupSelection(isSelected); view->updateView(); } - blockSelection(false); + blockSceneSelection(false); } //! invoked by selection change made in Tree via father MDIView @@ -1030,21 +1030,21 @@ void MDIViewPage::onSelectionChanged(const Gui::SelectionChanges& msg) clearSceneSelection(); } else if(msg.Type == Gui::SelectionChanges::SetSelection) { //replace entire selection set clearSceneSelection(); - blockSelection(true); + blockSceneSelection(true); for (auto& so: selObjs){ if (so.pObject->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) { selectQGIView(so.pObject, true); } } - blockSelection(false); + blockSceneSelection(false); } else if(msg.Type == Gui::SelectionChanges::AddSelection) { - blockSelection(true); + blockSceneSelection(true); for (auto& so: selObjs){ if (so.pObject->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) { selectQGIView(so.pObject, true); } } - blockSelection(false); + blockSceneSelection(false); } else { Base::Console().Log("MDIVP::onSelectionChanged - unhandled: %d\n", msg.Type); } @@ -1123,8 +1123,8 @@ void MDIViewPage::sceneSelectionChanged() //Note: Qt says: "no guarantee of selection order"!!! void MDIViewPage::setTreeToSceneSelect(void) { - bool saveBlock = blockConnection(true); // block selectionChanged signal from Tree/Observer - blockSelection(true); + bool saveBlock = blockSelection(true); // block selectionChanged signal from Tree/Observer + blockSceneSelection(true); Gui::Selection().clearSelection(); QList sceneSel = m_qgSceneSelected; for (QList::iterator it = sceneSel.begin(); it != sceneSel.end(); ++it) { @@ -1268,8 +1268,8 @@ void MDIViewPage::setTreeToSceneSelect(void) } } - blockSelection(false); - blockConnection(saveBlock); + blockSceneSelection(false); + blockSelection(saveBlock); } bool MDIViewPage::compareSelections(std::vector treeSel, QList sceneSel) diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.h b/src/Mod/TechDraw/Gui/MDIViewPage.h index e2f2655ce8..cf16ffb278 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.h +++ b/src/Mod/TechDraw/Gui/MDIViewPage.h @@ -72,7 +72,7 @@ public: /// QGraphicsScene selection routines void selectQGIView(App::DocumentObject *obj, bool state); void clearSceneSelection(); - void blockSelection(bool isBlocked); + void blockSceneSelection(bool isBlocked); void attachTemplate(TechDraw::DrawTemplate *obj); void updateTemplate(bool force = false); diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index de3afe6151..ac60795542 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -769,7 +769,7 @@ void QGIViewPart::removePrimitives() QList children = childItems(); MDIViewPage* mdi = getMDIViewPage(); if (mdi != nullptr) { - getMDIViewPage()->blockSelection(true); + getMDIViewPage()->blockSceneSelection(true); } for (auto& c:children) { QGIPrimPath* prim = dynamic_cast(c); @@ -780,7 +780,7 @@ void QGIViewPart::removePrimitives() } } if (mdi != nullptr) { - getMDIViewPage()->blockSelection(false); + getMDIViewPage()->blockSceneSelection(false); } } diff --git a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp index da302c2b98..8fe7b4ca5c 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp @@ -169,10 +169,10 @@ void ViewProviderDrawingView::hide(void) // block/unblock selection protects against crash in Gui::SelectionSingleton::setVisible MDIViewPage* mdi = getMDIViewPage(); if (mdi != nullptr) { //if there is no mdivp, there is nothing to hide! - mdi->blockSelection(true); + mdi->blockSceneSelection(true); qView->hide(); ViewProviderDocumentObject::hide(); - mdi->blockSelection(false); + mdi->blockSceneSelection(false); } } }