1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QQMLPROPERTYMAP_H
5#define QQMLPROPERTYMAP_H
6
7#include <QtQml/qtqmlglobal.h>
8
9#include <QtCore/QObject>
10#include <QtCore/QHash>
11#include <QtCore/QStringList>
12#include <QtCore/QVariant>
13
14QT_BEGIN_NAMESPACE
15
16
17class QQmlPropertyMapPrivate;
18class Q_QML_EXPORT QQmlPropertyMap : public QObject
19{
20 Q_OBJECT
21public:
22 explicit QQmlPropertyMap(QObject *parent = nullptr);
23 ~QQmlPropertyMap() override;
24
25 QVariant value(const QString &key) const;
26 void insert(const QString &key, const QVariant &value);
27 void insert(const QVariantHash &values);
28 void clear(const QString &key);
29 void freeze();
30
31 Q_INVOKABLE QStringList keys() const;
32
33 int count() const;
34 int size() const;
35 bool isEmpty() const;
36 bool contains(const QString &key) const;
37
38 QVariant &operator[](const QString &key);
39 QVariant operator[](const QString &key) const;
40
41Q_SIGNALS:
42 void valueChanged(const QString &key, const QVariant &value);
43
44protected:
45 virtual QVariant updateValue(const QString &key, const QVariant &input);
46
47 template<class DerivedType>
48 QQmlPropertyMap(DerivedType *derived, QObject *parentObj)
49 : QQmlPropertyMap(&DerivedType::staticMetaObject, parentObj)
50 {
51 Q_UNUSED(derived);
52 }
53
54private:
55 QQmlPropertyMap(const QMetaObject *staticMetaObject, QObject *parent);
56
57 Q_DECLARE_PRIVATE(QQmlPropertyMap)
58 Q_DISABLE_COPY(QQmlPropertyMap)
59};
60
61QT_END_NAMESPACE
62
63#endif
64

source code of qtdeclarative/src/qml/util/qqmlpropertymap.h