//! Registers (or adds if such listener is already registered) a listener
//! that will be called on the event and from the defined sender
+ //! \param theListener the object that will listen (process) the event
+ //! \param theID listen for messages with this ID
+ //! \param theSender listen only for this sender (NULL - listen everybody)
+ //! \param theImmediate for listeners who can not wait (no groupping mechanism is used for it)
EVENTS_EXPORT void registerListener(Events_Listener* theListener, const Events_ID theID,
- void* theSender = 0, bool theImmediate = false);
+ void* theSender = 0, bool theImmediate = false);
//! Remove the listener from internal maps if it was registered there
//! \param theListener a listener
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_ORDER_UPDATED)) {
std::shared_ptr<ModelAPI_OrderUpdatedMessage> aUpdMsg =
std::dynamic_pointer_cast<ModelAPI_OrderUpdatedMessage>(theMessage);
- DocumentPtr aDoc = aUpdMsg->reordered()->document();
- std::string aGroup = aUpdMsg->reordered()->group();
-
- QModelIndex aParent;
- int aStartId = 0;
- if (aDoc == aRootDoc) {
- // Update a group under root
- if (aGroup == myXMLReader->rootType()) // Update objects under root
- aStartId = foldersCount();
- else // Update objects in folder under root
- aParent = createIndex(folderId(aGroup), 0, -1);
+ if (aUpdMsg->reordered().get()) {
+ DocumentPtr aDoc = aUpdMsg->reordered()->document();
+ std::string aGroup = aUpdMsg->reordered()->group();
+
+ QModelIndex aParent;
+ int aStartId = 0;
+ if (aDoc == aRootDoc) {
+ // Update a group under root
+ if (aGroup == myXMLReader->rootType()) // Update objects under root
+ aStartId = foldersCount();
+ else // Update objects in folder under root
+ aParent = createIndex(folderId(aGroup), 0, -1);
+ } else {
+ // Update a sub-document
+ if (aGroup == myXMLReader->subType()) {
+ // Update sub-document root
+ aParent = findDocumentRootIndex(aDoc.get());
+ aStartId = foldersCount(aDoc.get());
+ } else
+ // update folder in sub-document
+ aParent = createIndex(folderId(aGroup, aDoc.get()), 0, aDoc.get());
+ }
+ int aChildNb = rowCount(aParent);
+ rebuildBranch(aStartId, aChildNb - aStartId, aParent);
} else {
- // Update a sub-document
- if (aGroup == myXMLReader->subType()) {
- // Update sub-document root
- aParent = findDocumentRootIndex(aDoc.get());
- aStartId = foldersCount(aDoc.get());
- } else
- // update folder in sub-document
- aParent = createIndex(folderId(aGroup, aDoc.get()), 0, aDoc.get());
+ rebuildDataTree();
}
- int aChildNb = rowCount(aParent);
- rebuildBranch(aStartId, aChildNb - aStartId, aParent);
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_DOCUMENT_CHANGED)) {
DocumentPtr aDoc = ModelAPI_Session::get()->activeDocument();
if (aDoc != aRootDoc) {