1 | /* This file is part of the KDE libraries |
2 | * Copyright (C) 2001 Frerich Raabe <raabe@kde.org> |
3 | * 2003 Carsten Pfeiffer <pfeiffer@kde.org> |
4 | * |
5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Library General Public |
7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. |
9 | * |
10 | * This library is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU Library General Public License |
16 | * along with this library; see the file COPYING.LIB. If not, write to |
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
18 | * Boston, MA 02110-1301, USA. |
19 | */ |
20 | |
21 | #ifndef __KPREVIEWWIDGETBASE_H__ |
22 | #define __KPREVIEWWIDGETBASE_H__ |
23 | |
24 | #include <QtGui/QWidget> |
25 | |
26 | #include <kio/kio_export.h> |
27 | |
28 | class KUrl; |
29 | |
30 | /** |
31 | * Abstract baseclass for all preview widgets which shall be used via |
32 | * KFileDialog::setPreviewWidget(const KPreviewWidgetBase *). |
33 | * Ownership will be transferred to KFileDialog, so you have to create |
34 | * the preview with "new" and let KFileDialog delete it. |
35 | * |
36 | * Just derive your custom preview widget from KPreviewWidgetBase and implement |
37 | * all the pure virtual methods. The slot showPreview(const KUrl &) is called |
38 | * every time the file selection changes. |
39 | * |
40 | * @short Abstract baseclass for all preview widgets. |
41 | * @author Frerich Raabe <raabe@kde.org> |
42 | */ |
43 | class KIO_EXPORT KPreviewWidgetBase : public QWidget |
44 | { |
45 | Q_OBJECT |
46 | |
47 | public: |
48 | /** |
49 | * Constructor. Construct the user interface of your preview widget here |
50 | * and pass the KFileDialog this preview widget is going to be used in as |
51 | * the parent. |
52 | * |
53 | * @param parent The KFileDialog this preview widget is going to be used in |
54 | */ |
55 | KPreviewWidgetBase(QWidget *parent); |
56 | ~KPreviewWidgetBase(); |
57 | |
58 | public Q_SLOTS: |
59 | /** |
60 | * This slot is called every time the user selects another file in the |
61 | * file dialog. Implement the stuff necessary to reflect the change here. |
62 | * |
63 | * @param url The URL of the currently selected file. |
64 | */ |
65 | virtual void showPreview(const KUrl &url) = 0; |
66 | |
67 | /** |
68 | * Reimplement this to clear the preview. This is called when e.g. the |
69 | * selection is cleared or when multiple selections exist, or the directory |
70 | * is changed. |
71 | */ |
72 | virtual void clearPreview() = 0; |
73 | |
74 | QStringList supportedMimeTypes() const; |
75 | |
76 | protected: |
77 | void setSupportedMimeTypes( const QStringList& mimeTypes ); |
78 | |
79 | private: |
80 | class KPreviewWidgetBasePrivate; |
81 | KPreviewWidgetBasePrivate *const d; |
82 | |
83 | Q_DISABLE_COPY(KPreviewWidgetBase) |
84 | }; |
85 | |
86 | #endif |
87 | |