[PATCH 3 of 7] Remove unused code

Wald Commits scm-commit at wald.intevation.org
Fri Jul 4 16:17:46 CEST 2014


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1404469606 -7200
# Node ID 084536d95f4a41e4655229e4af88d5dc50dd7961
# Parent  8efd10afb8831e45024dba4d813e0c0d4c38da49
Remove unused code.

diff -r 8efd10afb883 -r 084536d95f4a ui/certificateitemdelegate.cpp
--- a/ui/certificateitemdelegate.cpp	Fri Jul 04 11:16:43 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/* 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.
- */
-#include <QtWidgets>
-
-#include "certificate.h"
-#include "mainwindow.h"
-#include "certificateitemdelegate.h"
-
-void CertificateItemDelegate::paint(QPainter *painter,
-    const QStyleOptionViewItem &option, const QModelIndex &index) const
-{
-    // Save the current painter.
-    painter->save();
-    int status = index.data(StatusRole).toInt();
-    if (status == 0) {
-        // This status is not known, so draw the default item.
-        QStyledItemDelegate::paint(painter, option, index);
-        painter->restore();
-        return;
-    }
-
-    if (status == Certificate::InstallNew) {
-        //Set the icon and use bold and bigger font to highlight this item.
-        QIcon *icon = new QIcon(":/img/list-add.png");
-        QFont *font = new QFont();
-        font->setBold(true);
-        font->setPointSize(font->pointSize() + 1);
-        drawItem(painter, option, index, icon, font);
-    }
-    else if (status == Certificate::InstallOld) {
-        // Set the icon and use the default font for this item.
-        QIcon *icon = new QIcon(":/img/list-add.png");
-        QFont *font = new QFont();
-        drawItem(painter, option, index, icon, font);
-    }
-    else if (status == Certificate::RemoveNew) {
-        //Set the icon and use bold and bigger font to highlight this item.
-        QIcon *icon = new QIcon(":/img/list-remove.png");
-        QFont *font = new QFont();
-        font->setBold(true);
-        font->setPointSize(font->pointSize() + 1);
-        drawItem(painter, option, index, icon, font);
-    }
-    else if (status == Certificate::RemoveOld) {
-        // Set the icon and use the default font for this item.
-        QIcon *icon = new QIcon(":/img/list-remove.png");
-        QFont *font = new QFont();
-        drawItem(painter, option, index, icon, font);
-    }
-    else {
-        // Draw the default item.
-        QStyledItemDelegate::paint(painter, option, index);
-    }
-    // Restore the painter to have an unmodified painter for the next draw
-    // action.
-    painter->restore();
-    return;
-}
-
-void CertificateItemDelegate::drawItem(QPainter *painter,
-    const QStyleOptionViewItem &option, const QModelIndex &index,
-    QIcon *icon, QFont *font) const
-{
-    // Get temporary style option to draw a checkbox only.
-    QStyleOptionViewItem opt = option;
-    // Initialize the style options with the temporary option object.
-    initStyleOption(&opt, index);
-    // Clear all text to draw the checkbox only.
-    opt.text.clear();
-
-    // Draw highlighted background.
-    if (option.state & QStyle::State_Selected) {
-        painter->fillRect(option.rect, option.palette.highlight());
-    }
-
-    // Draw the checkbox control with the temporary options.
-    QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter);
-
-    // Draw the icon.
-    int iconSpace = 25;
-    if (!icon->isNull()) {
-        QRect rect = option.rect.adjusted(25, 0, 0, 0);
-        icon->paint(painter, rect, Qt::AlignVCenter|Qt::AlignLeft);
-        iconSpace = 50;
-    }
-
-    // Draw the text using the given font.
-    QString text = index.data().toString();
-    QRect rect = option.rect.adjusted(iconSpace, 0, 0, 0);
-    painter->setFont(*font);
-    painter->drawText(rect.left(), rect.top(), rect.width(), rect.height(),
-        Qt::AlignVCenter|Qt::AlignLeft, text, &rect);
-}
-
-QSize CertificateItemDelegate::sizeHint(const QStyleOptionViewItem &option,
-    const QModelIndex &index) const
-{
-    int width = QStyledItemDelegate::sizeHint(option, index).width() + 75;
-    int height = 25;
-    return QSize(width, height);
-}
diff -r 8efd10afb883 -r 084536d95f4a ui/certificateitemdelegate.h
--- a/ui/certificateitemdelegate.h	Fri Jul 04 11:16:43 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-/* 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 CERTIFICATELISTDELEGATE_H
-#define CERTIFICATELISTDELEGATE_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


More information about the Trustbridge-commits mailing list