File indexing completed on 2024-07-14 14:33:58

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 1999 David Faure <faure@kde.org>
0004     SPDX-FileCopyrightText: 2001, 2002, 2004-2006 Michael Brade <brade@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef kdirlister_h
0010 #define kdirlister_h
0011 
0012 #include "kiowidgets_export.h"
0013 #include <kcoredirlister.h>
0014 
0015 class QWidget;
0016 class KDirListerPrivate;
0017 
0018 /**
0019  * @class KDirLister kdirlister.h <KDirLister>
0020  *
0021  * Subclass of KCoreDirLister which uses QWidgets to show error messages
0022  * and to associate jobs with windows.
0023  */
0024 class KIOWIDGETS_EXPORT KDirLister : public KCoreDirLister
0025 {
0026     Q_OBJECT
0027 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 82)
0028     Q_PROPERTY(bool autoErrorHandlingEnabled READ autoErrorHandlingEnabled)
0029 #endif
0030 
0031 public:
0032     /**
0033      * Create a directory lister.
0034      */
0035     KDirLister(QObject *parent = nullptr);
0036 
0037     /**
0038      * Destroy the directory lister.
0039      */
0040     ~KDirLister() override;
0041 
0042     /**
0043      * Check whether auto error handling is enabled.
0044      * If enabled, it will show an error dialog to the user when an
0045      * error occurs. It is turned on by default.
0046      * @return true if auto error handling is enabled, false otherwise
0047      * @see setAutoErrorHandlingEnabled()
0048      */
0049     bool autoErrorHandlingEnabled() const; // KF6 remove, already provided by KCoreDirLister
0050 
0051 #if KIOCORE_ENABLE_DEPRECATED_SINCE(5, 82)
0052     /**
0053      * Enable or disable auto error handling.
0054      * If enabled, it will show an error dialog to the user when an
0055      * error occurs. It is turned on by default.
0056      * @param enable true to enable auto error handling, false to disable
0057      * @param parent the parent widget for the error dialogs, can be @c nullptr for
0058      *               top-level
0059      * @see autoErrorHandlingEnabled()
0060      * @deprecated since 5.82, connect to the jobError() signal instead
0061      */
0062     KIOCORE_DEPRECATED_VERSION(5, 82, "Connect to the jobError() signal instead")
0063     void setAutoErrorHandlingEnabled(bool enable, QWidget *parent);
0064     using KCoreDirLister::setAutoErrorHandlingEnabled;
0065 #endif
0066 
0067     /**
0068      * Pass the main window this object is associated with
0069      * this is used for caching authentication data
0070      * @param window the window to associate with, @c nullptr to disassociate
0071      */
0072     void setMainWindow(QWidget *window);
0073 
0074     /**
0075      * Returns the main window associated with this object.
0076      * @return the associated main window, or @c nullptr if there is none
0077      */
0078     QWidget *mainWindow();
0079 
0080 protected:
0081 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 82)
0082     /**
0083      * Reimplemented to customize error handling
0084      * @reimp
0085      */
0086     void handleError(KIO::Job *) override;
0087 #endif
0088 
0089 #if KIOCORE_BUILD_DEPRECATED_SINCE(5, 81)
0090     /**
0091      * Reimplemented to customize error handling
0092      * @reimp
0093      */
0094     void handleErrorMessage(const QString &message) override;
0095 #endif
0096 
0097     /**
0098      * Reimplemented to associate a window with new jobs
0099      * @reimp
0100      */
0101     void jobStarted(KIO::ListJob *) override;
0102 
0103 private:
0104     friend class KDirListerPrivate;
0105     std::unique_ptr<KDirListerPrivate> d;
0106 };
0107 
0108 #endif