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

Method unsubscribeTopic

src/frontend/datasources/ImportFileWidget.cpp:2724–2756  ·  view source on GitHub ↗

! *\brief Unsubscribes from the given topic, and removes any data connected to it * * \param topicName the name of a topic we want to unsubscribe from */

Source from the content-addressed store, hash-verified

2722 * \param topicName the name of a topic we want to unsubscribe from
2723 */
2724void ImportFileWidget::unsubscribeTopic(const QString& topicName, QVector<QTreeWidgetItem*> children) {
2725 if (topicName.isEmpty())
2726 return;
2727
2728 for (int i = 0; i < m_mqttSubscriptions.count(); ++i) {
2729 if (m_mqttSubscriptions[i]->topic().filter() == topicName) {
2730 // explicitly disconnect from the signal, callling QMqttClient::unsubscribe() below is not enough
2731 disconnect(m_mqttSubscriptions.at(i), &QMqttSubscription::messageReceived, this, &ImportFileWidget::mqttSubscriptionMessageReceived);
2732 m_mqttSubscriptions.remove(i);
2733 break;
2734 }
2735 }
2736
2737 m_client->unsubscribe(QMqttTopicFilter(topicName));
2738
2739 QMapIterator<QMqttTopicName, QMqttMessage> j(m_lastMessage);
2740 while (j.hasNext()) {
2741 j.next();
2742 if (MQTTSubscriptionWidget::checkTopicContains(topicName, j.key().name()))
2743 m_lastMessage.remove(j.key());
2744 }
2745
2746 if (m_willSettings.willTopic == topicName) {
2747 if (m_subscriptionWidget->subscriptionCount() > 0)
2748 m_willSettings.willTopic = children[0]->text(0);
2749 else
2750 m_willSettings.willTopic.clear();
2751 }
2752
2753 // signals that there was a change among the subscribed topics
2754 Q_EMIT subscriptionsChanged();
2755 refreshPreview();
2756}
2757
2758/*!
2759 *\brief called when the client receives a message

Callers

nothing calls this directly

Calls 9

nextMethod · 0.80
subscriptionCountMethod · 0.80
isEmptyMethod · 0.45
countMethod · 0.45
filterMethod · 0.45
removeMethod · 0.45
nameMethod · 0.45
textMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected