view ui/certificateitemdelegate.h @ 445:b3721ded6f5b

Sort and filter the certificate list, changed certificate item roles.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 23 Apr 2014 11:53:57 +0200
parents 2e5499fae159
children ab622e094786
line wrap: on
line source
/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU GPL (v>=2)
 * and comes with ABSOLUTELY NO WARRANTY!
 * See LICENSE.txt for details.
 */
#ifndef CERTIFICATELISTITEM_H
#define CERTIFICATELISTITEM_H
/**
 * @file certificateitemdelegate.h
 * @brief Item delegate drawing custom certificate items in list views.
 *
 */

#include <QStyledItemDelegate>

class CertificateItemDelegate : public QStyledItemDelegate
{
Q_OBJECT

public:
    CertificateItemDelegate(QWidget *parent = 0) : QStyledItemDelegate(parent){}

    /**
     * @brief Renders the delegate using the given painter and options.
     *
     * @param painter   The painter to draw the item.
     * @param option    The style options.
     * @param index     The model index of the item to draw.
     */
    void paint(QPainter *painter, const QStyleOptionViewItem &option,
        const QModelIndex &index) const;
    QSize sizeHint(const QStyleOptionViewItem &option,
        const QModelIndex &index) const;

    /** @brief different roles for this tiem */
    enum ItemRole {
        DataRole = Qt::UserRole, /* The certificate details for the window */
        StatusRole, /* Certificate status */
    };

private:

    /**
     * @brief Draw the item using the given parameters.
     *
     * @param painter   The painter to draw the item.
     * @param option    The style options.
     * @param index     The model index of the item to draw.
     * @param icon      The icon to display.
     * @param font      The font used to draw text.
     */
    void drawItem(QPainter *painter, const QStyleOptionViewItem &option,
        const QModelIndex &index, QIcon *icon, QFont *font) const;
};
#endif

http://wald.intevation.org/projects/trustbridge/