Package Camelot :: Package camelot :: Package view :: Package controls :: Package delegates :: Module virtualaddressdelegate |
[frames] | no frames]

# Source Code for Module Camelot.camelot.view.controls.delegates.virtualaddressdelegate

     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

    10 -class VirtualAddressDelegate(CustomDelegate):
    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  # These icons don't exist any more in the new tango icon set

    32  #                elif virtual_address[0] == 'phone':

    33  #                    icon = Icon('tango/16x16/devices/phone.png').getQPixmap()

    34  #                    painter.drawPixmap(icon_rect, icon)

    35                  elif virtual_address[0] == 'fax':
    36                      icon = Icon('tango/16x16/devices/printer.png').getQPixmap()
    37                      painter.drawPixmap(icon_rect, icon)
    38  #                elif virtual_address[0] == 'mobile':

    39  #                    icon = Icon('tango/16x16/devices/mobile.png').getQPixmap()

    40  #                    painter.drawPixmap(icon_rect, icon)

    41  #                elif virtual_address[0] == 'im':

    42  #                    icon = Icon('tango/16x16/places/instant-messaging.png').getQPixmap()

    43  #                    painter.drawPixmap(icon_rect, icon)

    44  #                elif virtual_address[0] == 'pager':

    45  #                    icon = Icon('tango/16x16/devices/pager.png').getQPixmap()

    46  #                    painter.drawPixmap(icon_rect, icon)

    47  #                else:

    48  #                #if virtual_adress[0] == 'telephone':

    49  #                    icon = Icon('tango/16x16/apps/preferences-desktop-sound.png').getQPixmap()

    50  #                    painter.drawPixmap(icon_rect, icon)

    51

    52          painter.restore()
    53