dde-control-center
Deepin Control Center
载入中...
搜索中...
未找到
dccrepeater.h
1// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#ifndef DCCREPEATER_H
6#define DCCREPEATER_H
7
8#include <QObject>
9#include <QQmlComponent>
10
11class QQmlChangeSet;
12
13namespace dccV25 {
14class DccRepeaterPrivate;
15class DccRepeater : public QObject
16{
17 Q_OBJECT
18public:
19 Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged FINAL)
20 Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL)
21 Q_PROPERTY(int count READ count NOTIFY countChanged FINAL)
22
23 explicit DccRepeater(QObject *parent = nullptr);
24 ~DccRepeater() override;
25
26 QVariant model() const;
27 void setModel(const QVariant &newModel);
28
29 QQmlComponent *delegate() const;
30 void setDelegate(QQmlComponent *newDelegate);
31
32 int count() const;
33
34 Q_INVOKABLE void resetModel();
35
36Q_SIGNALS:
37 void modelChanged();
38 void delegateChanged();
39 void countChanged();
40
41 void objAdded(int index, QObject *obj);
42 void objRemoved(int index, QObject *obj);
43
44private Q_SLOTS:
45 void createdItem(int index, QObject *item);
46 void initItem(int index, QObject *item);
47 void modelUpdated(const QQmlChangeSet &changeSet, bool reset);
48
49protected:
50 void regenerate();
51 void clear();
52
53private:
54 QScopedPointer<DccRepeaterPrivate> d_ptr;
55 Q_DECLARE_PRIVATE_D(qGetPtrHelper(d_ptr), DccRepeater)
56};
57} // namespace dccV25
58#endif // DCCREPEATER_H
Definition dccrepeater.h:16