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#include <memory>
17
18class QUrl;
19
20/*!
21 * \class KPreviewWidgetBase
22 * \inmodule KIOFileWidgets
23 *
24 * \brief Abstract baseclass for all preview widgets.
25 *
26 * Abstract baseclass for all preview widgets which shall be used via
27 * KFileDialog::setPreviewWidget(const KPreviewWidgetBase *).
28 * Ownership will be transferred to KFileDialog, so you have to create
29 * the preview with "new" and let KFileDialog delete it.
30 *
31 * Just derive your custom preview widget from KPreviewWidgetBase and implement
32 * all the pure virtual methods. The slot showPreview(const QUrl &) is called
33 * every time the file selection changes.
34 */
35class KIOFILEWIDGETS_EXPORT KPreviewWidgetBase : public QWidget
36{
37 Q_OBJECT
38
39public:
40 /*!
41 * Constructor. Construct the user interface of your preview widget here
42 * and pass the KFileDialog this preview widget is going to be used in as
43 * the parent.
44 *
45 * \a parent The KFileDialog this preview widget is going to be used in
46 */
47 explicit KPreviewWidgetBase(QWidget *parent);
48 ~KPreviewWidgetBase() override;
49
50 /*!
51 *
52 */
53 QStringList supportedMimeTypes() const;
54
55public Q_SLOTS:
56 /*!
57 * This slot is called every time the user selects another file in the
58 * file dialog. Implement the stuff necessary to reflect the change here.
59 *
60 * \a url The URL of the currently selected file.
61 */
62 virtual void showPreview(const QUrl &url) = 0;
63
64 /*!
65 * Reimplement this to clear the preview. This is called when e.g. the
66 * selection is cleared or when multiple selections exist, or the directory
67 * is changed.
68 */
69 virtual void clearPreview() = 0;
70
71protected:
72 /*!
73 *
74 */
75 void setSupportedMimeTypes(const QStringList &mimeTypes);
76
77private:
78 class KPreviewWidgetBasePrivate;
79 std::unique_ptr<KPreviewWidgetBasePrivate> const d;
80
81 Q_DISABLE_COPY(KPreviewWidgetBase)
82};
83
84#endif
85

source code of kio/src/filewidgets/kpreviewwidgetbase.h