Skip to content

Commit

Permalink
TreeView: update status on manual object touch
Browse files Browse the repository at this point in the history
  • Loading branch information
realthunder authored and wwmayer committed Aug 17, 2019
1 parent d4f066f commit 78ce18a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
18 changes: 7 additions & 11 deletions src/Gui/Document.cpp
Expand Up @@ -371,16 +371,12 @@ bool Document::setEdit(Gui::ViewProvider* p, int ModNum, const char *subname)
}
}

View3DInventor *activeView = dynamic_cast<View3DInventor *>(getActiveView());
View3DInventor *view3d = dynamic_cast<View3DInventor *>(getActiveView());
// if the currently active view is not the 3d view search for it and activate it
if (!activeView) {
activeView = dynamic_cast<View3DInventor *>(setActiveView(vp));
if(!activeView){
FC_ERR("cannot edit without active view");
return false;
}
}
getMainWindow()->setActiveWindow(activeView);
if (view3d)
getMainWindow()->setActiveWindow(view3d);
else
view3d = dynamic_cast<View3DInventor *>(setActiveView(vp));
Application::Instance->setEditDocument(this);

d->_editViewProviderParent = vp;
Expand All @@ -402,7 +398,8 @@ bool Document::setEdit(Gui::ViewProvider* p, int ModNum, const char *subname)
FC_LOG("object '" << sobj->getFullName() << "' refuse to edit");
return false;
}
activeView->getViewer()->setEditingViewProvider(d->_editViewProvider,ModNum);
if(view3d)
view3d->getViewer()->setEditingViewProvider(d->_editViewProvider,ModNum);
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
if (dlg)
dlg->setDocumentName(this->getDocument()->getName());
Expand Down Expand Up @@ -871,7 +868,6 @@ void Document::slotSkipRecompute(const App::Document& doc, const std::vector<App
void Document::slotTouchedObject(const App::DocumentObject &Obj)
{
getMainWindow()->updateActions(true);
TreeWidget::updateStatus(true);
if(!isModified()) {
FC_LOG(Obj.getFullName() << " touched");
setModified(true);
Expand Down
21 changes: 18 additions & 3 deletions src/Gui/Tree.cpp
Expand Up @@ -2155,11 +2155,18 @@ void TreeWidget::slotChangedViewObject(const Gui::ViewProvider& vp, const App::P
&& vp.isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
{
const auto &vpd = static_cast<const ViewProviderDocumentObject&>(vp);
if(&prop == &vpd.ShowInTree)
if(&prop == &vpd.ShowInTree) {
ChangedObjects.emplace(vpd.getObject(),0);
_updateStatus();
}
}
}

void TreeWidget::slotTouchedObject(const App::DocumentObject &obj) {
ChangedObjects.emplace(const_cast<App::DocumentObject*>(&obj),0);
_updateStatus();
}

void TreeWidget::slotShowHidden(const Gui::Document& Doc)
{
auto it = DocumentMap.find(&Doc);
Expand Down Expand Up @@ -2331,10 +2338,14 @@ void TreeWidget::onUpdateStatus(void)

if(docItem->connectChgObject.connected())
continue;

auto doc = v.first->getDocument();

docItem->connectChgObject = docItem->document()->signalChangedObject.connect(
boost::bind(&TreeWidget::slotChangeObject, this, _1, _2));
docItem->connectTouchedObject = doc->signalTouchedObject.connect(
boost::bind(&TreeWidget::slotTouchedObject, this, _1));

auto doc = v.first->getDocument();
if(doc->testStatus(App::Document::PartialDoc))
docItem->setIcon(0, *documentPartialPixmap);
else if(docItem->_ExpandInfo) {
Expand Down Expand Up @@ -2909,9 +2920,12 @@ DocumentItem::DocumentItem(const Gui::Document* doc, QTreeWidgetItem * parent)
connectNewObject = doc->signalNewObject.connect(boost::bind(&DocumentItem::slotNewObject, this, _1));
connectDelObject = doc->signalDeletedObject.connect(
boost::bind(&TreeWidget::slotDeleteObject, getTree(), _1));
if(!App::GetApplication().isRestoring())
if(!App::GetApplication().isRestoring()) {
connectChgObject = doc->signalChangedObject.connect(
boost::bind(&TreeWidget::slotChangeObject, getTree(), _1, _2));
connectTouchedObject = doc->getDocument()->signalTouchedObject.connect(
boost::bind(&TreeWidget::slotTouchedObject, getTree(), _1));
}
connectEdtObject = doc->signalInEdit.connect(boost::bind(&DocumentItem::slotInEdit, this, _1));
connectResObject = doc->signalResetEdit.connect(boost::bind(&DocumentItem::slotResetEdit, this, _1));
connectHltObject = doc->signalHighlightObject.connect(
Expand All @@ -2934,6 +2948,7 @@ DocumentItem::~DocumentItem()
connectNewObject.disconnect();
connectDelObject.disconnect();
connectChgObject.disconnect();
connectTouchedObject.disconnect();
connectEdtObject.disconnect();
connectResObject.disconnect();
connectHltObject.disconnect();
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/Tree.h
Expand Up @@ -193,6 +193,7 @@ private Q_SLOTS:
void _slotDeleteObject(const Gui::ViewProviderDocumentObject&, DocumentItem *deletingDoc);
void slotDeleteObject(const Gui::ViewProviderDocumentObject&);
void slotChangeObject(const Gui::ViewProviderDocumentObject&, const App::Property &prop);
void slotTouchedObject(const App::DocumentObject&);

void changeEvent(QEvent *e);
void setupText();
Expand Down Expand Up @@ -346,6 +347,7 @@ class DocumentItem : public QTreeWidgetItem, public Base::Persistence
Connection connectNewObject;
Connection connectDelObject;
Connection connectChgObject;
Connection connectTouchedObject;
Connection connectEdtObject;
Connection connectResObject;
Connection connectHltObject;
Expand Down

0 comments on commit 78ce18a

Please sign in to comment.