File indexing completed on 2024-09-08 03:39:05
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 QStringList supportedMimeTypes() const; 0051 0052 public Q_SLOTS: 0053 /** 0054 * This slot is called every time the user selects another file in the 0055 * file dialog. Implement the stuff necessary to reflect the change here. 0056 * 0057 * @param url The URL of the currently selected file. 0058 */ 0059 virtual void showPreview(const QUrl &url) = 0; 0060 0061 /** 0062 * Reimplement this to clear the preview. This is called when e.g. the 0063 * selection is cleared or when multiple selections exist, or the directory 0064 * is changed. 0065 */ 0066 virtual void clearPreview() = 0; 0067 0068 protected: 0069 void setSupportedMimeTypes(const QStringList &mimeTypes); 0070 0071 private: 0072 class KPreviewWidgetBasePrivate; 0073 std::unique_ptr<KPreviewWidgetBasePrivate> const d; 0074 0075 Q_DISABLE_COPY(KPreviewWidgetBase) 0076 }; 0077 0078 #endif