File indexing completed on 2024-07-21 12:11:47

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 1998, 1999 Torben Weis <weis@kde.org>
0004     SPDX-FileCopyrightText: 2000 Carsten Pfeiffer <pfeiffer@kde.org>
0005     SPDX-FileCopyrightText: 2003-2005 David Faure <faure@kde.org>
0006     SPDX-FileCopyrightText: 2001-2006 Michael Brade <brade@kde.org>
0007 
0008     SPDX-License-Identifier: LGPL-2.0-or-later
0009 */
0010 
0011 #include "kdirlister.h"
0012 #include <KJobUiDelegate>
0013 #include <KJobWidgets>
0014 #include <kio/listjob.h>
0015 
0016 #include <QWidget>
0017 
0018 class KDirListerPrivate
0019 {
0020 public:
0021     KDirListerPrivate()
0022     {
0023     }
0024 
0025 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 82)
0026     QWidget *m_errorParent = nullptr;
0027 #endif
0028     QWidget *m_window = nullptr; // Main window this lister is associated with
0029 };
0030 
0031 KDirLister::KDirLister(QObject *parent)
0032     : KCoreDirLister(parent)
0033     , d(new KDirListerPrivate)
0034 {
0035 }
0036 
0037 KDirLister::~KDirLister()
0038 {
0039 }
0040 
0041 bool KDirLister::autoErrorHandlingEnabled() const
0042 {
0043     return KCoreDirLister::autoErrorHandlingEnabled();
0044 }
0045 
0046 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 82)
0047 void KDirLister::setAutoErrorHandlingEnabled(bool enable, QWidget *parent)
0048 {
0049     KCoreDirLister::setAutoErrorHandlingEnabled(enable);
0050     d->m_errorParent = parent;
0051 }
0052 #endif
0053 
0054 void KDirLister::setMainWindow(QWidget *window)
0055 {
0056     d->m_window = window;
0057 }
0058 
0059 QWidget *KDirLister::mainWindow()
0060 {
0061     return d->m_window;
0062 }
0063 
0064 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 82)
0065 void KDirLister::handleError(KIO::Job *job)
0066 {
0067     // auto error handling moved to KCoreDirLister
0068     KCoreDirLister::handleError(job);
0069 }
0070 #endif
0071 
0072 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 81)
0073 void KDirLister::handleErrorMessage(const QString &message) // not called anymore
0074 {
0075     // auto error handling moved to KCoreDirLister
0076     KCoreDirLister::handleErrorMessage(message);
0077 }
0078 #endif
0079 
0080 void KDirLister::jobStarted(KIO::ListJob *job)
0081 {
0082     if (d->m_window) {
0083         KJobWidgets::setWindow(job, d->m_window);
0084     }
0085 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 82)
0086     else if (d->m_errorParent) {
0087         KJobWidgets::setWindow(job, d->m_errorParent);
0088     }
0089 #endif
0090 }
0091 
0092 #include "moc_kdirlister.cpp"