92 opt2.state |= QStyle.State_On |
92 opt2.state |= QStyle.State_On |
93 else: |
93 else: |
94 opt2.state |= QStyle.State_Off |
94 opt2.state |= QStyle.State_Off |
95 styleCheckBoxRect = style.subElementRect( |
95 styleCheckBoxRect = style.subElementRect( |
96 QStyle.SE_ViewItemCheckIndicator, opt2, widget) |
96 QStyle.SE_ViewItemCheckIndicator, opt2, widget) |
97 opt2.rect = QRect(leftPos, checkBoxYPos, |
97 opt2.rect = QRect( |
|
98 leftPos, checkBoxYPos, |
98 styleCheckBoxRect.width(), styleCheckBoxRect.height()) |
99 styleCheckBoxRect.width(), styleCheckBoxRect.height()) |
99 style.drawPrimitive(QStyle.PE_IndicatorViewItemCheck, opt2, painter, |
100 style.drawPrimitive(QStyle.PE_IndicatorViewItemCheck, opt2, painter, |
100 widget) |
101 widget) |
101 leftPos = opt2.rect.right() + self.__padding |
102 leftPos = opt2.rect.right() + self.__padding |
102 |
103 |
103 # Draw icon |
104 # Draw icon |
104 iconYPos = center - GreaseMonkeyConfigurationListDelegate.IconSize // 2 |
105 iconYPos = center - GreaseMonkeyConfigurationListDelegate.IconSize // 2 |
105 iconRect = QRect(leftPos, iconYPos, |
106 iconRect = QRect(leftPos, iconYPos, |
106 GreaseMonkeyConfigurationListDelegate.IconSize, |
107 GreaseMonkeyConfigurationListDelegate.IconSize, |
107 GreaseMonkeyConfigurationListDelegate.IconSize) |
108 GreaseMonkeyConfigurationListDelegate.IconSize) |
108 pixmap = index.data(Qt.DecorationRole).pixmap( |
109 pixmap = index.data(Qt.DecorationRole).pixmap( |
109 GreaseMonkeyConfigurationListDelegate.IconSize) |
110 GreaseMonkeyConfigurationListDelegate.IconSize) |
110 painter.drawPixmap(iconRect, pixmap) |
111 painter.drawPixmap(iconRect, pixmap) |
111 leftPos = iconRect.right() + self.__padding |
112 leftPos = iconRect.right() + self.__padding |
112 |
113 |
114 name = index.data(Qt.DisplayRole) |
115 name = index.data(Qt.DisplayRole) |
115 leftTitleEdge = leftPos + 2 |
116 leftTitleEdge = leftPos + 2 |
116 rightTitleEdge = rightPos - self.__padding |
117 rightTitleEdge = rightPos - self.__padding |
117 leftPosForVersion = titleMetrics.width(name) + self.__padding |
118 leftPosForVersion = titleMetrics.width(name) + self.__padding |
118 nameRect = QRect(leftTitleEdge, opt.rect.top() + self.__padding, |
119 nameRect = QRect(leftTitleEdge, opt.rect.top() + self.__padding, |
119 rightTitleEdge - leftTitleEdge, titleMetrics.height()) |
120 rightTitleEdge - leftTitleEdge, titleMetrics.height()) |
120 painter.setFont(titleFont) |
121 painter.setFont(titleFont) |
121 style.drawItemText(painter, nameRect, Qt.AlignLeft, opt.palette, True, |
122 style.drawItemText(painter, nameRect, Qt.AlignLeft, opt.palette, True, |
122 name, colorRole) |
123 name, colorRole) |
123 |
124 |
124 # Draw version |
125 # Draw version |
125 version = index.data(Qt.UserRole) |
126 version = index.data(Qt.UserRole) |
126 versionRect = QRect(nameRect.x() + leftPosForVersion, nameRect.y(), |
127 versionRect = QRect( |
|
128 nameRect.x() + leftPosForVersion, nameRect.y(), |
127 rightTitleEdge - leftTitleEdge, titleMetrics.height()) |
129 rightTitleEdge - leftTitleEdge, titleMetrics.height()) |
128 versionFont = titleFont |
130 versionFont = titleFont |
129 painter.setFont(versionFont) |
131 painter.setFont(versionFont) |
130 style.drawItemText(painter, versionRect, Qt.AlignLeft, opt.palette, |
132 style.drawItemText(painter, versionRect, Qt.AlignLeft, opt.palette, |
131 True, version, colorRole) |
133 True, version, colorRole) |
132 |
134 |
133 # Draw description |
135 # Draw description |
134 infoYPos = nameRect.bottom() + opt.fontMetrics.leading() |
136 infoYPos = nameRect.bottom() + opt.fontMetrics.leading() |
135 infoRect = QRect(nameRect.x(), infoYPos, |
137 infoRect = QRect( |
|
138 nameRect.x(), infoYPos, |
136 nameRect.width(), opt.fontMetrics.height()) |
139 nameRect.width(), opt.fontMetrics.height()) |
137 info = opt.fontMetrics.elidedText( |
140 info = opt.fontMetrics.elidedText( |
138 index.data(Qt.UserRole + 1), Qt.ElideRight, infoRect.width()) |
141 index.data(Qt.UserRole + 1), Qt.ElideRight, infoRect.width()) |
139 painter.setFont(opt.font) |
142 painter.setFont(opt.font) |
140 style.drawItemText(painter, infoRect, Qt.AlignLeft | Qt.TextSingleLine, |
143 style.drawItemText(painter, infoRect, Qt.AlignLeft | Qt.TextSingleLine, |
141 opt.palette, True, info, colorRole) |
144 opt.palette, True, info, colorRole) |
142 |
145 |
143 # Draw remove button |
146 # Draw remove button |
144 removeIconYPos = center - \ |
147 removeIconYPos = center - \ |
145 GreaseMonkeyConfigurationListDelegate.RemoveIconSize // 2 |
148 GreaseMonkeyConfigurationListDelegate.RemoveIconSize // 2 |
146 removeIconRect = QRect(rightPos, removeIconYPos, |
149 removeIconRect = QRect( |
|
150 rightPos, removeIconYPos, |
147 GreaseMonkeyConfigurationListDelegate.RemoveIconSize, |
151 GreaseMonkeyConfigurationListDelegate.RemoveIconSize, |
148 GreaseMonkeyConfigurationListDelegate.RemoveIconSize) |
152 GreaseMonkeyConfigurationListDelegate.RemoveIconSize) |
149 painter.drawPixmap(removeIconRect, self.__removePixmap) |
153 painter.drawPixmap(removeIconRect, self.__removePixmap) |
150 |
154 |
151 def sizeHint(self, option, index): |
155 def sizeHint(self, option, index): |