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

Fix opening flatpakref of already-existing repositories

Instead of loading it, which won't work, pick the resource that we already
have.

BUG: 401832
parent 6ea64d5e
......@@ -383,6 +383,17 @@ FlatpakResource * FlatpakBackend::addAppFromFlatpakRef(const QUrl &url)
{
QSettings settings(url.toLocalFile(), QSettings::NativeFormat);
const QString refurl = settings.value(QStringLiteral("Flatpak Ref/Url")).toString();
const QString name = settings.value(QStringLiteral("Flatpak Ref/Name")).toString();
auto item = m_sources->sourceByUrl(refurl);
if (item) {
const auto resources = resourcesByAppstreamName(name);
for (auto resource : resources) {
if (resource->origin() == item->data(AbstractSourcesBackend::IdRole)) {
return static_cast<FlatpakResource*>(resource);
}
}
}
g_autoptr(GError) error = nullptr;
g_autoptr(FlatpakRemoteRef) remoteRef = nullptr;
......
......@@ -131,6 +131,19 @@ QStandardItem * FlatpakSourcesBackend::sourceById(const QString& id) const
return sourceIt;
}
QStandardItem * FlatpakSourcesBackend::sourceByUrl(const QString& url) const
{
QStandardItem* sourceIt = nullptr;
for (int i = 0, c = m_sources->rowCount(); i<c; ++i) {
auto it = m_sources->item(i);
if (it->data(Qt::StatusTipRole) == url) {
sourceIt = it;
break;
}
}
return sourceIt;
}
bool FlatpakSourcesBackend::removeSource(const QString &id)
{
auto sourceIt = sourceById(id);
......@@ -244,6 +257,7 @@ void FlatpakSourcesBackend::addRemote(FlatpakRemote *remote, FlatpakInstallation
FlatpakSourceItem *it = new FlatpakSourceItem(!title.isEmpty() ? title : id);
it->setCheckState(flatpak_remote_get_disabled(remote) ? Qt::Unchecked : Qt::Checked);
it->setData(remoteUrl.isLocalFile() ? remoteUrl.toLocalFile() : remoteUrl.host(), Qt::ToolTipRole);
it->setData(remoteUrl, Qt::StatusTipRole);
it->setData(id, IdRole);
it->setFlatpakInstallation(installation);
......
......@@ -50,6 +50,7 @@ public:
bool moveSource(const QString & sourceId, int delta) override;
int originIndex(const QString& sourceId) const;
QStandardItem* sourceByUrl(const QString & url) const;
private:
QStandardItem* sourceById(const QString & sourceId) 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