339 @type str |
339 @type str |
340 """ |
340 """ |
341 self.subscribeButton.setEnabled(bool(topic)) |
341 self.subscribeButton.setEnabled(bool(topic)) |
342 |
342 |
343 @pyqtSlot() |
343 @pyqtSlot() |
|
344 def on_subscribeTopicEdit_returnPressed(self): |
|
345 """ |
|
346 Private slot handling the user pressing the return button to subscribe |
|
347 a topic. |
|
348 """ |
|
349 self.on_subscribeButton_clicked() |
|
350 |
|
351 @pyqtSlot() |
344 def on_subscribeButton_clicked(self): |
352 def on_subscribeButton_clicked(self): |
345 """ |
353 """ |
346 Private slot to subscribe to the entered topic. |
354 Private slot to subscribe to the entered topic. |
347 """ |
355 """ |
348 topic = self.subscribeTopicEdit.text() |
356 topic = self.subscribeTopicEdit.text() |
404 |
412 |
405 msgInfo = self.__client.publish(topic, payloadStr, qos, retain) |
413 msgInfo = self.__client.publish(topic, payloadStr, qos, retain) |
406 if msgInfo.rc == 0: |
414 if msgInfo.rc == 0: |
407 if topic not in self.__publishedTopics: |
415 if topic not in self.__publishedTopics: |
408 self.__publishedTopics.append(topic) |
416 self.__publishedTopics.append(topic) |
409 self.__updatePublishTopicComboBox() |
417 self.__updatePublishTopicComboBox(resetTopic=False) |
|
418 if self.clearPublishCheckBox.isChecked(): |
|
419 self.on_publishClearButton_clicked() |
410 |
420 |
411 @pyqtSlot() |
421 @pyqtSlot() |
412 def on_publishClearButton_clicked(self): |
422 def on_publishClearButton_clicked(self): |
413 """ |
423 """ |
414 Private slot to clear the publish data fields. |
424 Private slot to clear the publish data fields. |
511 """ |
521 """ |
512 self.unsubscribeTopicComboBox.clear() |
522 self.unsubscribeTopicComboBox.clear() |
513 self.unsubscribeTopicComboBox.addItems(sorted(self.__subscribedTopics)) |
523 self.unsubscribeTopicComboBox.addItems(sorted(self.__subscribedTopics)) |
514 self.unsubscribeButton.setEnabled(len(self.__subscribedTopics) > 0) |
524 self.unsubscribeButton.setEnabled(len(self.__subscribedTopics) > 0) |
515 |
525 |
516 def __updatePublishTopicComboBox(self): |
526 def __updatePublishTopicComboBox(self, resetTopic=True): |
517 """ |
527 """ |
518 Private method to update the publish topic combo box. |
528 Private method to update the publish topic combo box. |
519 """ |
529 |
|
530 @param resetTopic flag indicating to reset the topic |
|
531 @type bool |
|
532 """ |
|
533 currentTopic = self.publishTopicComboBox.currentText() |
520 self.publishTopicComboBox.clear() |
534 self.publishTopicComboBox.clear() |
521 self.publishTopicComboBox.addItems( |
535 self.publishTopicComboBox.addItems( |
522 [""] + list(set(self.__publishedTopics + self.__subscribedTopics))) |
536 list(set(self.__publishedTopics + self.__subscribedTopics))) |
|
537 if resetTopic: |
|
538 self.publishTopicComboBox.clearEditText() |
|
539 else: |
|
540 topicIndex = self.publishTopicComboBox.findText(currentTopic) |
|
541 self.publishTopicComboBox.setCurrentIndex(topicIndex) |
523 |
542 |
524 def __appendMessage(self, topic, payload): |
543 def __appendMessage(self, topic, payload): |
525 """ |
544 """ |
526 Private method to append a received message to the output. |
545 Private method to append a received message to the output. |
527 |
546 |