DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dobjectmodelproxy_p.h
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#pragma once
6
7#include <dtkdeclarative_global.h>
8
9#include <QJsonValue>
10#include <private/qqmlobjectmodel_p.h>
11
12DQUICK_BEGIN_NAMESPACE
13
14class ObjectModelProxyPrivate;
15class ObjectModelProxy : public QQmlInstanceModel
16{
17 Q_OBJECT
18 Q_PROPERTY(QQmlObjectModel *sourceModel READ sourceModel WRITE setSourceModel)
19 Q_PROPERTY(QJSValue filterAcceptsItem READ filterAcceptsItem WRITE setFilterAcceptsItem NOTIFY filterAcceptsItemChanged)
20#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
21 QML_NAMED_ELEMENT(ObjectModelProxy)
22#endif
23public:
24 explicit ObjectModelProxy(QObject *parent = nullptr);
25
26public:
27 bool isValid() const override;
28 virtual QObject *object(int index, QQmlIncubator::IncubationMode incubationMode) override;
29 virtual int count() const override;
30#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
31 virtual QVariant variantValue(int index, const QString &name) override;
32 virtual ReleaseFlags release(QObject *object, ReusableFlag reusableFlag = NotReusable) override;
33#else
34 virtual QString stringValue(int index, const QString &name) override;
35 virtual ReleaseFlags release(QObject *object) override;
36#endif
37 virtual void setWatchedRoles(const QList<QByteArray> &roles) override;
38 virtual QQmlIncubator::Status incubationStatus(int index) override;
39 virtual int indexOf(QObject *object, QObject *objectContext) const override;
40
41 QQmlObjectModel *sourceModel() const;
42 void setSourceModel(QQmlObjectModel * sourceModel);
43 QJSValue filterAcceptsItem() const;
44 void setFilterAcceptsItem(QJSValue filterAcceptsItem);
45
46public Q_SLOTS:
47 void update();
48 QObject *get(const int i) const;
49 int mapToSource(const int i) const;
50 int mapFromSource(const int i) const;
51
52private Q_SLOTS:
53 void syncDataFromItem();
54
55Q_SIGNALS:
56 void filterAcceptsItemChanged();
57
58private:
59 Q_DECLARE_PRIVATE(ObjectModelProxy)
60};
61
62DQUICK_END_NAMESPACE
Definition dobjectmodelproxy_p.h:16