Beispiel #1
0
static void drawRedWavyUnderLine(QPainter *painter,
                                 const QStyleOptionViewItem &styleOption,
                                 const QRect &textFrame)
{
    painter->translate(0, textFrame.y() + 1);
    QPen pen;
    pen.setColor(Qt::red);
    const qreal underlineOffset = styleOption.fontMetrics.underlinePos();
    const QPixmap wave = getWavyPixmap(qMax(underlineOffset, pen.widthF()), pen);
    const int descent = styleOption.fontMetrics.descent();

    painter->setBrushOrigin(painter->brushOrigin().x(), 0);
    painter->fillRect(textFrame.x(), 0, qCeil(textFrame.width()), qMin(wave.height(), descent), wave);
}
static void drawRedWavyUnderLine(QPainter *painter,
                                 const QStyleOptionViewItem &styleOption,
                                 const QModelIndex &modelIndex,
                                 const QRect &textFrame ,
                                 NavigatorTreeModel *navigatorTreeModel)
{
    if (navigatorTreeModel->hasNodeForIndex(modelIndex)) {
        ModelNode modelNode = navigatorTreeModel->nodeForIndex(modelIndex);

        if (!modelNode.metaInfo().isValid()) {
            painter->translate(0, textFrame.y() + 1);
            QPen pen;
            pen.setColor(Qt::red);
            const qreal underlineOffset = styleOption.fontMetrics.underlinePos();
            const QPixmap wave = getWavyPixmap(qMax(underlineOffset, pen.widthF()), pen);
            const int descent = styleOption.fontMetrics.descent();

            painter->setBrushOrigin(painter->brushOrigin().x(), 0);
            painter->fillRect(textFrame.x(), 0, qCeil(textFrame.width()), qMin(wave.height(), descent), wave);
        }
    }
}