MqttMonitor/MqttUserPropertiesEditor.py

branch
eric7
changeset 123
3d7e63ed4fd1
parent 114
8c0e9e602124
child 127
8982ef7b7d67
diff -r 28d69b9e1b6a -r 3d7e63ed4fd1 MqttMonitor/MqttUserPropertiesEditor.py
--- a/MqttMonitor/MqttUserPropertiesEditor.py	Thu Dec 30 16:36:40 2021 +0100
+++ b/MqttMonitor/MqttUserPropertiesEditor.py	Wed Sep 21 09:42:33 2022 +0200
@@ -9,7 +9,12 @@
 
 from PyQt6.QtCore import pyqtSlot, Qt
 from PyQt6.QtWidgets import (
-    QDialog, QDialogButtonBox, QTableWidgetItem, QVBoxLayout, QLabel, QWidget
+    QDialog,
+    QDialogButtonBox,
+    QTableWidgetItem,
+    QVBoxLayout,
+    QLabel,
+    QWidget,
 )
 
 from .Ui_MqttUserPropertiesEditor import Ui_MqttUserPropertiesEditor
@@ -21,41 +26,40 @@
     """
     Class implementing an editor for MQTT v5 user properties.
     """
+
     def __init__(self, parent=None):
         """
         Constructor
-        
+
         @param parent reference to the parent widget (defaults to None)
         @type QWidget (optional)
         """
         super().__init__(parent)
         self.setupUi(self)
-        
+
         self.addButton.setIcon(UI.PixmapCache.getIcon("plus"))
         self.deleteButton.setIcon(UI.PixmapCache.getIcon("minus"))
         self.clearButton.setIcon(UI.PixmapCache.getIcon("editDelete"))
-        
+
         self.clearButton.clicked.connect(self.clear)
-        
+
         self.deleteButton.setEnabled(False)
-    
+
     @pyqtSlot()
     def on_propertiesTable_itemSelectionChanged(self):
         """
         Private slot to handle the selection of rows.
         """
-        self.deleteButton.setEnabled(
-            bool(self.propertiesTable.selectedItems()))
-    
+        self.deleteButton.setEnabled(bool(self.propertiesTable.selectedItems()))
+
     @pyqtSlot()
     def on_addButton_clicked(self):
         """
         Private slot to add a row to the table.
         """
         self.propertiesTable.setRowCount(self.propertiesTable.rowCount() + 1)
-        self.propertiesTable.setCurrentCell(
-            self.propertiesTable.rowCount() - 1, 0)
-    
+        self.propertiesTable.setCurrentCell(self.propertiesTable.rowCount() - 1, 0)
+
     @pyqtSlot()
     def on_deleteButton_clicked(self):
         """
@@ -66,7 +70,7 @@
         for bottomRow, topRow in sorted(selectedRows, reverse=True):
             for row in range(bottomRow, topRow - 1, -1):
                 self.propertiesTable.removeRow(row)
-    
+
     @pyqtSlot()
     def clear(self):
         """
@@ -75,11 +79,11 @@
         self.propertiesTable.clearContents()
         self.propertiesTable.setRowCount(10)
         self.propertiesTable.setCurrentCell(0, 0)
-    
+
     def setProperties(self, properties):
         """
         Public method to populate the editor with a list of user properties.
-        
+
         @param properties list of defined user properties
         @type list of tuple of (str, str)
         """
@@ -90,16 +94,16 @@
                 self.propertiesTable.setItem(row, 1, QTableWidgetItem(value))
         else:
             self.clear()
-    
+
     def getProperties(self):
         """
         Public method to get the list of defined user properties.
-        
+
         @return list of defined user properties
         @rtype list of tuple of (str, str)
         """
         properties = []
-        
+
         for row in range(self.propertiesTable.rowCount()):
             keyItem = self.propertiesTable.item(row, 0)
             key = keyItem.text() if keyItem else ""
@@ -107,7 +111,7 @@
                 valueItem = self.propertiesTable.item(row, 1)
                 value = valueItem.text() if valueItem else ""
                 properties.append([key, value])
-        
+
         return properties
 
 
@@ -115,10 +119,11 @@
     """
     Class implementing an editor dialog for MQTT v5 user properties.
     """
+
     def __init__(self, header, properties, parent=None):
         """
         Constructor
-        
+
         @param header text to be shown in the dialog header label
         @type  str
         @param properties list of defined user properties
@@ -127,37 +132,37 @@
         @type QWidget (optional)
         """
         super().__init__(parent)
-        
+
         self.setObjectName("MqttUserPropertiesEditor")
         self.resize(400, 300)
         self.setSizeGripEnabled(True)
         self.setWindowTitle(self.tr("User Properties"))
-        
+
         self.__layout = QVBoxLayout(self)
-        
+
         self.__headerLabel = QLabel(header, self)
         self.__layout.addWidget(self.__headerLabel)
-        
+
         self.__propertiesEditor = MqttUserPropertiesEditor(self)
         self.__layout.addWidget(self.__propertiesEditor)
-        
+
         self.__buttonBox = QDialogButtonBox(self)
         self.__buttonBox.setOrientation(Qt.Orientation.Horizontal)
         self.__buttonBox.setStandardButtons(
-            QDialogButtonBox.StandardButton.Cancel |
-            QDialogButtonBox.StandardButton.Ok)
+            QDialogButtonBox.StandardButton.Cancel | QDialogButtonBox.StandardButton.Ok
+        )
         self.__buttonBox.setObjectName("buttonBox")
         self.__layout.addWidget(self.__buttonBox)
-        
+
         self.__buttonBox.accepted.connect(self.accept)
         self.__buttonBox.rejected.connect(self.reject)
-        
+
         self.__propertiesEditor.setProperties(properties)
-    
+
     def getProperties(self):
         """
         Public method to get the list of defined user properties.
-        
+
         @return list of defined user properties
         @rtype list of tuple of (str, str)
         """

eric ide

mercurial