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

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