1 from PyQt4 import QtGui, QtCore
2 from PyQt4.QtCore import Qt
3
4 from customdelegate import CustomDelegate, DocumentationMetaclass
5 from camelot.view.controls import editors
6 from camelot.view.proxy import ValueLoading
7 from camelot.view.art import Icon
8 from camelot.core.utils import variant_to_pyobject
9
11 """
12 """
13
14 __metaclass__ = DocumentationMetaclass
15
16 editor = editors.VirtualAddressEditor
17
18 - def paint(self, painter, option, index):
19 painter.save()
20 self.drawBackground(painter, option, index)
21 virtual_address = variant_to_pyobject(index.model().data(index, Qt.EditRole))
22
23 if virtual_address and virtual_address!=ValueLoading:
24 self.paint_text(painter, option, index, unicode(virtual_address[1] or ''), margin_left=0, margin_right=18)
25 if virtual_address[1]:
26 x, y, w, h = option.rect.getRect()
27 icon_rect = QtCore.QRect(x + w - 18, y + (h-16)/2, 16, 16)
28 if virtual_address[0] == 'email':
29 icon = Icon('tango/16x16/apps/internet-mail.png').getQPixmap()
30 painter.drawPixmap(icon_rect, icon)
31
32
33
34
35 elif virtual_address[0] == 'fax':
36 icon = Icon('tango/16x16/devices/printer.png').getQPixmap()
37 painter.drawPixmap(icon_rect, icon)
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 painter.restore()
53