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

Method testSubscribe

src/frontend/dockwidgets/LiveDataDock.cpp:812–840  ·  view source on GitHub ↗

! * \brief Used for testing the MQTT related features * \param topic */

Source from the content-addressed store, hash-verified

810 * \param topic
811 */
812bool LiveDataDock::testSubscribe(const QString& topic) {
813 QStringList topicList = topic.split(QLatin1Char('/'), Qt::SkipEmptyParts);
814 QTreeWidgetItem* currentItem = nullptr;
815 for (int i = 0; i < m_subscriptionWidget->topicCount(); ++i) {
816 if (m_subscriptionWidget->topLevelTopic(i)->text(0) == topicList[0]) {
817 currentItem = m_subscriptionWidget->topLevelTopic(i);
818 break;
819 }
820 }
821
822 if (currentItem) {
823 for (int i = 1; i < topicList.size(); ++i) {
824 if (topicList[i] == QLatin1Char('#'))
825 break;
826
827 for (int j = 0; j < currentItem->childCount(); ++j) {
828 if (currentItem->child(j)->text(0) == topicList[i]) {
829 currentItem = currentItem->child(j);
830 break;
831 } else if (j == currentItem->childCount() - 1)
832 return false;
833 }
834 }
835 } else
836 return false;
837
838 m_subscriptionWidget->testSubscribe(currentItem);
839 return true;
840}
841
842/*!
843 * \brief Used for testing the MQTT related features

Callers

nothing calls this directly

Calls 7

splitMethod · 0.80
topicCountMethod · 0.80
topLevelTopicMethod · 0.80
textMethod · 0.45
sizeMethod · 0.45
childCountMethod · 0.45
childMethod · 0.45

Tested by

no test coverage detected