Commit 9146b5da authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

packagekit: initialize repository list on-demand

At the moment it's holding the initialisation of all the backend, since
it's the first transaction to be issued. This change delays it to
whenever the settings view is shown which may never be.
parent 2ce5eb9d
......@@ -23,6 +23,7 @@ DiscoverPage {
mainItem: ListView {
id: sourcesView
model: SourcesModel
Component.onCompleted: Qt.callLater(SourcesModel.showingNow)
currentIndex: -1
section.property: "sourceName"
......
......@@ -28,6 +28,7 @@
#include <QProcess>
#include <QDebug>
#include <QRegularExpression>
#include <resources/SourcesModel.h>
#include <resources/AbstractResourcesBackend.h>
#include "PackageKitBackend.h"
#include "config-paths.h"
......@@ -79,7 +80,7 @@ PackageKitSourcesBackend::PackageKitSourcesBackend(AbstractResourcesBackend* par
, m_sources(new PKSourcesModel(this))
{
connect(PackageKit::Daemon::global(), &PackageKit::Daemon::repoListChanged, this, &PackageKitSourcesBackend::resetSources);
resetSources();
connect(SourcesModel::global(), &SourcesModel::showingNow, this, &PackageKitSourcesBackend::resetSources);
// Kubuntu-based
auto addNativeSourcesManager = [this](const QString &file){
......@@ -162,6 +163,7 @@ QVariantList PackageKitSourcesBackend::actions() const
void PackageKitSourcesBackend::resetSources()
{
disconnect(SourcesModel::global(), &SourcesModel::showingNow, this, &PackageKitSourcesBackend::resetSources);
m_sources->clear();
auto transaction = PackageKit::Daemon::global()->getRepoList();
connect(transaction, &PackageKit::Transaction::repoDetail, this, &PackageKitSourcesBackend::addRepositoryDetails);
......
......@@ -50,6 +50,9 @@ class DISCOVERCOMMON_EXPORT SourcesModel : public KConcatenateRowsProxyModel
Q_SCRIPTABLE AbstractSourcesBackend* sourcesBackendByName(const QString &name) const;
Q_SIGNALS:
void showingNow();
private:
const QAbstractItemModel* modelAt(const QModelIndex& idx) 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