KIO

kfilepreviewgenerator.h
1/*
2 SPDX-FileCopyrightText: 2008-2009 Peter Penz <peter.penz@gmx.at>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KFILEPREVIEWGENERATOR_H
8#define KFILEPREVIEWGENERATOR_H
9
10#include "kiofilewidgets_export.h"
11
12#include <QObject>
13
14#include <memory>
15
17class KDirModel;
20
21class KFilePreviewGeneratorPrivate;
22
23/**
24 * @class KFilePreviewGenerator kfilepreviewgenerator.h <KFilePreviewGenerator>
25 *
26 * @brief Generates previews for files of an item view.
27 *
28 * Per default a preview is generated for each item.
29 * Additionally the clipboard is checked for cut items.
30 * The icon state for cut items gets dimmed automatically.
31 *
32 * The following strategy is used when creating previews:
33 * - The previews for currently visible items are created before
34 * the previews for invisible items.
35 * - If the user changes the visible area by using the scrollbars,
36 * all pending previews get paused. As soon as the user stays
37 * on the same position for a short delay, the previews are
38 * resumed. Also in this case the previews for the visible items
39 * are generated first.
40 *
41 */
42class KIOFILEWIDGETS_EXPORT KFilePreviewGenerator : public QObject
43{
44 Q_OBJECT
45
46public:
47 /**
48 * @param parent Item view containing the file items where previews should
49 * be generated. It is mandatory that the item view specifies
50 * an icon size by QAbstractItemView::setIconSize() and that
51 * the model of the view (or the source model of the proxy model)
52 * is an instance of KDirModel. Otherwise no previews will be generated.
53 */
55
56 /** @internal */
58
59 ~KFilePreviewGenerator() override;
60
61 /**
62 * If \a show is set to true, a preview is generated for each item. If \a show
63 * is false, the MIME type icon of the item is shown instead. Per default showing
64 * the preview is turned on. Note that it is mandatory that the item view
65 * specifies an icon size by QAbstractItemView::setIconSize(), otherwise
66 * KFilePreviewGenerator::isPreviewShown() will always return false.
67 */
68 void setPreviewShown(bool show);
69 bool isPreviewShown() const;
70
71 /**
72 * Sets the list of enabled thumbnail plugins.
73 * Per default all plugins enabled in the KConfigGroup "PreviewSettings"
74 * are used.
75 *
76 * Note that this method doesn't cause already generated previews
77 * to be regenerated.
78 *
79 * For a list of available plugins, call KIO::PreviewJob::availableThumbnailerPlugins().
80 *
81 * @see enabledPlugins
82 */
83 void setEnabledPlugins(const QStringList &list);
84
85 /**
86 * Returns the list of enabled thumbnail plugins.
87 * @see setEnabledPlugins
88 */
89 QStringList enabledPlugins() const;
90
91public Q_SLOTS:
92 /**
93 * Updates the icons for all items. Usually it is only
94 * necessary to invoke this method when the icon size of the abstract item view
95 * has been changed by QAbstractItemView::setIconSize(). Note that this method
96 * should also be invoked if previews have been turned off, as the icons for
97 * cut items must be updated when the icon size has changed.
98 */
99 void updateIcons();
100
101 /** Cancels all pending previews. */
102 void cancelPreviews();
103
104private:
105 friend class KFilePreviewGeneratorPrivate;
106 std::unique_ptr<KFilePreviewGeneratorPrivate> const d;
107
108 Q_DISABLE_COPY(KFilePreviewGenerator)
109
110 Q_PRIVATE_SLOT(d, void pauseIconUpdates())
111};
112
113#endif
Interface used by KFilePreviewGenerator to generate previews for files.
A model for a KIO-based directory tree.
Definition kdirmodel.h:42
Generates previews for files of an item view.
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:52 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.