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 { ScrollBarValueChanged, IconSizeChanged };
62
64 : QObject(parent)
65 {
66 }
67 ~KAbstractViewAdapter() override
68 {
69 }
70 virtual QAbstractItemModel *model() const = 0;
71 virtual QSize iconSize() const = 0;
72 virtual QPalette palette() const = 0;
73 virtual QRect visibleArea() const = 0;
74 virtual QRect visualRect(const QModelIndex &index) const = 0;
75
76 // TODO KF6 make this connect work with a PointerToMemberFunction/Functor
77 virtual void connect(Signal signal, QObject *receiver, const char *slot) = 0;
78};
79
80#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 Fri May 24 2024 11:56:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.