Commit 54376f7e authored by Volker Krause's avatar Volker Krause
Browse files

Port away from deprecated KDirLister API

Error messages are now available as signal directly, considerably
simplifying this.
parent a06b4bbd
Pipeline #167410 passed with stage
in 46 seconds
set(filepicker_lib_SRCS
api/mobilefiledialog.cpp
api/mobilefiledialog.h
declarative/dirlister.cpp
declarative/dirlister.h
declarative/dirmodel.cpp
declarative/dirmodel.h
declarative/dirmodelutils.cpp
......
// SPDX-FileCopyrightText: 2020 Jonah Brüchert <jbb@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.0-or-later
#include "dirlister.h"
#include <KIO/Job>
DirLister::DirLister(QObject *parent)
: KDirLister(parent)
{
}
void DirLister::handleError(KIO::Job *job)
{
handleErrorMessage(job->errorString());
}
void DirLister::handleErrorMessage(const QString &message)
{
Q_EMIT errorOccured(message);
}
// SPDX-FileCopyrightText: 2020 Jonah Brüchert <jbb@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.0-or-later
#pragma once
#include <KDirLister>
#include <QObject>
class DirLister : public KDirLister
{
Q_OBJECT
public:
explicit DirLister(QObject *parent = nullptr);
void handleError(KIO::Job *job) override;
void handleErrorMessage(const QString &message) override;
Q_SIGNALS:
void errorOccured(const QString &message);
};
......@@ -6,18 +6,17 @@
#include "dirmodel.h"
#include <KDirLister>
#include "dirlister.h"
#include <KIO/Job>
DirModel::DirModel(QObject *parent)
: KDirSortFilterProxyModel(parent)
, m_lister(new DirLister(this))
, m_lister(new KDirLister(this))
{
setSourceModel(&m_dirModel);
m_dirModel.setDirLister(m_lister);
connect(m_lister, QOverload<>::of(&KCoreDirLister::completed), this, &DirModel::isLoadingChanged);
connect(m_lister, &DirLister::errorOccured, this, [this](const QString &message) {
m_lastError = message;
connect(m_lister, &KDirLister::jobError, this, [this](KIO::Job *job) {
m_lastError = job->errorString();
Q_EMIT lastErrorChanged();
});
}
......
......@@ -11,7 +11,7 @@
#include <KDirModel>
#include <KDirSortFilterProxyModel>
class DirLister;
class KDirLister;
class DirModel : public KDirSortFilterProxyModel
{
......@@ -74,7 +74,7 @@ Q_SIGNALS:
private:
KDirModel m_dirModel;
DirLister *m_lister;
KDirLister *m_lister;
QString m_lastError;
};
Supports Markdown
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