Commit 5a04c305 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Expose resources' release date

Makes it possible to sort lists by release date.
Also it's possible to show it in the application page.
parent 53f3ce95
......@@ -96,6 +96,16 @@ DiscoverPage {
checkable: true
checked: appsModel.sortRole == ResourcesProxyModel.SizeRole
}
QQC2.Action {
QQC2.ActionGroup.group: sortGroup
text: i18n("Release Date")
onTriggered: {
appsModel.sortRole = ResourcesProxyModel.ReleaseDateRole
appsModel.sortOrder = Qt.AscendingOrder
}
checkable: true
checked: appsModel.sortRole == ResourcesProxyModel.ReleaseDateRole
}
}
]
......
......@@ -542,3 +542,13 @@ QUrl FlatpakResource::url() const
{
return m_resourceFile.isEmpty() ? QUrl(QStringLiteral("appstream://") + appstreamId()) : m_resourceFile;
}
QDate FlatpakResource::releaseDate() const
{
if (!m_appdata.releases().isEmpty()) {
auto release = m_appdata.releases().constFirst();
return release.timestamp().date();
}
return {};
}
......@@ -105,6 +105,7 @@ public:
QString typeAsString() const;
QString uniqueId() const;
QUrl url() const override;
QDate releaseDate() const override;
FlatpakInstallation* installation() const { return m_installation; }
......
......@@ -229,3 +229,8 @@ QString KNSResource::executeLabel() const
{
return i18n("Use");
}
QDate KNSResource::releaseDate() const
{
return m_entry.releaseDate();
}
......@@ -66,6 +66,7 @@ public:
QUrl url() const override;
QString executeLabel() const override;
QString sourceIcon() const override { return QStringLiteral("get-hot-new-stuff"); }
QDate releaseDate() const override;
private:
const QStringList m_categories;
......
......@@ -201,3 +201,12 @@ void AppPackageKitResource::invokeApplication() const
}
}
QDate AppPackageKitResource::releaseDate() const
{
if (!m_appdata.releases().isEmpty()) {
auto release = m_appdata.releases().constFirst();
return release.timestamp().date();
}
return {};
}
......@@ -51,6 +51,7 @@ class AppPackageKitResource : public PackageKitResource
void fetchChangelog() override;
void invokeApplication() const override;
bool canExecute() const override { return true; }
QDate releaseDate() const override;
private:
const AppStream::Component m_appdata;
......
......@@ -71,6 +71,8 @@ class PackageKitResource : public AbstractResource
QString sourceIcon() const override;
QDate releaseDate() const override { return {}; }
public Q_SLOTS:
void addPackageId(PackageKit::Transaction::Info info, const QString &packageId, bool arch);
void setDetails(const PackageKit::Details& details);
......
......@@ -187,3 +187,8 @@ void SnapResource::setSnap(const QSharedPointer<QSnapdSnap>& snap)
if (newSize)
Q_EMIT sizeChanged();
}
QDate SnapResource::releaseDate() const
{
return {};
}
......@@ -60,6 +60,8 @@ public:
void setState(AbstractResource::State state);
QString sourceIcon() const override { return QStringLiteral("snap"); }
QDate releaseDate() const override;
public:
void gotIcon();
AbstractResource::State m_state;
......
......@@ -78,6 +78,7 @@ class DISCOVERCOMMON_EXPORT AbstractResource : public QObject
Q_PROPERTY(QUrl url READ url CONSTANT)
Q_PROPERTY(QString executeLabel READ executeLabel CONSTANT)
Q_PROPERTY(QString sourceIcon READ sourceIcon CONSTANT)
Q_PROPERTY(QDate releaseDate READ releaseDate NOTIFY stateChanged)
public:
/**
* This describes the state of the resource
......@@ -202,6 +203,7 @@ class DISCOVERCOMMON_EXPORT AbstractResource : public QObject
virtual QString executeLabel() const;
virtual QString sourceIcon() const = 0;
virtual QDate releaseDate() const = 0;
public Q_SLOTS:
virtual void fetchScreenshots();
......
......@@ -59,7 +59,8 @@ ResourcesProxyModel::ResourcesProxyModel(QObject *parent)
{ MimeTypes, "mimetypes" },
{ LongDescriptionRole, "longDescription" },
{ SourceIconRole, "sourceIcon" },
{ SizeRole, "size" }
{ SizeRole, "size" },
{ ReleaseDateRole, "releaseDate" }
})
, m_currentStream(nullptr)
{
......
......@@ -76,7 +76,8 @@ public:
MimeTypes,
SizeRole,
LongDescriptionRole,
SourceIconRole
SourceIconRole,
ReleaseDateRole
};
Q_ENUM(Roles)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment