Public Member Functions | Public Attributes

QxtConfigDelegate Class Reference

#include <qxtconfigdialog_p.h>

List of all members.

Public Member Functions

 QxtConfigDelegate (QObject *parent=0)
void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const

Public Attributes

bool hover

Detailed Description

Definition at line 48 of file qxtconfigdialog_p.h.


Constructor & Destructor Documentation

QxtConfigDelegate::QxtConfigDelegate ( QObject *  parent = 0 )

Definition at line 74 of file qxtconfigdialog.cpp.

        : QItemDelegate(parent), hover(true)
{
}

Member Function Documentation

void QxtConfigDelegate::paint ( QPainter *  painter,
const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const

Definition at line 79 of file qxtconfigdialog.cpp.

References hover.

{
    QStyleOptionViewItem opt = option;
    if (hover)
    {
        QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled) ? QPalette::Normal : QPalette::Disabled;
        if (cg == QPalette::Normal && !(option.state & QStyle::State_Active))
            cg = QPalette::Inactive;

        if (option.state & QStyle::State_Selected)
            painter->fillRect(opt.rect, option.palette.brush(cg, QPalette::Highlight));
        else if ((option.state & QStyle::State_MouseOver) && (option.state & QStyle::State_Enabled))
        {
            QColor color = option.palette.color(cg, QPalette::Highlight).light();
            if (color == option.palette.color(cg, QPalette::Base))
                color = option.palette.color(cg, QPalette::AlternateBase);
            painter->fillRect(opt.rect, color);
        }
        else
            painter->fillRect(opt.rect, option.palette.brush(cg, QPalette::Base));

        opt.showDecorationSelected = false;
        opt.state &= ~QStyle::State_HasFocus;
        opt.state &= ~QStyle::State_Selected;
    }
    QItemDelegate::paint(painter, opt, index);
}
QSize QxtConfigDelegate::sizeHint ( const QStyleOptionViewItem &  option,
const QModelIndex &  index 
) const

Definition at line 107 of file qxtconfigdialog.cpp.

{
    int margin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
    int textWidth = option.fontMetrics.width(index.data().toString());
    int width = qMax(textWidth, option.decorationSize.width()) + 2 * margin;
    int height = option.fontMetrics.height() + option.decorationSize.height() + margin;
    return QSize(width, height);
}

Member Data Documentation

Definition at line 54 of file qxtconfigdialog_p.h.

Referenced by paint().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines