<commit_before>#pragma once

#include <QStyledItemDelegate>
#include <QObject>
#include <QTextEdit>
#include <QStyleOption>
#include <QPainter>
#include <QDebug>
#include "log.h"

class ListboxEditableItem : public QStyledItemDelegate
{
public:
    explicit  ListboxEditableItem(QObject  *parent=0);

    void paint(QPainter *painter,
               const QStyleOptionViewItem &option,
               const QModelIndex &index) const override{


        painter->save();

        //painter->setFont(m_default_font);

        auto value = index.model()->data(index, Qt::DisplayRole).toString();
        QTextDocument doc;
        doc.setHtml(value);
        doc.setDefaultFont(m_default_font);

        //qDebug()<<"font:"<<m_default_font.toString()<<" => "<<doc.defaultFont().toString();
        option.widget->style()->drawControl(QStyle::CE_ItemViewItem, &option, painter);

        painter->translate(option.rect.left(), option.rect.top());

        QRect clip(0, 0, option.rect.width(), option.rect.height());

        doc.drawContents(painter, clip);

        painter->restore();
    }

    QSize sizeHint(const QStyleOptionViewItem &option,
                   const QModelIndex &index) const override{<commit_msg>doc properties.<commit_after>#pragma once

#include <QStyledItemDelegate>
#include <QObject>
#include <QTextEdit>
#include <QStyleOption>
#include <QPainter>
#include <QDebug>
#include "log.h"

class ListboxEditableItem : public QStyledItemDelegate
{
public:
    explicit  ListboxEditableItem(QObject  *parent=0);

    void paint(QPainter *painter,
               const QStyleOptionViewItem &option,
               const QModelIndex &index) const override{


        painter->save();

        //painter->setFont(m_default_font);

        auto value = index.model()->data(index, Qt::DisplayRole).toString();
        QTextDocument doc;
        QPalette::ColorGroup cg = option.state & QStyle::State_Enabled
                                  ? QPalette::Normal : QPalette::Disabled;
        if (cg == QPalette::Normal && !(option.state & QStyle::State_Active)){
            cg = QPalette::Inactive;
        }
        QColor textColor = option.palette.color(cg, QPalette::Text);
        doc.setDefaultStyleSheet(QString("body { color: %1}").arg(textColor.name()));
        doc.setDefaultFont(option.font);


        // This is the actual code for word wrap.
        QTextOption txtOption;
        txtOption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
        doc.setDefaultTextOption(txtOption);
        //doc.setTextWidth(rect.width());
        doc.setHtml(value);
        doc.setDocumentMargin(1);
        doc.setDefaultFont(m_default_font);

        //qDebug()<<"font:"<<m_default_font.toString()<<" => "<<doc.defaultFont().toString();
        option.widget->style()->drawControl(QStyle::CE_ItemViewItem, &option, painter);

        painter->translate(option.rect.left(), option.rect.top());

        QRect clip(0, 0, option.rect.width(), option.rect.height());

        doc.drawContents(painter, clip);

        painter->restore();
    }

    QSize sizeHint(const QStyleOptionViewItem &option,
                   const QModelIndex &index) const override{
{'fraction_non_alphanumeric': 0.1347361809045226, 'fraction_numerical': 0.002512562814070352, 'mean_word_length': 3.141742522756827, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4853845', 'n_tokens_mistral': 972, 'n_tokens_neox': 937, 'n_words': 173}