9 """ |
9 """ |
10 |
10 |
11 from __future__ import unicode_literals |
11 from __future__ import unicode_literals |
12 |
12 |
13 from PyQt5.QtCore import Qt, QSize, QRect |
13 from PyQt5.QtCore import Qt, QSize, QRect |
14 from PyQt5.QtGui import QFontMetrics, QPalette, QFont, QStyleOptionViewItemV4 |
14 from PyQt5.QtGui import QFontMetrics, QPalette, QFont |
15 from PyQt5.QtWidgets import QStyle, QStyledItemDelegate, QApplication |
15 from PyQt5.QtWidgets import QStyle, QStyledItemDelegate, QApplication, \ |
|
16 QStyleOptionViewItem |
16 |
17 |
17 import UI.PixmapCache |
18 import UI.PixmapCache |
18 import Globals |
19 import Globals |
19 |
20 |
20 |
21 |
57 |
58 |
58 @param painter painter object to paint to (QPainter) |
59 @param painter painter object to paint to (QPainter) |
59 @param option style option used for painting (QStyleOptionViewItem) |
60 @param option style option used for painting (QStyleOptionViewItem) |
60 @param index model index of the item (QModelIndex) |
61 @param index model index of the item (QModelIndex) |
61 """ |
62 """ |
62 opt = QStyleOptionViewItemV4(option) |
63 opt = QStyleOptionViewItem(option) |
63 self.initStyleOption(opt, index) |
64 self.initStyleOption(opt, index) |
64 |
65 |
65 widget = opt.widget |
66 widget = opt.widget |
66 style = widget.style() if widget is not None else QApplication.style() |
67 style = widget.style() if widget is not None else QApplication.style() |
67 height = opt.rect.height() |
68 height = opt.rect.height() |
87 style.drawPrimitive(QStyle.PE_PanelItemViewItem, opt, painter, widget) |
88 style.drawPrimitive(QStyle.PE_PanelItemViewItem, opt, painter, widget) |
88 |
89 |
89 # Draw checkbox |
90 # Draw checkbox |
90 checkBoxYPos = center - \ |
91 checkBoxYPos = center - \ |
91 GreaseMonkeyConfigurationListDelegate.CheckBoxSize // 2 |
92 GreaseMonkeyConfigurationListDelegate.CheckBoxSize // 2 |
92 opt2 = QStyleOptionViewItemV4(opt) |
93 opt2 = QStyleOptionViewItem(opt) |
93 if opt2.checkState == Qt.Checked: |
94 if opt2.checkState == Qt.Checked: |
94 opt2.state |= QStyle.State_On |
95 opt2.state |= QStyle.State_On |
95 else: |
96 else: |
96 opt2.state |= QStyle.State_Off |
97 opt2.state |= QStyle.State_Off |
97 styleCheckBoxRect = style.subElementRect( |
98 styleCheckBoxRect = style.subElementRect( |
161 @param option style option used for painting (QStyleOptionViewItem) |
162 @param option style option used for painting (QStyleOptionViewItem) |
162 @param index model index of the item (QModelIndex) |
163 @param index model index of the item (QModelIndex) |
163 @return size hint (QSize) |
164 @return size hint (QSize) |
164 """ |
165 """ |
165 if not self.__rowHeight: |
166 if not self.__rowHeight: |
166 opt = QStyleOptionViewItemV4(option) |
167 opt = QStyleOptionViewItem(option) |
167 self.initStyleOption(opt, index) |
168 self.initStyleOption(opt, index) |
168 |
169 |
169 widget = opt.widget |
170 widget = opt.widget |
170 style = widget.style() if widget is not None \ |
171 style = widget.style() if widget is not None \ |
171 else QApplication.style() |
172 else QApplication.style() |