1/*
2 *
3 * This file is part of the KDE project.
4 * Copyright (C) 2001 Martin R. Jones <mjones@kde.org>
5 * 2001 Carsten Pfeiffer <pfeiffer@kde.org>
6 * 2008 Rafael Fernández López <ereslibre@kde.org>
7 *
8 * You can Freely distribute this program under the GNU Library General Public
9 * License. See the file "COPYING" for the exact licensing terms.
10 */
11
12#ifndef KIMAGEFILEPREVIEW_H
13#define KIMAGEFILEPREVIEW_H
14
15#include <QtGui/QPixmap>
16
17#include <kurl.h>
18#include <kpreviewwidgetbase.h>
19
20class KFileItem;
21class KJob;
22namespace KIO { class PreviewJob; }
23
24/**
25 * Image preview widget for the file dialog.
26 */
27class KIO_EXPORT KImageFilePreview : public KPreviewWidgetBase
28{
29 Q_OBJECT
30
31 public:
32 /**
33 * Creates a new image file preview.
34 *
35 * @param parent The parent widget.
36 */
37 explicit KImageFilePreview(QWidget *parent = 0);
38
39 /**
40 * Destroys the image file preview.
41 */
42 ~KImageFilePreview();
43
44 /**
45 * Returns the size hint for this widget.
46 */
47 virtual QSize sizeHint() const;
48
49 public Q_SLOTS:
50 /**
51 * Shows a preview for the given @p url.
52 */
53 virtual void showPreview(const KUrl &url);
54
55 /**
56 * Clears the preview.
57 */
58 virtual void clearPreview();
59
60 protected Q_SLOTS:
61 void showPreview();
62 void showPreview( const KUrl& url, bool force );
63
64 virtual void gotPreview( const KFileItem&, const QPixmap& );
65
66 protected:
67 virtual void resizeEvent( QResizeEvent *event );
68 virtual KIO::PreviewJob * createJob( const KUrl& url, int width, int height );
69
70 private:
71 class KImageFilePreviewPrivate;
72 KImageFilePreviewPrivate *const d;
73
74 Q_DISABLE_COPY(KImageFilePreview)
75
76 Q_PRIVATE_SLOT( d, void _k_slotResult( KJob* ) )
77 Q_PRIVATE_SLOT( d, void _k_slotFailed( const KFileItem& ) )
78 Q_PRIVATE_SLOT( d, void _k_slotStepAnimation( int frame ) )
79 Q_PRIVATE_SLOT( d, void _k_slotFinished( ) )
80};
81
82#endif // KIMAGEFILEPREVIEW_H
83