-
Notifications
You must be signed in to change notification settings - Fork 28
/
itemCheckbox.py
70 lines (54 loc) · 2.16 KB
/
itemCheckbox.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#-*- coding:utf-8 -*-
'''
Created on 2014��2��21��
@author: huzhicheng
'''
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import settings
class DelegateButton(QStyledItemDelegate):
def paint(self, painter, option, index):
starRating = index.data().toList()
#s = QVariant(["ss","nn"])
print settings.translate(starRating[0].toString())
print starRating
# if isinstance(starRating, StarRating):
# if option.state & QtGui.QStyle.State_Selected:
# painter.fillRect(option.rect, option.palette.highlight())
#
# starRating.paint(painter, option.rect, option.palette,
# StarRating.ReadOnly)
# else:
# super(StarDelegate, self).paint(painter, option, index)
def sizeHint(self, option, index):
starRating = index.data()
# if isinstance(starRating, StarRating):
# return starRating.sizeHint()
# else:
# return super(StarDelegate, self).sizeHint(option, index)
def createEditor(self, parent, option, index):
starRating = index.data()
btn = QPushButton("hhi",parent=parent)
return btn
# if isinstance(starRating, StarRating):
# editor = StarEditor(parent)
# editor.editingFinished.connect(self.commitAndCloseEditor)
# return editor
# else:
# return super(StarDelegate, self).createEditor(parent, option, index)
def setEditorData(self, editor, index):
starRating = index.data()
# if isinstance(starRating, StarRating):
# editor.setStarRating(starRating)
# else:
# super(StarDelegate, self).setEditorData(editor, index)
def setModelData(self, editor, model, index):
starRating = index.data()
# if isinstance(starRating, StarRating):
# model.setData(index, editor.starRating())
# else:
# super(StarDelegate, self).setModelData(editor, model, index)
def commitAndCloseEditor(self):
editor = self.sender()
self.commitData.emit(editor)
self.closeEditor.emit(editor)