KIO

kabstractviewadapter.h
1/*
2 SPDX-FileCopyrightText: 2008 Fredrik Höglund <fredrik@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KABSTRACTVIEWADAPTER_H
8#define KABSTRACTVIEWADAPTER_H
9
10#include "kiofilewidgets_export.h"
11#include <QObject>
12
14class QModelIndex;
15class QPalette;
16class QRect;
17class QSize;
18
19/*
20 * TODO KF6 Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged)
21 * TODO KF6 virtual void setIconSize(const QSize &size);
22 * TODO KF6 iconSizeChanged();
23 *
24 * TODO KF6:
25 * KAbstractViewAdapter exists to allow KFilePreviewGenerator to be
26 * reused with new kinds of views. Unfortunately it doesn't cover
27 * all use cases that would be useful right now, in particular there
28 * are no change notifications for the properties it has getters for.
29 * This requires view implementations to e.g. call updateIcons() on
30 * the generator when the icon size changes, which means updating two
31 * entities (the generator and the adapter) instead of only one.
32 * In KF6 we should make iconSize a Q_PROPERTY with a virtual setter
33 * and a change notification signal, and make KFilePreviewGenerator
34 * listen to that signal.
35 * A related problem is that while the adapter is supposed to inter-
36 * face a view to the generator, it is sometimes the generator that
37 * is responsible for instantiating the adapter: KDirOperator in this
38 * framework uses the KFilePreviewGenerator constructor that doesn't
39 * take an adapter instance, which makes the generator instantiate a
40 * KIO::DefaultViewAdapter internally, which it doesn't expose to the
41 * outside. That means even when a setIconSize() is added,
42 * KDirOperator won't be able to call it on the adapter. This mis-
43 * design needs to be addressed as well so all change notifications
44 * can run through the adapter, also for the DefaultViewAdapter
45 * implementation (though for this specific example, perhaps Qt will
46 * one day give us a NOTIFY for QAbstractItemView::iconSize that the
47 * DefaultViewAdapter can use, obviating the need for KDirOperator
48 * to do anything except call setIconSize on its QAbstractItemView).
49 */
50
51/**
52 * @class KAbstractViewAdapter kabstractviewadapter.h <KAbstractViewAdapter>
53 *
54 * Interface used by KFilePreviewGenerator to generate previews
55 * for files. The interface allows KFilePreviewGenerator to be
56 * independent from the view implementation.
57 */
58class KIOFILEWIDGETS_EXPORT KAbstractViewAdapter : public QObject
59{
60public:
61 enum Signal {
62 ScrollBarValueChanged,
63 IconSizeChanged
64 };
65
67 : QObject(parent)
68 {
69 }
70 ~KAbstractViewAdapter() override
71 {
72 }
73 virtual QAbstractItemModel *model() const = 0;
74 virtual QSize iconSize() const = 0;
75 virtual QPalette palette() const = 0;
76 virtual QRect visibleArea() const = 0;
77 virtual QRect visualRect(const QModelIndex &index) const = 0;
78
79 // TODO KF6 make this connect work with a PointerToMemberFunction/Functor
80 virtual void connect(Signal signal, QObject *receiver, const char *slot) = 0;
81};
82
83#endif
Interface used by KFilePreviewGenerator to generate previews for files.
QObject(QObject *parent)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:58:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.