MCPcopy Create free account
hub / github.com/KDE/labplot / reparentTopic

Method reparentTopic

src/backend/datasources/MQTTClient.cpp:517–545  ·  view source on GitHub ↗

! * \brief Reparents the given MQTTTopic to the given MQTTSubscription * * \param topic, the name of the MQTTTopic * \param parent, the name of the MQTTSubscription */

Source from the content-addressed store, hash-verified

515 * \param parent, the name of the MQTTSubscription
516 */
517void MQTTClient::reparentTopic(const QString& topicName, const QString& parentTopicName) {
518 // We can only reparent if the parent contained the topic
519 if (m_subscriptions.contains(parentTopicName) && m_topicNames.contains(topicName)) {
520 // qDebug() << "Reparent " << topicName << " to " << parentTopicName;
521 // search for the parent MQTTSubscription
522 bool found = false;
523 MQTTSubscription* superiorSubscription = nullptr;
524 for (auto* subscription : m_MQTTSubscriptions) {
525 if (subscription->subscriptionName() == parentTopicName) {
526 found = true;
527 superiorSubscription = subscription;
528 break;
529 }
530 }
531
532 if (found) {
533 // get every topic of the MQTTClient
534 QVector<MQTTTopic*> topics = children<MQTTTopic>(AbstractAspect::ChildIndexFlag::Recursive);
535 // Search for the given topic among the MQTTTopics
536 for (auto* topic : topics) {
537 if (topicName == topic->topicName()) {
538 // if found, it is reparented to the parent MQTTSubscription
539 topic->reparent(superiorSubscription);
540 break;
541 }
542 }
543 }
544 }
545}
546
547/*!
548 *\brief Checks if a topic contains another one

Callers

nothing calls this directly

Calls 4

subscriptionNameMethod · 0.80
topicNameMethod · 0.80
containsMethod · 0.45
reparentMethod · 0.45

Tested by

no test coverage detected