def data(self, index, role):
        """QAbstractItemModel method implementation
        """
        if role == Qt.DisplayRole and \
           index.row() < len(self.words):
            text = self.words[index.row()]
            typed = text[:len(self._typedText)]
            canComplete = text[len(self._typedText):len(self._typedText) + len(self.canCompleteText)]
            rest = text[len(self._typedText) + len(self.canCompleteText):]
            if canComplete:
                # NOTE foreground colors are hardcoded, but I can't set background color of selected item (Qt bug?)
                # might look bad on some color themes
                return '<html>' \
                            '%s' \
                            '<font color="#e80000">%s</font>' \
                            '%s' \
                        '</html>' % (typed, canComplete, rest)
            else:
                return typed + rest
        else:
            return None
def data ( self , index , role ) : if role == Qt . DisplayRole and index . row ( ) < len ( self . words ) : text = self . words [ index . row ( ) ] typed = text [ : len ( self . _typedText ) ] canComplete = text [ len ( self . _typedText ) : len ( self . _typedText ) + len ( self . canCompleteText ) ] rest = text [ len ( self . _typedText ) + len ( self . canCompleteText ) : ] if canComplete : return '<html>' '%s' '<font color="#e80000">%s</font>' '%s' '</html>' % ( typed , canComplete , rest ) else : return typed + rest else : return None
QAbstractItemModel method implementation