Helpviewer/GreaseMonkey/GreaseMonkeyConfiguration/GreaseMonkeyConfigurationListDelegate.py

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

eric ide

mercurial