KIO

kpreviewwidgetbase.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 2001 Frerich Raabe <[email protected]>
4  SPDX-FileCopyrightText: 2003 Carsten Pfeiffer <[email protected]>
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 
18 class 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 <[email protected]>
34  */
35 class KIOFILEWIDGETS_EXPORT KPreviewWidgetBase : public QWidget
36 {
37  Q_OBJECT
38 
39 public:
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 public Q_SLOTS:
51  /**
52  * This slot is called every time the user selects another file in the
53  * file dialog. Implement the stuff necessary to reflect the change here.
54  *
55  * @param url The URL of the currently selected file.
56  */
57  virtual void showPreview(const QUrl &url) = 0;
58 
59  /**
60  * Reimplement this to clear the preview. This is called when e.g. the
61  * selection is cleared or when multiple selections exist, or the directory
62  * is changed.
63  */
64  virtual void clearPreview() = 0;
65 
66  // TODO KF6: make it a public method, it's not a slot
67  QStringList supportedMimeTypes() const; // clazy:exclude=const-signal-or-slot
68 
69 protected:
70  void setSupportedMimeTypes(const QStringList &mimeTypes);
71 
72 private:
73  class KPreviewWidgetBasePrivate;
74  std::unique_ptr<KPreviewWidgetBasePrivate> const d;
75 
77 };
78 
79 #endif
Abstract baseclass for all preview widgets.
Q_SLOTSQ_SLOTS
Q_DISABLE_COPY(Class)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Feb 7 2023 04:00:36 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.