--- a/MqttMonitor/MqttConnectionProfilesDialog.py Mon Sep 03 19:57:59 2018 +0200 +++ b/MqttMonitor/MqttConnectionProfilesDialog.py Tue Sep 04 19:42:24 2018 +0200 @@ -9,6 +9,8 @@ from __future__ import unicode_literals +import collections + from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QDialog, QAbstractButton, QListWidgetItem @@ -19,15 +21,26 @@ """ Class implementing a dialog to edit the MQTT connection profiles. """ - def __init__(self, parent=None): + def __init__(self, client, profiles, parent=None): """ Constructor + @param client reference to the MQTT client object + @type MqttClient + @param profiles dictionary containing dictionaries containing the + connection parameters. Each entry must have the keys + "BrokerAddress", "BrokerPort", "ClientId", + "Keepalive", "CleanSession", "Username", "Password", "WillTopic", + "WillMessage", "WillQos", "WillRetain". + @type dict @param parent reference to the parent widget @type QWidget """ super(MqttConnectionProfilesDialog, self).__init__(parent) self.setupUi(self) + + self.__profiles = collections.defaultdict(self.__defaultProfile) + self.__profiles.update(profiles) @pyqtSlot(str) def on_profileEdit_textChanged(self, p0): @@ -79,3 +92,25 @@ """ # TODO: not implemented yet raise NotImplementedError + + def getProfiles(self): + """ + Public method to return a dictionary of profiles. + + @return dictionary containing the defined connection profiles + @rtype dict + """ + return {} + + def __defaultProfile(self): + """ + Private method to populate non-existing profile items. + + @return default dictionary entry + @rtype dict + """ + defaultProfile = self.__client.defaultConnectionOptions() + defaultProfile["BrokerAddress"] = "" + defaultProfile["BrokerPort"] = 1883 + + return defaultProfile