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

Method saveMQTTSettings

src/frontend/datasources/ImportFileWidget.cpp:2996–3038  ·  view source on GitHub ↗

! saves the settings to the MQTTClient \c client. */

Source from the content-addressed store, hash-verified

2994 saves the settings to the MQTTClient \c client.
2995*/
2996void ImportFileWidget::saveMQTTSettings(MQTTClient* client) const {
2997 DEBUG(Q_FUNC_INFO);
2998 auto updateType = static_cast<MQTTClient::UpdateType>(ui.cbUpdateType->currentIndex());
2999 auto readingType = static_cast<MQTTClient::ReadingType>(ui.cbReadingType->currentIndex());
3000
3001 client->setFilter(static_cast<AsciiFilter*>(m_currentFilter.release())); // pass ownership of the filter to MQTTClient
3002
3003 client->setReadingType(readingType);
3004
3005 if (updateType == MQTTClient::UpdateType::TimeInterval)
3006 client->setUpdateInterval(ui.sbUpdateInterval->value());
3007
3008 client->setKeepNValues(ui.sbKeepNValues->value());
3009 client->setUpdateType(updateType);
3010
3011 if (readingType != MQTTClient::ReadingType::TillEnd)
3012 client->setSampleSize(ui.sbSampleSize->value());
3013
3014 client->setMQTTClientHostPort(m_client->hostname(), m_client->port());
3015
3016 KConfig config(m_configPath, KConfig::SimpleConfig);
3017 KConfigGroup group = config.group(ui.cbConnection->currentText());
3018
3019 bool useID = group.readEntry("UseID").toUInt();
3020 bool useAuthentication = group.readEntry("UseAuthentication").toUInt();
3021
3022 client->setMQTTUseAuthentication(useAuthentication);
3023 if (useAuthentication)
3024 client->setMQTTClientAuthentication(m_client->username(), m_client->password());
3025
3026 client->setMQTTUseID(useID);
3027 if (useID)
3028 client->setMQTTClientId(m_client->clientId());
3029
3030 for (int i = 0; i < m_mqttSubscriptions.count(); ++i)
3031 client->addInitialMQTTSubscriptions(m_mqttSubscriptions[i]->topic(), m_mqttSubscriptions[i]->qos());
3032
3033 const bool retain = group.readEntry("Retain").toUInt();
3034 client->setMQTTRetain(retain);
3035
3036 if (m_willSettings.enabled)
3037 client->setWillSettings(m_willSettings);
3038}
3039#endif

Callers 1

importToMQTTMethod · 0.80

Calls 15

setMQTTClientHostPortMethod · 0.80
currentTextMethod · 0.80
setMQTTUseIDMethod · 0.80
setMQTTClientIdMethod · 0.80
setMQTTRetainMethod · 0.80
setWillSettingsMethod · 0.80
currentIndexMethod · 0.45
setFilterMethod · 0.45
setReadingTypeMethod · 0.45

Tested by

no test coverage detected