KIO

kpreviewwidgetbase.h
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 kpreviewwidgetbase.h <KPreviewWidgetBase>
22 *
23 * Abstract baseclass for all preview widgets which shall be used via
24 * KFileDialog::setPreviewWidget(const KPreviewWidgetBase *).
25 * Ownership will be transferred to KFileDialog, so you have to create
26 * the preview with "new" and let KFileDialog delete it.
27 *
28 * Just derive your custom preview widget from KPreviewWidgetBase and implement
29 * all the pure virtual methods. The slot showPreview(const QUrl &) is called
30 * every time the file selection changes.
31 *
32 * @short Abstract baseclass for all preview widgets.
33 * @author Frerich Raabe <raabe@kde.org>
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 * @param parent The KFileDialog this preview widget is going to be used in
46 */
47 explicit KPreviewWidgetBase(QWidget *parent);
48 ~KPreviewWidgetBase() override;
49
50 QStringList supportedMimeTypes() const;
51
52public Q_SLOTS:
53 /**
54 * This slot is called every time the user selects another file in the
55 * file dialog. Implement the stuff necessary to reflect the change here.
56 *
57 * @param url The URL of the currently selected file.
58 */
59 virtual void showPreview(const QUrl &url) = 0;
60
61 /**
62 * Reimplement this to clear the preview. This is called when e.g. the
63 * selection is cleared or when multiple selections exist, or the directory
64 * is changed.
65 */
66 virtual void clearPreview() = 0;
67
68protected:
69 void setSupportedMimeTypes(const QStringList &mimeTypes);
70
71private:
72 class KPreviewWidgetBasePrivate;
73 std::unique_ptr<KPreviewWidgetBasePrivate> const d;
74
75 Q_DISABLE_COPY(KPreviewWidgetBase)
76};
77
78#endif
Abstract baseclass for all preview widgets which shall be used via KFileDialog::setPreviewWidget(cons...
virtual void showPreview(const QUrl &url)=0
This slot is called every time the user selects another file in the file dialog.
virtual void clearPreview()=0
Reimplement this to clear the preview.
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:28 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.