Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmltreerow_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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 QQMLTREEROW_P_H
5#define QQMLTREEROW_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQmlModels/private/qtqmlmodelsglobal_p.h>
19
20#include <QtCore/qmap.h>
21#include <QtCore/qvariant.h>
22
23#include <memory>
24#include <vector>
25
27
28QT_BEGIN_NAMESPACE
29
30using namespace Qt::StringLiterals;
31static constexpr QLatin1StringView ROWS_PROPERTY_NAME = "rows"_L1;
32
34{
35public:
36 explicit QQmlTreeRow(QQmlTreeRow *parentItem = nullptr);
37 explicit QQmlTreeRow(const QVariant &data, QQmlTreeRow *parentItem = nullptr);
38 explicit QQmlTreeRow(const QVariantMap &data, QQmlTreeRow *parentItem = nullptr);
39
40 QQmlTreeRow *parent() const { return m_parent; }
41 void setParent(QQmlTreeRow *parent) { m_parent = parent; }
42
43 const QQmlTreeRow *getRow(int i) const { return m_children[i].get(); }
44 void addChild(QQmlTreeRow *child);
45 void insertChild(int index, std::unique_ptr<QQmlTreeRow> child);
46 size_t rowCount() const { return m_children.size(); }
47 int subTreeSize() const;
48
49 QVariantMap data() const { return dataMap; }
50 QVariant data(const QString &key) const { return dataMap[key]; }
51 const std::vector<std::unique_ptr<QQmlTreeRow>>& children() const { return m_children; }
52 void removeChild(std::vector<std::unique_ptr<QQmlTreeRow>>::const_iterator &child);
53 void removeChildAt(int i);
55 void setData(const QVariant &data);
56 void setData(const QVariantMap &data);
57 void setField(const QString &key, const QVariant &value);
58 QVariant toVariant() const;
59private:
60 void unpackVariantMap(const QVariantMap &dataMap);
61
62 QQmlTreeRow *m_parent;
63 std::vector<std::unique_ptr<QQmlTreeRow>> m_children;
64 QVariantMap dataMap;
65};
66
67QT_END_NAMESPACE
68
69#endif // QQMLTREEROW_P_H
void addChild(QQmlTreeRow *child)
QVariant toVariant() const
std::unique_ptr< QQmlTreeRow > takeChild(int i)
const std::vector< std::unique_ptr< QQmlTreeRow > > & children() const
QVariantMap data() const
QQmlTreeRow * parent() const
void setData(const QVariant &data)
void setParent(QQmlTreeRow *parent)
void setField(const QString &key, const QVariant &value)
void removeChild(std::vector< std::unique_ptr< QQmlTreeRow > >::const_iterator &child)
QQmlTreeRow(QQmlTreeRow *parentItem=nullptr)
int subTreeSize() const
size_t rowCount() const
QQmlTreeRow(const QVariant &data, QQmlTreeRow *parentItem=nullptr)
const QQmlTreeRow * getRow(int i) const
void insertChild(int index, std::unique_ptr< QQmlTreeRow > child)
QVariant data(const QString &key) const
void removeChildAt(int i)
Combined button and popup list for selecting options.
QT_REQUIRE_CONFIG(animation)
QT_REQUIRE_CONFIG(qml_tree_model)
static constexpr QLatin1StringView ROWS_PROPERTY_NAME