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

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

     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
     7 -class LabelDelegate(CustomDelegate):
     8
     9      __metaclass__ = DocumentationMetaclass
    10
    11      editor = editors.LabelEditor
    12
    13 -    def paint(self, painter, option, index):
    14          painter.save()
    15          self.drawBackground(painter, option, index)
    16          checked = index.model().data(index, Qt.EditRole).toBool()
    17
    18          background_color = QtGui.QColor(index.model().data(index, Qt.BackgroundRole))
    19
    20          if( option.state & QtGui.QStyle.State_Selected ):
    21              painter.fillRect(option.rect, option.palette.highlight())
    22          elif not self.editable:
    23              painter.fillRect(option.rect, option.palette.window())
    24          else:
    25              painter.fillRect(option.rect, background_color)
    26
    27
    28          QtGui.QApplication.style().drawControl(QtGui.QStyle.CE_CheckBox,
    29                                                 checked,
    30                                                 painter)
    31          painter.restore()
    32