Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 4bbab6b2 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Make it possible to change the source we're dealing with

parent 95ef0d1c
......@@ -153,13 +153,26 @@ DiscoverPage {
Label {
text: i18n("Size: %1", appInfo.application.sizeDescription)
}
Label {
text: i18n("Origin: %1 (%2)", appInfo.application.origin, appInfo.application.backend.displayName)
}
Label {
visible: text.length>0
text: appInfo.application.license ? i18n("License: %1", appInfo.application.license) : ""
}
ComboBox {
id: sourcesCombo
model: ResourcesProxyModel {
onIsBusyChanged: if (!isBusy) {
sourcesCombo.currentIndex = indexOf(appInfo.application)
}
resourcesUrl: appInfo.application.url
}
onActivated: if(index>=0) {
var res = model.resourceAt(index)
console.assert(res)
window.stack.pop()
Navigation.openApplication(res)
}
textRole: "displayOrigin"
}
}
}
......
......@@ -249,3 +249,8 @@ QUrl AbstractResource::url() const
const QString asid = appstreamId();
return asid.isEmpty() ? QUrl() : QUrl(QStringLiteral("appstream://") + asid);
}
QString AbstractResource::displayOrigin() const
{
return i18nc("origin (backend name)", "%1 (%2)", origin(), backend()->displayName());
}
......@@ -63,6 +63,7 @@ class DISCOVERCOMMON_EXPORT AbstractResource : public QObject
Q_PROPERTY(QString license READ license CONSTANT)
Q_PROPERTY(QString longDescription READ longDescription CONSTANT)
Q_PROPERTY(QString origin READ origin CONSTANT)
Q_PROPERTY(QString displayOrigin READ displayOrigin CONSTANT)
Q_PROPERTY(int size READ size NOTIFY sizeChanged)
Q_PROPERTY(QString sizeDescription READ sizeDescription NOTIFY sizeChanged)
Q_PROPERTY(QString installedVersion READ installedVersion NOTIFY stateChanged)
......@@ -142,6 +143,7 @@ class DISCOVERCOMMON_EXPORT AbstractResource : public QObject
virtual QString longDescription() = 0;
virtual QString origin() const = 0;
QString displayOrigin() const;
virtual QString section() = 0;
///@returns what kind of mime types the resource can consume
......
......@@ -49,6 +49,7 @@ ResourcesProxyModel::ResourcesProxyModel(QObject *parent)
{ InstalledRole, "isInstalled" },
{ ApplicationRole, "application" },
{ OriginRole, "origin" },
{ DisplayOriginRole, "displayOrigin" },
{ CanUpgrade, "canUpgrade" },
{ PackageNameRole, "packageName" },
{ IsTechnicalRole, "isTechnical" },
......@@ -463,3 +464,13 @@ QVector<int> ResourcesProxyModel::propertiesToRoles(const QVector<QByteArray>& p
roles.removeAll(-1);
return roles;
}
int ResourcesProxyModel::indexOf(AbstractResource* res)
{
return m_displayedResources.indexOf(res);
}
AbstractResource * ResourcesProxyModel::resourceAt(int row) const
{
return m_displayedResources[row];
}
......@@ -65,6 +65,7 @@ public:
InstalledRole,
ApplicationRole,
OriginRole,
DisplayOriginRole,
CanUpgrade,
PackageNameRole,
IsTechnicalRole,
......@@ -107,6 +108,9 @@ public:
QVariant data(const QModelIndex & index, int role) const override;
int rowCount(const QModelIndex & parent = {}) const override;
Q_SCRIPTABLE int indexOf(AbstractResource* res);
Q_SCRIPTABLE AbstractResource* resourceAt(int row) const;
bool isBusy() const { return m_currentStream != nullptr; }
bool lessThan(AbstractResource* rl, AbstractResource* rr) const;
......
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