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 ~QQmlTreeRow();
40
41 QQmlTreeRow *parent() const { return m_parent; }
42 void setParent(QQmlTreeRow *parent) { m_parent = parent; }
43
44 const QQmlTreeRow *getRow(int i) const { return m_children[i].get(); }
45 void addChild(QQmlTreeRow *child);
46 void insertChild(int index, std::unique_ptr<QQmlTreeRow> child);
47 size_t rowCount() const { return m_children.size(); }
48 int subTreeSize() const;
49
50 QVariantMap data() const { return dataMap; }
51 QVariant data(const QString &key) const { return dataMap[key]; }
52 const std::vector<std::unique_ptr<QQmlTreeRow>>& children() const { return m_children; }
53 void removeChild(std::vector<std::unique_ptr<QQmlTreeRow>>::const_iterator &child);
54 void removeChildAt(int i);
56 void setData(const QVariant &data);
57 void setData(const QVariantMap &data);
58 void setField(const QString &key, const QVariant &value);
59 QVariant toVariant() const;
60private:
61 void unpackVariantMap(const QVariantMap &dataMap);
62
63 QQmlTreeRow *m_parent;
64 std::vector<std::unique_ptr<QQmlTreeRow>> m_children;
65 QVariantMap dataMap;
66};
67
68QT_END_NAMESPACE
69
70#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