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 5673ade2 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

flatpak: allow listing extensions

BUG: 400795
parent acd304d9
......@@ -521,6 +521,10 @@ void FlatpakBackend::addResource(FlatpakResource *resource)
updateAppSize(installation, resource);
m_resources.insert(resource->uniqueId(), resource);
if (!resource->extends().isEmpty()) {
m_extends.append(resource->extends());
m_extends.removeDuplicates();
}
}
class FlatpakSource
......@@ -1101,13 +1105,13 @@ ResultsStream * FlatpakBackend::search(const AbstractResourcesBackend::Filters &
return stream;
} else if(filter.resourceUrl.scheme() == QLatin1String("appstream")) {
return findResourceByPackageName(filter.resourceUrl);
} else if (!filter.resourceUrl.isEmpty() || !filter.extends.isEmpty())
} else if (!filter.resourceUrl.isEmpty() || (!filter.extends.isEmpty() && !m_extends.contains(filter.extends)))
return new ResultsStream(QStringLiteral("FlatpakStream-void"), {});
auto stream = new ResultsStream(QStringLiteral("FlatpakStream"));
auto f = [this, stream, filter] () {
QVector<AbstractResource*> ret;
foreach(AbstractResource* r, m_resources) {
foreach(auto r, m_resources) {
if (r->type() == AbstractResource::Technical && filter.state != AbstractResource::Upgradeable) {
continue;
}
......@@ -1115,6 +1119,9 @@ ResultsStream * FlatpakBackend::search(const AbstractResourcesBackend::Filters &
if (r->state() < filter.state)
continue;
if (!filter.extends.isEmpty() && !r->extends().contains(filter.extends))
continue;
if (filter.search.isEmpty() || r->name().contains(filter.search, Qt::CaseInsensitive) || r->comment().contains(filter.search, Qt::CaseInsensitive)) {
ret += r;
}
......
......@@ -63,6 +63,7 @@ public:
QString displayName() const override;
bool hasApplications() const override { return true; }
FlatpakResource * addSourceFromFlatpakRepo(const QUrl &url);
QStringList extends() const override { return m_extends; }
private Q_SLOTS:
void onFetchMetadataFinished(FlatpakInstallation *flatpakInstallation, FlatpakResource *resource, const QByteArray &metadata);
......@@ -111,6 +112,7 @@ private:
QSharedPointer<OdrsReviewsBackend> m_reviews;
uint m_isFetching = 0;
uint m_refreshAppstreamMetadataJobs;
QStringList m_extends;
GCancellable *m_cancellable;
QVector<FlatpakInstallation *> m_installations;
......
......@@ -141,7 +141,9 @@ void FlatpakResource::updateFromRef(FlatpakRef* ref)
setBranch(QString::fromUtf8(flatpak_ref_get_branch(ref)));
setCommit(QString::fromUtf8(flatpak_ref_get_commit(ref)));
setFlatpakName(QString::fromUtf8(flatpak_ref_get_name(ref)));
setType(flatpak_ref_get_kind(ref) == FLATPAK_REF_KIND_APP ? FlatpakResource::DesktopApp : FlatpakResource::Runtime);
setType(flatpak_ref_get_kind(ref) == FLATPAK_REF_KIND_APP ? DesktopApp :
extends().isEmpty() ? Runtime
: Extension);
setObjectName(packageName());
}
......@@ -244,7 +246,14 @@ int FlatpakResource::installedSize() const
AbstractResource::Type FlatpakResource::type() const
{
return m_id.type == FlatpakResource::Runtime ? Technical : Application;
switch (m_id.type) {
case FlatpakResource::Runtime:
return Technical;
case FlatpakResource::Extension:
return Addon;
default:
return Application;
}
}
QUrl FlatpakResource::homepage()
......@@ -381,11 +390,11 @@ FlatpakResource::ResourceType FlatpakResource::resourceType() const
QString FlatpakResource::typeAsString() const
{
switch (m_id.type) {
case FlatpakResource::DesktopApp:
case FlatpakResource::Source:
return QLatin1String("app");
case FlatpakResource::Runtime:
case FlatpakResource::Extension:
return QLatin1String("runtime");
case FlatpakResource::DesktopApp:
case FlatpakResource::Source:
default:
return QLatin1String("app");
}
......@@ -549,7 +558,12 @@ QString FlatpakResource::sourceIcon() const
return QStringLiteral("flatpak-discover");
}
QString FlatpakResource::author() const
QString FlatpakResource::author() const
{
return m_appdata.developerName();
}
QStringList FlatpakResource::extends() const
{
return m_appdata.extends();
}
......@@ -55,6 +55,7 @@ public:
enum ResourceType {
DesktopApp = 0,
Runtime,
Extension,
Source
};
......@@ -125,6 +126,7 @@ public:
QUrl url() const override;
QDate releaseDate() const override;
QString author() const override;
QStringList extends() const override;
FlatpakInstallation* installation() const { return m_id.installation; }
......
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