mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-09 21:24:36 +00:00
[#76 state:fixed] Added combobox painting for the selected item in Directories' State column.
--HG-- extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%40256
This commit is contained in:
parent
d5a60b1580
commit
b487189742
@ -10,7 +10,8 @@
|
|||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from PyQt4.QtCore import QModelIndex, Qt, QRect, QEvent, QPoint, QUrl
|
from PyQt4.QtCore import QModelIndex, Qt, QRect, QEvent, QPoint, QUrl
|
||||||
from PyQt4.QtGui import QComboBox, QStyledItemDelegate, QMouseEvent, QApplication, QBrush
|
from PyQt4.QtGui import (QComboBox, QStyledItemDelegate, QMouseEvent, QApplication, QBrush, QStyle,
|
||||||
|
QStyleOptionComboBox, QStyleOptionViewItemV4)
|
||||||
|
|
||||||
from qtlib.tree_model import TreeNode, TreeModel
|
from qtlib.tree_model import TreeNode, TreeModel
|
||||||
|
|
||||||
@ -23,6 +24,24 @@ class DirectoriesDelegate(QStyledItemDelegate):
|
|||||||
editor.addItems(STATES)
|
editor.addItems(STATES)
|
||||||
return editor
|
return editor
|
||||||
|
|
||||||
|
def paint(self, painter, option, index):
|
||||||
|
self.initStyleOption(option, index)
|
||||||
|
# No idea why, but this cast is required if we want to have access to the V4 valuess
|
||||||
|
option = QStyleOptionViewItemV4(option)
|
||||||
|
if (index.column() == 1) and (option.state & QStyle.State_Selected):
|
||||||
|
cboption = QStyleOptionComboBox()
|
||||||
|
cboption.rect = option.rect
|
||||||
|
# On OS X (with Qt4.6.0), adding State_Enabled to the flags causes the whole drawing to
|
||||||
|
# fail (draw nothing), but it's an OS X only glitch. On Windows, it works alright.
|
||||||
|
cboption.state |= QStyle.State_Enabled
|
||||||
|
QApplication.style().drawComplexControl(QStyle.CC_ComboBox, cboption, painter)
|
||||||
|
painter.setBrush(option.palette.text())
|
||||||
|
rect = QRect(option.rect)
|
||||||
|
rect.setLeft(rect.left()+4)
|
||||||
|
painter.drawText(rect, Qt.AlignLeft, option.text)
|
||||||
|
else:
|
||||||
|
QStyledItemDelegate.paint(self, painter, option, index)
|
||||||
|
|
||||||
def setEditorData(self, editor, index):
|
def setEditorData(self, editor, index):
|
||||||
value = index.model().data(index, Qt.EditRole)
|
value = index.model().data(index, Qt.EditRole)
|
||||||
editor.setCurrentIndex(value);
|
editor.setCurrentIndex(value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user