Commit f81ec58e authored by Nate Graham's avatar Nate Graham 🔩

Show installed and available versions of updates right there on the page

Summary:
Show the installed and available versions of each app and package update on the delegate rather than hidden away.

Depends on D17922

Test Plan:
{F6514892, size=full}

This will look nicer on distros that aren't Neon dev, where update strings are shorter and more user-readable. :)

Reviewers: apol, #discover_software_store, #vdg

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D17844
parent 89fc0a8c
......@@ -178,7 +178,7 @@ DiscoverPage
property: "section"
delegate: Kirigami.Heading {
x: Kirigami.Units.gridUnit
level: 3
level: 2
text: section
height: implicitHeight + Kirigami.Units.largeSpacing * 2
}
......@@ -223,10 +223,22 @@ DiscoverPage
smooth: true
}
Label {
Layout.fillWidth: true
text: i18n("%1 (%2)", display, version)
elide: Text.ElideRight
ColumnLayout {
// App name
Kirigami.Heading {
Layout.fillWidth: true
text: i18n("%1", display)
level: 3
elide: Text.ElideRight
}
// Old and new version numbers
Label {
Layout.fillWidth: true
elide: Text.ElideRight
text: i18n("%1 ⮕ %2", installedVersion, availableVersion)
}
}
LabelBackground {
......
......@@ -47,11 +47,22 @@ QString UpdateItem::name() const
return m_app->name();
}
// Deprecated; use availableVersion() instead
QString UpdateItem::version() const
{
return m_app->availableVersion();
}
QString UpdateItem::availableVersion() const
{
return m_app->availableVersion();
}
QString UpdateItem::installedVersion() const
{
return m_app->installedVersion();
}
QVariant UpdateItem::icon() const
{
return m_app->icon();
......
......@@ -44,7 +44,9 @@ public:
AbstractResource *app() const;
QString name() const;
QString version() const;
QString version() const; // Deprecated; use availableVersion() instead
QString availableVersion() const;
QString installedVersion() const;
QVariant icon() const;
qint64 size() const;
Qt::CheckState checked() const;
......
......@@ -63,9 +63,10 @@ QHash<int,QByteArray> UpdateModel::roleNames() const
{ ResourceProgressRole, "resourceProgress" },
{ ResourceRole, "resource" },
{ SizeRole, "size" },
{ VersionRole, "version" },
{ SectionRole, "section" },
{ ChangelogRole, "changelog" }
{ ChangelogRole, "changelog" },
{ InstalledVersionRole, "installedVersion" },
{ AvailableVersionRole, "availableVersion" }
} );
}
......@@ -124,8 +125,10 @@ QVariant UpdateModel::data(const QModelIndex &index, int role) const
return item->icon();
case Qt::CheckStateRole:
return item->checked();
case VersionRole:
return item->version();
case InstalledVersionRole:
return item->installedVersion();
case AvailableVersionRole:
return item->availableVersion();
case SizeRole:
return KFormat().formatByteSize(item->size());
case ResourceRole:
......@@ -332,7 +335,7 @@ void UpdateModel::resourceDataChanged(AbstractResource* res, const QVector<QByte
const auto index = indexFromItem(item);
if (properties.contains("state"))
Q_EMIT dataChanged(index, index, {SizeRole, VersionRole});
Q_EMIT dataChanged(index, index, {SizeRole, AvailableVersionRole});
else if (properties.contains("size")) {
Q_EMIT dataChanged(index, index, {SizeRole});
m_updateSizeTimer->start();
......
......@@ -40,13 +40,14 @@ class DISCOVERCOMMON_EXPORT UpdateModel : public QAbstractListModel
public:
enum Roles {
VersionRole = Qt::UserRole + 1,
SizeRole,
SizeRole = Qt::UserRole + 1,
ResourceRole,
ResourceProgressRole,
SectionResourceProgressRole,
ChangelogRole,
SectionRole
SectionRole,
InstalledVersionRole,
AvailableVersionRole
};
Q_ENUM(Roles)
......
......@@ -282,9 +282,8 @@ void PackageKitResource::updateDetail(const QString& packageID, const QStringLis
const auto name = PackageKit::Daemon::packageName(packageID);
QString info;
addIfNotEmpty(i18n("Current Version:"), joinPackages(updates, {}, name), info);
addIfNotEmpty(i18n("Obsoletes:"), joinPackages(obsoletes, {}, name), info);
addIfNotEmpty(i18n("New Version:"), updateText, info);
addIfNotEmpty(i18n("Release Notes:"), updateText, info);
addIfNotEmpty(i18n("Update State:"), PackageKitMessages::updateStateMessage(state), info);
addIfNotEmpty(i18n("Restart:"), PackageKitMessages::restartMessage(restart), info);
......
Markdown is supported
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