void makeSnapshot() { using namespace Command; if(m_parentSM.editionSettings().sequence()) return; if(this->createdStates.empty()) return; if(!this->createdConstraints.empty()) { const auto& cst = m_parentSM.model().constraints.at(this->createdConstraints.last()); if(!cst.processes.empty()) { // In case of the presence of a sequence, we // only use the sequence's namespace, hence we don't need to make a snapshot at the end.. return; } } auto& device_explorer = this->m_parentSM.context().context.template plugin<Explorer::DeviceDocumentPlugin>().explorer; State::MessageList messages = getSelectionSnapshot(device_explorer); if(messages.empty()) return; m_dispatcher.submitCommand(new AddMessagesToState{ m_parentSM.model().states.at(this->createdStates.last()).messages(), messages}); }
//method called when a drag is initiated QMimeData* DeviceExplorerModel::mimeData(const QModelIndexList& indexes) const { QMimeData* mimeData = new QMimeData; auto uniqueNodes = uniqueSelectedNodes(indexes); // Now we request an update to the device explorer. m_devicePlugin.updateProxy.refreshRemoteValues(uniqueNodes.parents); // The "MessagesList" part. State::MessageList messages; for(const auto& node : uniqueNodes.parents) { Device::parametersList(*node, messages); } for(const auto& node : uniqueNodes.messages) { messages += Device::message(*node); } if(!messages.empty()) { Mime<State::MessageList>::Serializer s{*mimeData}; s.serialize(messages); } // The "Nodes" part. // TODO The mime data should also transmit the root address for // each node in this case. For now it's useless. { Mime<Device::NodeList>::Serializer s{*mimeData}; s.serialize(uniqueNodes.parents + uniqueNodes.messages); } if(messages.empty() && uniqueNodes.parents.empty() && uniqueNodes.messages.empty()) { delete mimeData; return nullptr; } return mimeData; }