Gui: rename methods of SelectionObserver to clarify intention in client code

This commit is contained in:
wmayer
2021-12-07 14:17:07 +01:00
parent ce88fa2052
commit ca5c799ce2
18 changed files with 123 additions and 126 deletions

View File

@@ -506,7 +506,7 @@ void DlgFilletEdges::toggleCheckState(const QModelIndex& index)
QString name = QString::fromLatin1("Edge%1").arg(id);
Qt::CheckState checkState = static_cast<Qt::CheckState>(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()

View File

@@ -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<DimSelections::DimSelection>::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<DimSelections::DimSelection>::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<DimSelections::DimSelection>::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<DimSelections::DimSelection>::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)

View File

@@ -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);
}
}
}

View File

@@ -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);

View File

@@ -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<ViewProviderLoft*>(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<ViewProviderLoft*>(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<ViewProviderLoft*>(vp)->highlightReferences(true, true);
}
}

View File

@@ -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()

View File

@@ -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);
}
}
}

View File

@@ -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<std::string> 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)

View File

@@ -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<std::string> 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 && focusItemIndex<ui->listWidgetElements->count())

View File

@@ -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<void> (blockConnection(true)); // avoid to be notified by itself
static_cast<void> (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<void> (blockConnection(false));
static_cast<void> (blockSelection(false));
}
PyObject* MDIViewPage::getPyObject()
@@ -851,7 +851,7 @@ void MDIViewPage::saveSVG()
if (fn.isEmpty()) {
return;
}
static_cast<void> (blockConnection(true)); // avoid to be notified by itself
static_cast<void> (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<QGIView *> 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<QGraphicsItem*> sceneSel = m_qgSceneSelected;
for (QList<QGraphicsItem*>::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<Gui::SelectionObject> treeSel, QList<QGraphicsItem*> sceneSel)

View File

@@ -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);

View File

@@ -769,7 +769,7 @@ void QGIViewPart::removePrimitives()
QList<QGraphicsItem*> children = childItems();
MDIViewPage* mdi = getMDIViewPage();
if (mdi != nullptr) {
getMDIViewPage()->blockSelection(true);
getMDIViewPage()->blockSceneSelection(true);
}
for (auto& c:children) {
QGIPrimPath* prim = dynamic_cast<QGIPrimPath*>(c);
@@ -780,7 +780,7 @@ void QGIViewPart::removePrimitives()
}
}
if (mdi != nullptr) {
getMDIViewPage()->blockSelection(false);
getMDIViewPage()->blockSceneSelection(false);
}
}

View File

@@ -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);
}
}
}