<commit_before>'''
Created on 24.05.2012

@author: michi
'''

from PyQt4.QtCore import QSize, Qt
from PyQt4.QtGui import QStyledItemDelegate, QApplication, QStyle, \
    QStyleOptionButton, QIcon
from ems.qt4.util import variant_to_pyobject
from ems.qt4.itemmodel.addrow_proxymodel import AddRowProxyModel #@UnresolvedImport

class AddRowDelegate(QStyledItemDelegate):
    
    def __init__(self, parent=None):
        QStyledItemDelegate.__init__(self, parent)
        self.addIcon = None
        self.removeIcon = None
        self.addText = None
        self.removeText = None
        
    def paint(self, painter, option, index):
        options = QStyleOptionButton()
        options.rect = option.rect
        options.state = QStyle.State_Enabled
        if self.addIcon and self.removeIcon:
            action = variant_to_pyobject(index.data(Qt.UserRole))
            if action == AddRowProxyModel.ADD:
                options.icon = self.addIcon
            if action == AddRowProxyModel.REMOVE:
                options.icon = self.removeIcon
            options.text = ""
            options.features = QStyleOptionButton.DefaultButton
        if self.addText is not None and self.removeText is not None:
            if action == AddRowProxyModel.ADD:
                options.text = self.addText
            if action == AddRowProxyModel.REMOVE:
                options.text = self.removeText 
        
        QApplication.style().drawControl(QStyle.CE_PushButton, options, painter)
        QApplication.style().drawItemPixmap(painter, options.rect,
                                            Qt.AlignCenter | Qt.AlignVCenter,
                                            options.icon.pixmap(48,48))
    
    def sizeHint_(self, option, index):
#        options = QStyleOptionViewItemV4(option)
#        self.initStyleOption(options, index)
        return QSize(50, 50)<commit_msg>* Nur CE_PushButtonBevel zeichnen und das Pixmap manuell drüber weil das unter Windows mit Icon nicht funktioniert<commit_after>'''
Created on 24.05.2012

@author: michi
'''

from PyQt4.QtCore import QSize, Qt
from PyQt4.QtGui import QStyledItemDelegate, QApplication, QStyle, \
    QStyleOptionButton, QIcon
from ems.qt4.util import variant_to_pyobject
from ems.qt4.itemmodel.addrow_proxymodel import AddRowProxyModel #@UnresolvedImport

class AddRowDelegate(QStyledItemDelegate):
    
    def __init__(self, parent=None):
        QStyledItemDelegate.__init__(self, parent)
        self.addIcon = None
        self.removeIcon = None
        self.addText = None
        self.removeText = None
        
    def paint(self, painter, option, index):
        options = QStyleOptionButton()
        options.rect = option.rect
        options.state = QStyle.State_Enabled
        if self.addIcon and self.removeIcon:
            action = variant_to_pyobject(index.data(Qt.UserRole))
            if action == AddRowProxyModel.ADD:
                options.icon = self.addIcon
            if action == AddRowProxyModel.REMOVE:
                options.icon = self.removeIcon
            options.text = ""
            options.features = QStyleOptionButton.DefaultButton
        if self.addText is not None and self.removeText is not None:
            if action == AddRowProxyModel.ADD:
                options.text = self.addText
            if action == AddRowProxyModel.REMOVE:
                options.text = self.removeText 
        
        QApplication.style().drawControl(QStyle.CE_PushButtonBevel, options, painter)
        QApplication.style().drawItemPixmap(painter, options.rect,
                                            Qt.AlignCenter | Qt.AlignVCenter,
                                            options.icon.pixmap(48,48))
    
    def sizeHint_(self, option, index):
#        options = QStyleOptionViewItemV4(option)
#        self.initStyleOption(options, index)
        return QSize(50, 50)
{'fraction_non_alphanumeric': 0.07994858611825192, 'fraction_numerical': 0.010796915167095116, 'mean_word_length': 2.2560669456066944, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3385709', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1060, 'n_words': 239}