diff --git a/src/kdefrontend/datasources/MQTTSubscriptionWidget.h b/src/kdefrontend/datasources/MQTTSubscriptionWidget.h index eb3d33772..7973b5794 100644 --- a/src/kdefrontend/datasources/MQTTSubscriptionWidget.h +++ b/src/kdefrontend/datasources/MQTTSubscriptionWidget.h @@ -1,77 +1,104 @@ +/*************************************************************************** +File : MQTTSubscriptionWidget.h +Project : LabPlot +Description : manage topics and subscribing +-------------------------------------------------------------------- +Copyright : (C) 2019 by Kovacs Ferencz (kferike98@gmail.com) +***************************************************************************/ + +/*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program; if not, write to the Free Software * +* Foundation, Inc., 51 Franklin Street, Fifth Floor, * +* Boston, MA 02110-1301 USA * +* * +***************************************************************************/ + #ifndef MQTTSUBSCRIPTIONWIDGET_H #define MQTTSUBSCRIPTIONWIDGET_H #include #include #ifdef HAVE_MQTT #include "ui_mqttsubscriptionwidget.h" class QMqttSubscription; #endif class MQTTSubscriptionWidget : public QWidget { #ifdef HAVE_MQTT Q_OBJECT public: explicit MQTTSubscriptionWidget(QWidget* parent = nullptr); ~MQTTSubscriptionWidget() override; enum MQTTParentWidget { ImportFileWidget = 0, LiveDataDock = 1 }; void setTopicList (QStringList topicList); QStringList getTopicList();\ int subscriptionCount(); QTreeWidgetItem* topLevelTopic(int); QTreeWidgetItem* topLevelSubscription(int); void addTopic(QTreeWidgetItem*); int topicCount(); void setTopicTreeText(const QString&); void makeVisible(bool); void testSubscribe(QTreeWidgetItem*); void testUnsubscribe(QTreeWidgetItem*); signals: void makeSubscription(const QString& name, quint8 QoS); void MQTTUnsubscribeFromTopic(const QString&, QVector children); void removeMQTTSubscription(const QString&); void addBeforeRemoveSubscription(const QString&, quint8); void reparentTopic(const QString& topic, const QString& parent); void enableWill(bool); private: Ui::MQTTSubscriptionWidget ui; MQTTParentWidget m_parent; QWidget* m_parentWidget; QCompleter* m_subscriptionCompleter{nullptr}; QCompleter* m_topicCompleter{nullptr}; QStringList m_topicList; bool m_searching{false}; QTimer* m_searchTimer; void unsubscribeFromTopic(const QString&); void manageCommonLevelSubscriptions(); void updateSubscriptionCompleter(); private slots: void mqttAvailableTopicDoubleClicked(QTreeWidgetItem* item, int column); void mqttSubscribedTopicDoubleClicked(QTreeWidgetItem* item, int column); void mqttSubscribe(); void mqttUnsubscribe(); void setTopicCompleter(const QString&); void scrollToTopicTreeItem(const QString& rootName); void scrollToSubsriptionTreeItem(const QString& rootName); void topicTimeout(); void updateSubscriptionTree(const QVector&); void clearWidgets(); void onDisconnect(); #endif // HAVE_MQTT }; #endif // MQTTSUBSCRIPTIONWIDGET_H