File indexing completed on 2024-09-15 12:00:09
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 2001 Frerich Raabe <raabe@kde.org> 0004 SPDX-FileCopyrightText: 2003 Carsten Pfeiffer <pfeiffer@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef __KPREVIEWWIDGETBASE_H__ 0010 #define __KPREVIEWWIDGETBASE_H__ 0011 0012 #include <QWidget> 0013 0014 #include "kiofilewidgets_export.h" 0015 0016 #include <memory> 0017 0018 class QUrl; 0019 0020 /** 0021 * @class KPreviewWidgetBase kpreviewwidgetbase.h <KPreviewWidgetBase> 0022 * 0023 * Abstract baseclass for all preview widgets which shall be used via 0024 * KFileDialog::setPreviewWidget(const KPreviewWidgetBase *). 0025 * Ownership will be transferred to KFileDialog, so you have to create 0026 * the preview with "new" and let KFileDialog delete it. 0027 * 0028 * Just derive your custom preview widget from KPreviewWidgetBase and implement 0029 * all the pure virtual methods. The slot showPreview(const QUrl &) is called 0030 * every time the file selection changes. 0031 * 0032 * @short Abstract baseclass for all preview widgets. 0033 * @author Frerich Raabe <raabe@kde.org> 0034 */ 0035 class KIOFILEWIDGETS_EXPORT KPreviewWidgetBase : public QWidget 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 /** 0041 * Constructor. Construct the user interface of your preview widget here 0042 * and pass the KFileDialog this preview widget is going to be used in as 0043 * the parent. 0044 * 0045 * @param parent The KFileDialog this preview widget is going to be used in 0046 */ 0047 explicit KPreviewWidgetBase(QWidget *parent); 0048 ~KPreviewWidgetBase() override; 0049 0050 public Q_SLOTS: 0051 /** 0052 * This slot is called every time the user selects another file in the 0053 * file dialog. Implement the stuff necessary to reflect the change here. 0054 * 0055 * @param url The URL of the currently selected file. 0056 */ 0057 virtual void showPreview(const QUrl &url) = 0; 0058 0059 /** 0060 * Reimplement this to clear the preview. This is called when e.g. the 0061 * selection is cleared or when multiple selections exist, or the directory 0062 * is changed. 0063 */ 0064 virtual void clearPreview() = 0; 0065 0066 // TODO KF6: make it a public method, it's not a slot 0067 QStringList supportedMimeTypes() const; // clazy:exclude=const-signal-or-slot 0068 0069 protected: 0070 void setSupportedMimeTypes(const QStringList &mimeTypes); 0071 0072 private: 0073 class KPreviewWidgetBasePrivate; 0074 std::unique_ptr<KPreviewWidgetBasePrivate> const d; 0075 0076 Q_DISABLE_COPY(KPreviewWidgetBase) 0077 }; 0078 0079 #endif