1 /* 2 This file is part of the KDE libraries 3 SPDX-FileCopyrightText: 2001 Frerich Raabe <raabe@kde.org> 4 SPDX-FileCopyrightText: 2003 Carsten Pfeiffer <pfeiffer@kde.org> 5 6 SPDX-License-Identifier: LGPL-2.0-or-later 7 */ 8 9 #ifndef __KPREVIEWWIDGETBASE_H__ 10 #define __KPREVIEWWIDGETBASE_H__ 11 12 #include <QWidget> 13 14 #include "kiofilewidgets_export.h" 15 16 class QUrl; 17 18 /** 19 * @class KPreviewWidgetBase kpreviewwidgetbase.h <KPreviewWidgetBase> 20 * 21 * Abstract baseclass for all preview widgets which shall be used via 22 * KFileDialog::setPreviewWidget(const KPreviewWidgetBase *). 23 * Ownership will be transferred to KFileDialog, so you have to create 24 * the preview with "new" and let KFileDialog delete it. 25 * 26 * Just derive your custom preview widget from KPreviewWidgetBase and implement 27 * all the pure virtual methods. The slot showPreview(const QUrl &) is called 28 * every time the file selection changes. 29 * 30 * @short Abstract baseclass for all preview widgets. 31 * @author Frerich Raabe <raabe@kde.org> 32 */ 33 class KIOFILEWIDGETS_EXPORT KPreviewWidgetBase : public QWidget 34 { 35 Q_OBJECT 36 37 public: 38 /** 39 * Constructor. Construct the user interface of your preview widget here 40 * and pass the KFileDialog this preview widget is going to be used in as 41 * the parent. 42 * 43 * @param parent The KFileDialog this preview widget is going to be used in 44 */ 45 explicit KPreviewWidgetBase(QWidget *parent); 46 ~KPreviewWidgetBase() override; 47 48 public Q_SLOTS: 49 /** 50 * This slot is called every time the user selects another file in the 51 * file dialog. Implement the stuff necessary to reflect the change here. 52 * 53 * @param url The URL of the currently selected file. 54 */ 55 virtual void showPreview(const QUrl &url) = 0; 56 57 /** 58 * Reimplement this to clear the preview. This is called when e.g. the 59 * selection is cleared or when multiple selections exist, or the directory 60 * is changed. 61 */ 62 virtual void clearPreview() = 0; 63 64 // TODO KF6: make it a public method, it's not a slot 65 QStringList supportedMimeTypes() const; // clazy:exclude=const-signal-or-slot 66 67 protected: 68 void setSupportedMimeTypes(const QStringList &mimeTypes); 69 70 private: 71 class KPreviewWidgetBasePrivate; 72 KPreviewWidgetBasePrivate *const d; 73 74 Q_DISABLE_COPY(KPreviewWidgetBase) 75 }; 76 77 #endif 78