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

Method updateSubscriptionTree

src/frontend/datasources/MQTTSubscriptionWidget.cpp:371–409  ·  view source on GitHub ↗

! *\brief Fills twSubscriptions with the subscriptions made by the client */

Source from the content-addressed store, hash-verified

369 *\brief Fills twSubscriptions with the subscriptions made by the client
370 */
371void MQTTSubscriptionWidget::updateSubscriptionTree(const QVector<QString>& mqttSubscriptions) {
372 DEBUG("ImportFileWidget::updateSubscriptionTree()");
373 ui.twSubscriptions->clear();
374
375 for (const auto& sub : mqttSubscriptions) {
376 QStringList name;
377 name.append(sub);
378
379 bool found = false;
380 for (int j = 0; j < ui.twSubscriptions->topLevelItemCount(); ++j) {
381 if (ui.twSubscriptions->topLevelItem(j)->text(0) == sub) {
382 found = true;
383 break;
384 }
385 }
386
387 if (!found) {
388 // Add the subscription to the tree widget
389 auto* newItem = new QTreeWidgetItem(name);
390 ui.twSubscriptions->addTopLevelItem(newItem);
391 name.clear();
392 name = sub.split(QLatin1Char('/'), Qt::SkipEmptyParts);
393
394 // find the corresponding "root" item in twTopics
395 QTreeWidgetItem* topic = nullptr;
396 for (int j = 0; j < ui.twTopics->topLevelItemCount(); ++j) {
397 if (ui.twTopics->topLevelItem(j)->text(0) == name[0]) {
398 topic = ui.twTopics->topLevelItem(j);
399 break;
400 }
401 }
402
403 // restore the children of the subscription
404 if (topic != nullptr && topic->childCount() > 0)
405 restoreSubscriptionChildren(topic, newItem, name, 1);
406 }
407 }
408 m_searching = false;
409}
410
411/*!
412 *\brief Adds to a # wildcard containing topic, every topic present in twTopics that the former topic contains

Callers

nothing calls this directly

Calls 5

appendMethod · 0.80
splitMethod · 0.80
clearMethod · 0.45
textMethod · 0.45
childCountMethod · 0.45

Tested by

no test coverage detected