File indexing completed on 2024-05-12 16:58:59

0001 /*
0002  *   SPDX-FileCopyrightText: 2011 Jonathan Thomas <echidnaman@kubuntu.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #include "UpdateItem.h"
0008 #include <resources/AbstractBackendUpdater.h>
0009 #include <resources/AbstractResource.h>
0010 #include <resources/AbstractResourcesBackend.h>
0011 
0012 #include "libdiscover_debug.h"
0013 #include <KLocalizedString>
0014 #include <QStringBuilder>
0015 
0016 UpdateItem::UpdateItem(AbstractResource *app)
0017     : m_app(app)
0018 {
0019 }
0020 
0021 UpdateItem::~UpdateItem()
0022 {
0023 }
0024 
0025 AbstractResource *UpdateItem::app() const
0026 {
0027     return m_app;
0028 }
0029 
0030 QString UpdateItem::name() const
0031 {
0032     return m_app->name();
0033 }
0034 
0035 QVariant UpdateItem::icon() const
0036 {
0037     return m_app->icon();
0038 }
0039 
0040 qint64 UpdateItem::size() const
0041 {
0042     return m_app->size();
0043 }
0044 
0045 static bool isMarked(AbstractResource *res)
0046 {
0047     return res->backend()->backendUpdater()->isMarked(res);
0048 }
0049 
0050 Qt::CheckState UpdateItem::checked() const
0051 {
0052     return isMarked(app()) ? Qt::Checked : Qt::Unchecked;
0053 }
0054 
0055 qreal UpdateItem::progress() const
0056 {
0057     return m_progress;
0058 }
0059 
0060 void UpdateItem::setProgress(qreal progress)
0061 {
0062     m_progress = progress;
0063 }
0064 
0065 QString UpdateItem::changelog() const
0066 {
0067     return m_changelog;
0068 }
0069 
0070 void UpdateItem::setChangelog(const QString &changelog)
0071 {
0072     m_changelog = changelog;
0073 }