Core: Gui: DAGView: delay retrieval for python features. see following note.

This doesn't work on document restore!
This commit is contained in:
blobfish 2015-08-15 13:07:34 -04:00 committed by wmayer
parent 973dda6f88
commit 86bf399682
2 changed files with 21 additions and 0 deletions

View File

@ -248,6 +248,22 @@ void Model::slotNewObject(const ViewProviderDocumentObject &VPDObjectIn)
(*theGraph)[virginVertex].text->setFont(this->font());
graphDirty = true;
//we are here before python objects are instantiated. so at this point
//the getIcon method doesn't reflect the python override.
//so we hack in a delay to get the latest icon and set it for the graphics item.
lastAddedVertex = virginVertex;
QTimer::singleShot(0, this, SLOT(iconUpdateSlot()));
}
void Model::iconUpdateSlot()
{
if (lastAddedVertex == Graph::null_vertex())
return;
const ViewProviderDocumentObject *VPDObject = findRecord(lastAddedVertex, *graphLink).VPDObject;
(*theGraph)[lastAddedVertex].icon->setPixmap(VPDObject->getIcon().pixmap(iconSize, iconSize));
lastAddedVertex = Graph::null_vertex();
this->invalidate();
}
void Model::slotDeleteObject(const ViewProviderDocumentObject &VPDObjectIn)
@ -265,6 +281,9 @@ void Model::slotDeleteObject(const ViewProviderDocumentObject &VPDObjectIn)
for (auto inEdgeIt = inRange.first; inEdgeIt != inRange.second; ++inEdgeIt)
this->removeItem((*theGraph)[*inEdgeIt].connector.get());
if (vertex == lastAddedVertex)
lastAddedVertex = Graph::null_vertex();
//remove the actual vertex.
boost::clear_vertex(vertex, *theGraph);
boost::remove_vertex(vertex, *theGraph);

View File

@ -81,6 +81,7 @@ namespace Gui
void renameRejectedSlot();
void editingStartSlot();
void editingFinishedSlot();
void iconUpdateSlot(); //!< needed because python objects are not ready.
private:
Model(){}
@ -150,6 +151,7 @@ namespace Gui
QPixmap passPixmap;
QPixmap failPixmap;
QPixmap pendingPixmap;
Vertex lastAddedVertex = Graph::null_vertex(); //!< needed because python objects are not ready.
QAction *renameAction;
QAction *editingFinishedAction;