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 QTREEWIDGETITEMITERATOR_P_H
5#define QTREEWIDGETITEMITERATOR_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 <QtCore/qstack.h>
19
20#include "qtreewidgetitemiterator.h"
21#include "private/qglobal_p.h"
22#if QT_CONFIG(treewidget)
23
24QT_BEGIN_NAMESPACE
25
26class QTreeModel;
27class QTreeWidgetItem;
28
29class QTreeWidgetItemIteratorPrivate {
30 Q_DECLARE_PUBLIC(QTreeWidgetItemIterator)
31public:
32 QTreeWidgetItemIteratorPrivate(QTreeWidgetItemIterator *q, QTreeModel *model)
33 : m_currentIndex(0), m_model(model), q_ptr(q)
34 {
35
36 }
37
38 QTreeWidgetItemIteratorPrivate(const QTreeWidgetItemIteratorPrivate& other)
39 : m_currentIndex(other.m_currentIndex), m_model(other.m_model),
40 m_parentIndex(other.m_parentIndex), q_ptr(other.q_ptr)
41 {
42
43 }
44
45 QTreeWidgetItemIteratorPrivate &operator=(const QTreeWidgetItemIteratorPrivate& other)
46 {
47 m_currentIndex = other.m_currentIndex;
48 m_parentIndex = other.m_parentIndex;
49 m_model = other.m_model;
50 return (*this);
51 }
52
53 ~QTreeWidgetItemIteratorPrivate()
54 {
55 }
56
57 QTreeWidgetItem* nextSibling(const QTreeWidgetItem* item) const;
58 void ensureValidIterator(const QTreeWidgetItem *itemToBeRemoved);
59
60 QTreeWidgetItem *next(const QTreeWidgetItem *current);
61 QTreeWidgetItem *previous(const QTreeWidgetItem *current);
62private:
63 int m_currentIndex;
64 QTreeModel *m_model; // This iterator class should not have ownership of the model.
65 QStack<int> m_parentIndex;
66 QTreeWidgetItemIterator *q_ptr;
67};
68
69QT_END_NAMESPACE
70
71#endif // QT_CONFIG(treewidget)
72
73#endif //QTREEWIDGETITEMITERATOR_P_H
74

source code of qtbase/src/widgets/itemviews/qtreewidgetitemiterator_p.h