aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktreeview_p.h
blob: b499f900cdc4d7b9606995d730b3762cbbc74fe4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QQUICKTREEVIEW_P_H
#define QQUICKTREEVIEW_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include <QtCore/qabstractitemmodel.h>
#include "qquicktableview_p.h"

QT_BEGIN_NAMESPACE

class QQuickTreeViewPrivate;

class Q_QUICK_PRIVATE_EXPORT QQuickTreeView : public QQuickTableView
{
    Q_OBJECT
    QML_NAMED_ELEMENT(TreeView)
    QML_ADDED_IN_VERSION(6, 3)

public:
    QQuickTreeView(QQuickItem *parent = nullptr);
    ~QQuickTreeView() override;

    Q_INVOKABLE int depth(int row) const;

    Q_INVOKABLE bool isExpanded(int row) const;
    Q_INVOKABLE void expand(int row);
    Q_INVOKABLE void collapse(int row);
    Q_INVOKABLE void toggleExpanded(int row);

    Q_REVISION(6, 4) Q_INVOKABLE void expandRecursively(int row = -1, int depth = -1);
    Q_REVISION(6, 4) Q_INVOKABLE void collapseRecursively(int row = -1);
    Q_REVISION(6, 4) Q_INVOKABLE void expandToIndex(const QModelIndex &index);

    Q_INVOKABLE QModelIndex modelIndex(const QPoint &cell) const override;
    Q_INVOKABLE QModelIndex modelIndex(int row, int column) const override;
    Q_INVOKABLE QPoint cellAtIndex(const QModelIndex &index) const override;

Q_SIGNALS:
    void expanded(int row, int depth);
    void collapsed(int row, bool recursively);

protected:
    void keyPressEvent(QKeyEvent *event) override;

private:
    Q_DISABLE_COPY(QQuickTreeView)
    Q_DECLARE_PRIVATE(QQuickTreeView)
};

QT_END_NAMESPACE

QML_DECLARE_TYPE(QQuickTreeView)

#endif // QQUICKTREEVIEW_P_H