]>
cloud.milkyroute.net Git - dolphin.git/blob - src/kfilepreviewgenerator.h
1 /***************************************************************************
2 * Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #ifndef KFILEPREVIEWGENERATOR_H
21 #define KFILEPREVIEWGENERATOR_H
26 class KDirSortFilterProxyModel
;
27 class QAbstractItemView
;
30 * @brief Generates previews for files of an item view.
32 * Per default a preview is generated for each item.
33 * Additionally the clipboard is checked for cut items.
34 * The icon state for cut items gets dimmed automatically.
36 * The following strategy is used when creating previews:
37 * - The previews for currently visible items are created before
38 * the previews for invisible items.
39 * - If the user changes the visible area by using the scrollbars,
40 * all pending previews get paused. As soon as the user stays
41 * on the same position for a short delay, the previews are
42 * resumed. Also in this case the previews for the visible items
43 * are generated first.
45 class KFilePreviewGenerator
: public QObject
51 * @param parent Item view containing the file items where previews should
52 * be generated. It is mandatory that the item view specifies
53 * an icon size by QAbstractItemView::setIconSize(), otherwise
54 * no previews will be generated.
55 * @param model Model of the item view.
57 KFilePreviewGenerator(QAbstractItemView
* parent
, KDirSortFilterProxyModel
* model
);
58 virtual ~KFilePreviewGenerator();
61 * If \a show is set to true, a preview is generated for each item. If \a show
62 * is false, the MIME type icon of the item is shown instead. Per default showing
63 * of the preview is turned on. Note that it is mandatory that the item view
64 * specifies an icon size by QAbstractItemView::setIconSize(), otherwise
65 * KFilePreviewGenerator::showPreview() will always return false.
67 void setShowPreview(bool show
);
68 bool showPreview() const;
71 * Updates the previews for all already available items. Usually It is only
72 * necessary to invoke this method when the icon size of the abstract item view
73 * has been changed by QAbstractItemView::setIconSize().
75 void updatePreviews();
77 /** Cancels all pending previews. */
78 void cancelPreviews();
82 Private
* const d
; /// @internal
83 Q_DISABLE_COPY(KFilePreviewGenerator
)
85 Q_PRIVATE_SLOT(d
, void generatePreviews(const KFileItemList
&))
86 Q_PRIVATE_SLOT(d
, void addToPreviewQueue(const KFileItem
&, const QPixmap
&))
87 Q_PRIVATE_SLOT(d
, void slotPreviewJobFinished(KJob
*))
88 Q_PRIVATE_SLOT(d
, void updateCutItems())
89 Q_PRIVATE_SLOT(d
, void dispatchPreviewQueue())
90 Q_PRIVATE_SLOT(d
, void pausePreviews())
91 Q_PRIVATE_SLOT(d
, void resumePreviews())