! \class MQTTTopic \brief Represents a topic of a subscription made in MQTTClient. \ingroup datasources */
| 30 | \ingroup datasources |
| 31 | */ |
| 32 | MQTTTopic::MQTTTopic(const QString& name, MQTTSubscription* subscription, bool loading) |
| 33 | : Spreadsheet(name, loading, AspectType::MQTTTopic) |
| 34 | , m_topicName(name) |
| 35 | , m_MQTTClient(subscription->mqttClient()) |
| 36 | , m_filter(new AsciiFilter) { |
| 37 | // Set topic name as column name |
| 38 | auto properties = m_MQTTClient->filter()->properties(); |
| 39 | if (properties.columnModes.size() != 0) { |
| 40 | properties.columnNames.clear(); |
| 41 | for (int i = 0; i < properties.columnModes.size(); i++) { |
| 42 | if (properties.endColumn > 0 && i >= (properties.endColumn - properties.startColumn + 1)) |
| 43 | break; |
| 44 | properties.columnNames.append(i18n("%1 %2").arg(m_topicName).arg(QString::number(i + 1))); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | m_filter->initialize(properties); |
| 49 | m_filter->setDataSource(this); |
| 50 | |
| 51 | connect(m_MQTTClient, &MQTTClient::readFromTopics, this, &MQTTTopic::read); |
| 52 | qDebug() << "New MqttTopic: " << m_topicName; |
| 53 | initActions(); |
| 54 | } |
| 55 | |
| 56 | MQTTTopic::~MQTTTopic() { |
| 57 | qDebug() << "MqttTopic destructor:" << m_topicName; |
nothing calls this directly
no test coverage detected