eric6/WebBrowser/GreaseMonkey/GreaseMonkeyConfiguration/GreaseMonkeyConfigurationListDelegate.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
--- a/eric6/WebBrowser/GreaseMonkey/GreaseMonkeyConfiguration/GreaseMonkeyConfigurationListDelegate.py	Mon Mar 01 17:48:43 2021 +0100
+++ b/eric6/WebBrowser/GreaseMonkey/GreaseMonkeyConfiguration/GreaseMonkeyConfigurationListDelegate.py	Tue Mar 02 17:17:09 2021 +0100
@@ -73,11 +73,12 @@
         
         titleMetrics = QFontMetrics(titleFont)
         if Globals.isWindowsPlatform():
-            colorRole = QPalette.Text
+            colorRole = QPalette.ColorRole.Text
         else:
             colorRole = (
-                QPalette.HighlightedText
-                if opt.state & QStyle.State_Selected else QPalette.Text
+                QPalette.ColorRole.HighlightedText
+                if opt.state & QStyle.StateFlag.State_Selected else
+                QPalette.ColorRole.Text
             )
         
         leftPos = self.__padding
@@ -87,7 +88,8 @@
         )
         
         # Draw background
-        style.drawPrimitive(QStyle.PE_PanelItemViewItem, opt, painter, widget)
+        style.drawPrimitive(
+            QStyle.PrimitiveElement.PE_PanelItemViewItem, opt, painter, widget)
         
         # Draw checkbox
         checkBoxYPos = (
@@ -95,17 +97,18 @@
             GreaseMonkeyConfigurationListDelegate.CheckBoxSize // 2
         )
         opt2 = QStyleOptionViewItem(opt)
-        if opt2.checkState == Qt.Checked:
-            opt2.state |= QStyle.State_On
+        if opt2.checkState == Qt.CheckState.Checked:
+            opt2.state |= QStyle.StateFlag.State_On
         else:
-            opt2.state |= QStyle.State_Off
+            opt2.state |= QStyle.StateFlag.State_Off
         styleCheckBoxRect = style.subElementRect(
-            QStyle.SE_ViewItemCheckIndicator, opt2, widget)
+            QStyle.SubElement.SE_ViewItemCheckIndicator, opt2, widget)
         opt2.rect = QRect(
             leftPos, checkBoxYPos,
             styleCheckBoxRect.width(), styleCheckBoxRect.height())
-        style.drawPrimitive(QStyle.PE_IndicatorViewItemCheck, opt2, painter,
-                            widget)
+        style.drawPrimitive(
+            QStyle.PrimitiveElement.PE_IndicatorViewItemCheck, opt2, painter,
+            widget)
         leftPos = opt2.rect.right() + self.__padding
         
         # Draw icon
@@ -113,13 +116,13 @@
         iconRect = QRect(leftPos, iconYPos,
                          GreaseMonkeyConfigurationListDelegate.IconSize,
                          GreaseMonkeyConfigurationListDelegate.IconSize)
-        pixmap = index.data(Qt.DecorationRole).pixmap(
+        pixmap = index.data(Qt.ItemDataRole.DecorationRole).pixmap(
             GreaseMonkeyConfigurationListDelegate.IconSize)
         painter.drawPixmap(iconRect, pixmap)
         leftPos = iconRect.right() + self.__padding
         
         # Draw script name
-        name = index.data(Qt.DisplayRole)
+        name = index.data(Qt.ItemDataRole.DisplayRole)
         leftTitleEdge = leftPos + 2
         rightTitleEdge = rightPos - self.__padding
         try:
@@ -131,18 +134,22 @@
         nameRect = QRect(leftTitleEdge, opt.rect.top() + self.__padding,
                          rightTitleEdge - leftTitleEdge, titleMetrics.height())
         painter.setFont(titleFont)
-        style.drawItemText(painter, nameRect, Qt.AlignLeft, opt.palette, True,
-                           name, colorRole)
+        style.drawItemText(
+            painter, nameRect,
+            Qt.AlignmentFlag.AlignLeft, opt.palette, True,
+            name, colorRole)
         
         # Draw version
-        version = index.data(Qt.UserRole)
+        version = index.data(Qt.ItemDataRole.UserRole)
         versionRect = QRect(
             nameRect.x() + leftPosForVersion, nameRect.y(),
             rightTitleEdge - leftTitleEdge, titleMetrics.height())
         versionFont = titleFont
         painter.setFont(versionFont)
-        style.drawItemText(painter, versionRect, Qt.AlignLeft, opt.palette,
-                           True, version, colorRole)
+        style.drawItemText(
+            painter, versionRect,
+            Qt.AlignmentFlag.AlignLeft, opt.palette,
+            True, version, colorRole)
         
         # Draw description
         infoYPos = nameRect.bottom() + opt.fontMetrics.leading()
@@ -150,10 +157,13 @@
             nameRect.x(), infoYPos,
             nameRect.width(), opt.fontMetrics.height())
         info = opt.fontMetrics.elidedText(
-            index.data(Qt.UserRole + 1), Qt.ElideRight, infoRect.width())
+            index.data(Qt.ItemDataRole.UserRole + 1),
+            Qt.TextElideMode.ElideRight, infoRect.width())
         painter.setFont(opt.font)
-        style.drawItemText(painter, infoRect, Qt.AlignLeft | Qt.TextSingleLine,
-                           opt.palette, True, info, colorRole)
+        style.drawItemText(
+            painter, infoRect,
+            Qt.AlignmentFlag.AlignLeft | Qt.TextFlag.TextSingleLine,
+            opt.palette, True, info, colorRole)
         
         # Draw remove button
         removeIconYPos = (
@@ -183,7 +193,8 @@
                 widget.style() if widget is not None
                 else QApplication.style()
             )
-            padding = style.pixelMetric(QStyle.PM_FocusFrameHMargin) + 1
+            padding = style.pixelMetric(
+                QStyle.PixelMetric.PM_FocusFrameHMargin) + 1
             
             titleFont = opt.font
             titleFont.setBold(True)

eric ide

mercurial