1 /*
2     This file is part of the KDE project
3     SPDX-FileCopyrightText: 1998, 1999 Torben Weis <weis@kde.org>
4     SPDX-FileCopyrightText: 2000 Carsten Pfeiffer <pfeiffer@kde.org>
5     SPDX-FileCopyrightText: 2003-2005 David Faure <faure@kde.org>
6     SPDX-FileCopyrightText: 2001-2006 Michael Brade <brade@kde.org>
7 
8     SPDX-License-Identifier: LGPL-2.0-or-later
9 */
10 
11 #include "kdirlister.h"
12 #include <KJobUiDelegate>
13 #include <KJobWidgets>
14 #include <kio/listjob.h>
15 
16 #include <KMessageBox>
17 #include <QWidget>
18 
19 class KDirListerPrivate
20 {
21 public:
KDirListerPrivate()22     KDirListerPrivate()
23     {
24     }
25 
26 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 82)
27     QWidget *m_errorParent = nullptr;
28 #endif
29     QWidget *m_window = nullptr; // Main window this lister is associated with
30 };
31 
KDirLister(QObject * parent)32 KDirLister::KDirLister(QObject *parent)
33     : KCoreDirLister(parent)
34     , d(new KDirListerPrivate)
35 {
36 }
37 
~KDirLister()38 KDirLister::~KDirLister()
39 {
40 }
41 
autoErrorHandlingEnabled() const42 bool KDirLister::autoErrorHandlingEnabled() const
43 {
44     return KCoreDirLister::autoErrorHandlingEnabled();
45 }
46 
47 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 82)
setAutoErrorHandlingEnabled(bool enable,QWidget * parent)48 void KDirLister::setAutoErrorHandlingEnabled(bool enable, QWidget *parent)
49 {
50     KCoreDirLister::setAutoErrorHandlingEnabled(enable);
51     d->m_errorParent = parent;
52 }
53 #endif
54 
setMainWindow(QWidget * window)55 void KDirLister::setMainWindow(QWidget *window)
56 {
57     d->m_window = window;
58 }
59 
mainWindow()60 QWidget *KDirLister::mainWindow()
61 {
62     return d->m_window;
63 }
64 
65 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 82)
handleError(KIO::Job * job)66 void KDirLister::handleError(KIO::Job *job)
67 {
68     // auto error handling moved to KCoreDirLister
69     KCoreDirLister::handleError(job);
70 }
71 #endif
72 
73 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 81)
handleErrorMessage(const QString & message)74 void KDirLister::handleErrorMessage(const QString &message) // not called anymore
75 {
76     // auto error handling moved to KCoreDirLister
77     KCoreDirLister::handleErrorMessage(message);
78 }
79 #endif
80 
jobStarted(KIO::ListJob * job)81 void KDirLister::jobStarted(KIO::ListJob *job)
82 {
83     if (d->m_window) {
84         KJobWidgets::setWindow(job, d->m_window);
85     }
86 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 82)
87     else if (d->m_errorParent) {
88         KJobWidgets::setWindow(job, d->m_errorParent);
89     }
90 #endif
91 }
92 
93 #include "moc_kdirlister.cpp"
94