summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLorenz Haas <lorenz.haas@histomatics.de>2017-11-13 22:26:25 +0100
committerMaurice Kalinowski <maurice.kalinowski@qt.io>2017-11-15 13:18:31 +0000
commit6eca6f914d3f7704e7bd38f3b48f4c7a3f817625 (patch)
tree7a0a6a973e1b511bad406114ad1ce67c0f21f521 /examples
parentb9369efc1ea0fdba5a92ef70ec24b9f3c6edc3cd (diff)
Introduce specific types for topic names and filters
For "topics" the standard defines topic names and topic filters with specific characteristics. QMqttTopicName and QMqttTopicFilter implement this requirements. [ChangeLog][General] Added QMqttTopicName and QMqttTopicFilter Change-Id: Ie2b6851ec9249f20d05c4b8df3c2f27afc2be4b9 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/mqtt/quicksubscription/qmlmqttclient.h4
-rw-r--r--examples/mqtt/simpleclient/mainwindow.cpp4
-rw-r--r--examples/mqtt/subscriptions/mainwindow.cpp6
-rw-r--r--examples/mqtt/subscriptions/subscriptionwindow.cpp2
4 files changed, 8 insertions, 8 deletions
diff --git a/examples/mqtt/quicksubscription/qmlmqttclient.h b/examples/mqtt/quicksubscription/qmlmqttclient.h
index ffc45ea..2e1041b 100644
--- a/examples/mqtt/quicksubscription/qmlmqttclient.h
+++ b/examples/mqtt/quicksubscription/qmlmqttclient.h
@@ -60,7 +60,7 @@ class QmlMqttClient;
class QmlMqttSubscription : public QObject
{
Q_OBJECT
- Q_PROPERTY(QString topic MEMBER m_topic NOTIFY topicChanged)
+ Q_PROPERTY(QMqttTopicFilter topic MEMBER m_topic NOTIFY topicChanged)
public:
QmlMqttSubscription(QMqttSubscription *s, QmlMqttClient *c);
~QmlMqttSubscription();
@@ -76,7 +76,7 @@ private:
Q_DISABLE_COPY(QmlMqttSubscription)
QMqttSubscription *sub;
QmlMqttClient *client;
- QString m_topic;
+ QMqttTopicFilter m_topic;
};
class QmlMqttClient : public QMqttClient
diff --git a/examples/mqtt/simpleclient/mainwindow.cpp b/examples/mqtt/simpleclient/mainwindow.cpp
index 4f5e575..e40820b 100644
--- a/examples/mqtt/simpleclient/mainwindow.cpp
+++ b/examples/mqtt/simpleclient/mainwindow.cpp
@@ -68,10 +68,10 @@ MainWindow::MainWindow(QWidget *parent) :
connect(m_client, &QMqttClient::stateChanged, this, &MainWindow::updateLogStateChange);
connect(m_client, &QMqttClient::disconnected, this, &MainWindow::brokerDisconnected);
- connect(m_client, &QMqttClient::messageReceived, this, [this](const QByteArray &message, const QString &topic) {
+ connect(m_client, &QMqttClient::messageReceived, this, [this](const QByteArray &message, const QMqttTopicName &topic) {
const QString content = QDateTime::currentDateTime().toString()
+ QLatin1String(" Received Topic: ")
- + topic
+ + topic.name()
+ QLatin1String(" Message: ")
+ message
+ QLatin1Char('\n');
diff --git a/examples/mqtt/subscriptions/mainwindow.cpp b/examples/mqtt/subscriptions/mainwindow.cpp
index 499d46a..e8fea99 100644
--- a/examples/mqtt/subscriptions/mainwindow.cpp
+++ b/examples/mqtt/subscriptions/mainwindow.cpp
@@ -69,10 +69,10 @@ MainWindow::MainWindow(QWidget *parent) :
connect(m_client, &QMqttClient::stateChanged, this, &MainWindow::updateLogStateChange);
connect(m_client, &QMqttClient::disconnected, this, &MainWindow::brokerDisconnected);
- connect(m_client, &QMqttClient::messageReceived, this, [this](const QByteArray &message, const QString &topic) {
+ connect(m_client, &QMqttClient::messageReceived, this, [this](const QByteArray &message, const QMqttTopicName &topic) {
const QString content = QDateTime::currentDateTime().toString()
+ QLatin1String(" Received Topic: ")
- + topic
+ + topic.name()
+ QLatin1String(" Message: ")
+ message
+ QLatin1Char('\n');
@@ -156,7 +156,7 @@ void MainWindow::on_buttonSubscribe_clicked()
return;
}
auto subWindow = new SubscriptionWindow(subscription);
- subWindow->setWindowTitle(subscription->topic());
+ subWindow->setWindowTitle(subscription->topic().filter());
subWindow->show();
}
diff --git a/examples/mqtt/subscriptions/subscriptionwindow.cpp b/examples/mqtt/subscriptions/subscriptionwindow.cpp
index 0b6e0ba..5a87a51 100644
--- a/examples/mqtt/subscriptions/subscriptionwindow.cpp
+++ b/examples/mqtt/subscriptions/subscriptionwindow.cpp
@@ -58,7 +58,7 @@ SubscriptionWindow::SubscriptionWindow(QMqttSubscription *sub, QWidget *parent)
{
ui->setupUi(this);
- ui->labelSub->setText(m_sub->topic());
+ ui->labelSub->setText(m_sub->topic().filter());
ui->labelQoS->setText(QString::number(m_sub->qos()));
updateStatus(m_sub->state());
connect(m_sub, &QMqttSubscription::messageReceived, this, &SubscriptionWindow::updateMessage);