File indexing completed on 2025-01-26 05:06:21

0001 /*
0002     SPDX-FileCopyrightText: 2014 Eike Hein <hein@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QRect>
0010 
0011 #include <KAbstractViewAdapter>
0012 
0013 class ItemViewAdapter : public KAbstractViewAdapter
0014 {
0015     Q_OBJECT
0016 
0017     Q_PROPERTY(QObject *adapterView READ adapterView WRITE setAdapterView NOTIFY adapterViewChanged)
0018     Q_PROPERTY(QAbstractItemModel *adapterModel READ adapterModel WRITE setAdapterModel NOTIFY adapterModelChanged)
0019     Q_PROPERTY(int adapterIconSize READ adapterIconSize WRITE setAdapterIconSize NOTIFY adapterIconSizeChanged)
0020     Q_PROPERTY(QRect adapterVisibleArea READ adapterVisibleArea WRITE setAdapterVisibleArea NOTIFY adapterVisibleAreaChanged)
0021 
0022 public:
0023     explicit ItemViewAdapter(QObject *parent = nullptr);
0024 
0025     QAbstractItemModel *model() const override;
0026     QSize iconSize() const override;
0027     QPalette palette() const override;
0028     QRect visibleArea() const override;
0029     QRect visualRect(const QModelIndex &index) const override;
0030     void connect(Signal signal, QObject *receiver, const char *slot) override;
0031 
0032     QObject *adapterView() const;
0033     void setAdapterView(QObject *view);
0034 
0035     QAbstractItemModel *adapterModel() const;
0036     void setAdapterModel(QAbstractItemModel *model);
0037 
0038     int adapterIconSize() const;
0039     void setAdapterIconSize(int size);
0040 
0041     QRect adapterVisibleArea() const;
0042     void setAdapterVisibleArea(QRect rect);
0043 
0044 Q_SIGNALS:
0045     void viewScrolled() const;
0046     void adapterViewChanged() const;
0047     void adapterModelChanged() const;
0048     void adapterIconSizeChanged() const;
0049     void adapterVisibleAreaChanged() const;
0050 
0051 private:
0052     QObject *m_adapterView;
0053     QAbstractItemModel *m_adapterModel;
0054     int m_adapterIconSize;
0055     QRect m_adapterVisibleArea;
0056 };