File indexing completed on 2024-02-18 04:58:20

0001 /**************************************************************************
0002  *   Copyright (C) 2009-2011 Matthias Fuchs <mat69@gmx.net>                *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU General Public License as published by  *
0006  *   the Free Software Foundation; either version 2 of the License, or     *
0007  *   (at your option) any later version.                                   *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU General Public License     *
0015  *   along with this program; if not, write to the                         *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
0018  ***************************************************************************/
0019 
0020 #ifndef VERIFICATION_MODEL_H
0021 #define VERIFICATION_MODEL_H
0022 
0023 #include "kget_export.h"
0024 
0025 #include <QAbstractTableModel>
0026 
0027 class VerificationModelPrivate;
0028 
0029 class KGET_EXPORT VerificationModel : public QAbstractTableModel
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     VerificationModel(QObject *parent = nullptr);
0035 
0036     enum dataType { Type, Checksum, Verified };
0037 
0038     QVariant data(const QModelIndex &index, int role) const override;
0039     Qt::ItemFlags flags(const QModelIndex &index) const override;
0040     bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
0041     QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
0042     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0043     int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0044     bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
0045 
0046     /**
0047      * Add a checksum that is later used in the verification process
0048      * @note only one checksum per type can be added (one MD5, one SHA1 etc.),
0049      * the newer overwrites the older and a checksum can only be added if it is
0050      * supported by the verifier
0051      * @param type the type of the checksum
0052      * @param checksum the checksum
0053      * @param verified if the file has been verified using this checksum
0054      */
0055     void addChecksum(const QString &type, const QString &checksum, int verified = 0);
0056 
0057     /**
0058      * Add multiple checksums that will later be used in the verification process
0059      * @note only one checksum per type can be added (one MD5, one SHA1 etc.),
0060      * the newer overwrites the older and a checksum can only be added if it is
0061      * supported by the verifier
0062      * @param checksums <type, checksum>
0063      */
0064     void addChecksums(const QMultiHash<QString, QString> &checksums);
0065 
0066     /**
0067      * Sets the verificationStatus for type
0068      */
0069     void setVerificationStatus(const QString &type, int verified);
0070 
0071 private:
0072     VerificationModelPrivate *d;
0073 
0074     friend class VerificationModelPrivate;
0075 };
0076 
0077 #endif