<commit_before>#include "defaultnotefolderdelegateeditor.h"
#include <QPainter>
#include <QDebug>
#include <QTreeView>
#include "nodetreemodel.h"

DefaultNoteFolderDelegateEditor::DefaultNoteFolderDelegateEditor(QTreeView *view, const QStyleOptionViewItem &option,
                                                     const QModelIndex &m_index,
                                                     QWidget *parent) :
    QWidget(parent),
    m_option(option),
    m_index(m_index),
    #ifdef __APPLE__
    m_displayFont(QFont(QStringLiteral("SF Pro Text")).exactMatch() ? QStringLiteral("SF Pro Text") : QStringLiteral("Roboto")),
    #elif _WIN32
    m_displayFont(QFont(QStringLiteral("Segoe UI")).exactMatch() ? QStringLiteral("Segoe UI") : QStringLiteral("Roboto")),
    #else
    m_displayFont(QStringLiteral("Roboto")),
    #endif
    #ifdef __APPLE__
    m_titleFont(m_displayFont, 13, 65),
    #else
    m_titleFont(m_displayFont, 10, 60),
    #endif
    m_titleColor(26, 26, 26),
    m_titleSelectedColor(255, 255, 255),
    m_activeColor(68, 138, 201),
    m_hoverColor(207, 207, 207),
    m_view(view)
{
    setContentsMargins(0, 0, 0, 0);
}


void DefaultNoteFolderDelegateEditor::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    auto iconRect = QRect(rect().x() + 5, rect().y() + (rect().height() - 20) / 2, 20, 20);
    QRect nameRect(rect());
    nameRect.setLeft(iconRect.x() + iconRect.width() + 5);
    nameRect.setWidth(nameRect.width() - 5 - 40);

    auto displayName = m_index.data(NodeItem::Roles::DisplayText).toString();
    QFontMetrics fm(m_titleFont);
    displayName = fm.elidedText(displayName, Qt::ElideRight, nameRect.width());

    if (m_view->selectionModel()->isSelected(m_index)) {
        painter.fillRect(rect(), QBrush(m_activeColor));
        painter.setPen(m_titleSelectedColor);
    } else {
        painter.fillRect(rect(), QBrush(m_hoverColor));
        painter.setPen(m_titleColor);
    }
    painter.setFont(m_titleFont);
    painter.drawText(nameRect, Qt::AlignLeft | Qt::AlignVCenter, displayName);
    auto childCountRect = rect();
    childCountRect.setLeft(nameRect.right() + 5);
    childCountRect.setWidth(childCountRect.width() - 5);
    auto childCount = m_index.data(NodeItem::Roles::ChildCount).toInt();
    if (m_view->selectionModel()->isSelected(m_index)) {
        painter.setPen(m_titleSelectedColor);
    } else {
        painter.setPen(m_titleColor);
    }
    painter.setFont(m_titleFont);
    painter.drawText(childCountRect, Qt::AlignHCenter | Qt::AlignVCenter, QString::number(childCount));
    QWidget::paintEvent(event);
}
<commit_msg>fix node tree deledator painting<commit_after>#include "defaultnotefolderdelegateeditor.h"
#include <QPainter>
#include <QDebug>
#include <QTreeView>
#include "nodetreemodel.h"

DefaultNoteFolderDelegateEditor::DefaultNoteFolderDelegateEditor(QTreeView *view, const QStyleOptionViewItem &option,
                                                     const QModelIndex &m_index,
                                                     QWidget *parent) :
    QWidget(parent),
    m_option(option),
    m_index(m_index),
    #ifdef __APPLE__
    m_displayFont(QFont(QStringLiteral("SF Pro Text")).exactMatch() ? QStringLiteral("SF Pro Text") : QStringLiteral("Roboto")),
    #elif _WIN32
    m_displayFont(QFont(QStringLiteral("Segoe UI")).exactMatch() ? QStringLiteral("Segoe UI") : QStringLiteral("Roboto")),
    #else
    m_displayFont(QStringLiteral("Roboto")),
    #endif
    #ifdef __APPLE__
    m_titleFont(m_displayFont, 13, 65),
    #else
    m_titleFont(m_displayFont, 10, 60),
    #endif
    m_titleColor(26, 26, 26),
    m_titleSelectedColor(255, 255, 255),
    m_activeColor(68, 138, 201),
    m_hoverColor(207, 207, 207),
    m_view(view)
{
    setContentsMargins(0, 0, 0, 0);
}


void DefaultNoteFolderDelegateEditor::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    auto iconRect = QRect(rect().x() + 5, rect().y() + (rect().height() - 20) / 2, 20, 20);
    QRect nameRect(rect());
    nameRect.setLeft(iconRect.x() + iconRect.width());
    nameRect.setWidth(nameRect.width() - 5 - 40);

    auto displayName = m_index.data(NodeItem::Roles::DisplayText).toString();
    QFontMetrics fm(m_titleFont);
    displayName = fm.elidedText(displayName, Qt::ElideRight, nameRect.width());

    if (m_view->selectionModel()->isSelected(m_index)) {
        painter.fillRect(rect(), QBrush(m_activeColor));
        painter.setPen(m_titleSelectedColor);
    } else {
        painter.fillRect(rect(), QBrush(m_hoverColor));
        painter.setPen(m_titleColor);
    }
    painter.setFont(m_titleFont);
    painter.drawText(nameRect, Qt::AlignLeft | Qt::AlignVCenter, displayName);
    auto childCountRect = rect();
    childCountRect.setLeft(nameRect.right() + 5);
    childCountRect.setWidth(childCountRect.width() - 5);
    auto childCount = m_index.data(NodeItem::Roles::ChildCount).toInt();
    if (m_view->selectionModel()->isSelected(m_index)) {
        painter.setPen(m_titleSelectedColor);
    } else {
        painter.setPen(m_titleColor);
    }
    painter.setFont(m_titleFont);
    painter.drawText(childCountRect, Qt::AlignHCenter | Qt::AlignVCenter, QString::number(childCount));
    QWidget::paintEvent(event);
}

{'fraction_non_alphanumeric': 0.13780650066527275, 'fraction_numerical': 0.022619273902299942, 'mean_word_length': 3.8054794520547945, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, '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': '1069313', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1705, 'n_words': 275}