MqttMonitor/MqttConnectionProfilesDialog.py

branch
connection_profiles
changeset 18
bbfe5866b6aa
parent 17
ee738a0efe9c
child 19
889a7c3c0e63
equal deleted inserted replaced
17:ee738a0efe9c 18:bbfe5866b6aa
7 Module implementing a dialog to edit the MQTT connection profiles. 7 Module implementing a dialog to edit the MQTT connection profiles.
8 """ 8 """
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 import collections
13
12 from PyQt5.QtCore import pyqtSlot 14 from PyQt5.QtCore import pyqtSlot
13 from PyQt5.QtWidgets import QDialog, QAbstractButton, QListWidgetItem 15 from PyQt5.QtWidgets import QDialog, QAbstractButton, QListWidgetItem
14 16
15 from .Ui_MqttConnectionProfilesDialog import Ui_MqttConnectionProfilesDialog 17 from .Ui_MqttConnectionProfilesDialog import Ui_MqttConnectionProfilesDialog
16 18
17 19
18 class MqttConnectionProfilesDialog(QDialog, Ui_MqttConnectionProfilesDialog): 20 class MqttConnectionProfilesDialog(QDialog, Ui_MqttConnectionProfilesDialog):
19 """ 21 """
20 Class implementing a dialog to edit the MQTT connection profiles. 22 Class implementing a dialog to edit the MQTT connection profiles.
21 """ 23 """
22 def __init__(self, parent=None): 24 def __init__(self, client, profiles, parent=None):
23 """ 25 """
24 Constructor 26 Constructor
25 27
28 @param client reference to the MQTT client object
29 @type MqttClient
30 @param profiles dictionary containing dictionaries containing the
31 connection parameters. Each entry must have the keys
32 "BrokerAddress", "BrokerPort", "ClientId",
33 "Keepalive", "CleanSession", "Username", "Password", "WillTopic",
34 "WillMessage", "WillQos", "WillRetain".
35 @type dict
26 @param parent reference to the parent widget 36 @param parent reference to the parent widget
27 @type QWidget 37 @type QWidget
28 """ 38 """
29 super(MqttConnectionProfilesDialog, self).__init__(parent) 39 super(MqttConnectionProfilesDialog, self).__init__(parent)
30 self.setupUi(self) 40 self.setupUi(self)
41
42 self.__profiles = collections.defaultdict(self.__defaultProfile)
43 self.__profiles.update(profiles)
31 44
32 @pyqtSlot(str) 45 @pyqtSlot(str)
33 def on_profileEdit_textChanged(self, p0): 46 def on_profileEdit_textChanged(self, p0):
34 """ 47 """
35 Slot documentation goes here. 48 Slot documentation goes here.
77 """ 90 """
78 Slot documentation goes here. 91 Slot documentation goes here.
79 """ 92 """
80 # TODO: not implemented yet 93 # TODO: not implemented yet
81 raise NotImplementedError 94 raise NotImplementedError
95
96 def getProfiles(self):
97 """
98 Public method to return a dictionary of profiles.
99
100 @return dictionary containing the defined connection profiles
101 @rtype dict
102 """
103 return {}
104
105 def __defaultProfile(self):
106 """
107 Private method to populate non-existing profile items.
108
109 @return default dictionary entry
110 @rtype dict
111 """
112 defaultProfile = self.__client.defaultConnectionOptions()
113 defaultProfile["BrokerAddress"] = ""
114 defaultProfile["BrokerPort"] = 1883
115
116 return defaultProfile

eric ide

mercurial