<commit_before>/*
    Kopete View Item Delegate

    Copyright (c) 2007 by <NAME> <<EMAIL>>

    Kopete    (c) 2002-2007 by the Kopete developers  <<EMAIL>>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include "kopeteitemdelegate.h"
#include "kopeteitembase.h"

#include <QPainter>
#include <QStyleOptionViewItem>
#include <QModelIndex>
#include <QAbstractItemView>

#include "kopetemetacontact.h"
#include "kopeteappearancesettings.h"

KopeteItemDelegate::KopeteItemDelegate( QAbstractItemView* parent )
: QItemDelegate( parent )
{
}

KopeteItemDelegate::~KopeteItemDelegate()
{
}

QSize KopeteItemDelegate::sizeHint(const QStyleOptionViewItem &option,
                                   const QModelIndex &index) const
{
    QVariant value = index.data(Qt::SizeHintRole);
    if ( value.isValid() )
        return qvariant_cast<QSize>(value);
    return QItemDelegate::sizeHint( option, index );
}

void KopeteItemDelegate::paint( QPainter* painter, 
                                const QStyleOptionViewItem& option,
                                const QModelIndex& index ) const
{
    //pull in contact settings: idleContactColor, greyIdleMetaContacts
    //pull in contact list settings: contactListDisplayMode
    QStyleOptionViewItem opt = option;

    if ( index.data( Kopete::Items::TypeRole ) ==
         Kopete::Items::MetaContact )
    {
        //check the idle state of the metacontact and apply the appropriate
        //color
        QVariant v = index.data( Kopete::Items::IdleTimeRole );
        if ( Kopete::AppearanceSettings::self()->greyIdleMetaContacts() &&
             v.toInt() > 0 )
        {
            opt.palette.setColor( QPalette::Text, Qt::lightGray );
        }
    }

    if (  index.data( Kopete::Items::TypeRole ) ==
          Kopete::Items::Group )
    {
        QColor gc( Kopete::AppearanceSettings::self()->groupNameColor() );
        opt.palette.setColor( QPalette::Text, gc );
    }

    QItemDelegate::paint( painter, opt, index );
}
<commit_msg>use the idle color setting from the appearance config<commit_after>/*
    Kopete View Item Delegate

    Copyright (c) 2007 by <NAME> <<EMAIL>>

    Kopete    (c) 2002-2007 by the Kopete developers  <<EMAIL>>

    *************************************************************************
    *                                                                       *
    * This program is free software; you can redistribute it and/or modify  *
    * it under the terms of the GNU General Public License as published by  *
    * the Free Software Foundation; either version 2 of the License, or     *
    * (at your option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include "kopeteitemdelegate.h"
#include "kopeteitembase.h"

#include <QPainter>
#include <QStyleOptionViewItem>
#include <QModelIndex>
#include <QAbstractItemView>

#include "kopetemetacontact.h"
#include "kopeteappearancesettings.h"

KopeteItemDelegate::KopeteItemDelegate( QAbstractItemView* parent )
: QItemDelegate( parent )
{
}

KopeteItemDelegate::~KopeteItemDelegate()
{
}

QSize KopeteItemDelegate::sizeHint(const QStyleOptionViewItem &option,
                                   const QModelIndex &index) const
{
    QVariant value = index.data(Qt::SizeHintRole);
    if ( value.isValid() )
        return qvariant_cast<QSize>(value);
    return QItemDelegate::sizeHint( option, index );
}

void KopeteItemDelegate::paint( QPainter* painter, 
                                const QStyleOptionViewItem& option,
                                const QModelIndex& index ) const
{
    //pull in contact settings: idleContactColor, greyIdleMetaContacts
    //pull in contact list settings: contactListDisplayMode
    QStyleOptionViewItem opt = option;

    if ( index.data( Kopete::Items::TypeRole ) ==
         Kopete::Items::MetaContact )
    {
        //check the idle state of the metacontact and apply the appropriate
        //color
        QVariant v = index.data( Kopete::Items::IdleTimeRole );
        if ( Kopete::AppearanceSettings::self()->greyIdleMetaContacts() &&
             v.toInt() > 0 )
        {
            QColor idleColor( Kopete::AppearanceSettings::self()->idleContactColor() );
            opt.palette.setColor( QPalette::Text, idleColor );
        }
    }

    if (  index.data( Kopete::Items::TypeRole ) ==
          Kopete::Items::Group )
    {
        QColor gc( Kopete::AppearanceSettings::self()->groupNameColor() );
        opt.palette.setColor( QPalette::Text, gc );
    }

    QItemDelegate::paint( painter, opt, index );
}

{'fraction_non_alphanumeric': 0.14937523665278304, 'fraction_numerical': 0.005301022340022719, 'mean_word_length': 2.403994845360825, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7237013', 'n_tokens_mistral': 1477, 'n_tokens_neox': 1413, 'n_words': 347}