| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** Contact: Qt Software Information ([email protected])
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 7 | **
|
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 9 | ** Commercial Usage
|
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 13 | ** a written agreement between you and Nokia.
|
|---|
| 14 | **
|
|---|
| 15 | ** GNU Lesser General Public License Usage
|
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 19 | ** packaging of this file. Please review the following information to
|
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 22 | **
|
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain
|
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL
|
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|---|
| 26 | ** package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please
|
|---|
| 37 | ** contact the sales department at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef QTREEWIDGETITEMITERATOR_H
|
|---|
| 43 | #define QTREEWIDGETITEMITERATOR_H
|
|---|
| 44 |
|
|---|
| 45 | #include <QtCore/qglobal.h>
|
|---|
| 46 |
|
|---|
| 47 | QT_BEGIN_HEADER
|
|---|
| 48 |
|
|---|
| 49 | QT_BEGIN_NAMESPACE
|
|---|
| 50 |
|
|---|
| 51 | QT_MODULE(Gui)
|
|---|
| 52 |
|
|---|
| 53 | #ifndef QT_NO_TREEWIDGET
|
|---|
| 54 |
|
|---|
| 55 | class QTreeWidget;
|
|---|
| 56 | class QTreeWidgetItem;
|
|---|
| 57 | class QTreeModel;
|
|---|
| 58 |
|
|---|
| 59 | class QTreeWidgetItemIteratorPrivate;
|
|---|
| 60 | class Q_GUI_EXPORT QTreeWidgetItemIterator
|
|---|
| 61 | {
|
|---|
| 62 | friend class QTreeModel;
|
|---|
| 63 |
|
|---|
| 64 | public:
|
|---|
| 65 | enum IteratorFlag {
|
|---|
| 66 | All = 0x00000000,
|
|---|
| 67 | Hidden = 0x00000001,
|
|---|
| 68 | NotHidden = 0x00000002,
|
|---|
| 69 | Selected = 0x00000004,
|
|---|
| 70 | Unselected = 0x00000008,
|
|---|
| 71 | Selectable = 0x00000010,
|
|---|
| 72 | NotSelectable = 0x00000020,
|
|---|
| 73 | DragEnabled = 0x00000040,
|
|---|
| 74 | DragDisabled = 0x00000080,
|
|---|
| 75 | DropEnabled = 0x00000100,
|
|---|
| 76 | DropDisabled = 0x00000200,
|
|---|
| 77 | HasChildren = 0x00000400,
|
|---|
| 78 | NoChildren = 0x00000800,
|
|---|
| 79 | Checked = 0x00001000,
|
|---|
| 80 | NotChecked = 0x00002000,
|
|---|
| 81 | Enabled = 0x00004000,
|
|---|
| 82 | Disabled = 0x00008000,
|
|---|
| 83 | Editable = 0x00010000,
|
|---|
| 84 | NotEditable = 0x00020000,
|
|---|
| 85 | UserFlag = 0x01000000 // The first flag that can be used by the user.
|
|---|
| 86 | };
|
|---|
| 87 | Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)
|
|---|
| 88 |
|
|---|
| 89 | QTreeWidgetItemIterator(const QTreeWidgetItemIterator &it);
|
|---|
| 90 | explicit QTreeWidgetItemIterator(QTreeWidget *widget, IteratorFlags flags = All);
|
|---|
| 91 | explicit QTreeWidgetItemIterator(QTreeWidgetItem *item, IteratorFlags flags = All);
|
|---|
| 92 | ~QTreeWidgetItemIterator();
|
|---|
| 93 |
|
|---|
| 94 | QTreeWidgetItemIterator &operator=(const QTreeWidgetItemIterator &it);
|
|---|
| 95 |
|
|---|
| 96 | QTreeWidgetItemIterator &operator++();
|
|---|
| 97 | inline const QTreeWidgetItemIterator operator++(int);
|
|---|
| 98 | inline QTreeWidgetItemIterator &operator+=(int n);
|
|---|
| 99 |
|
|---|
| 100 | QTreeWidgetItemIterator &operator--();
|
|---|
| 101 | inline const QTreeWidgetItemIterator operator--(int);
|
|---|
| 102 | inline QTreeWidgetItemIterator &operator-=(int n);
|
|---|
| 103 |
|
|---|
| 104 | inline QTreeWidgetItem *operator*() const;
|
|---|
| 105 |
|
|---|
| 106 | private:
|
|---|
| 107 | bool matchesFlags(const QTreeWidgetItem *item) const;
|
|---|
| 108 | QTreeWidgetItemIteratorPrivate *d_ptr;
|
|---|
| 109 | QTreeWidgetItem *current;
|
|---|
| 110 | IteratorFlags flags;
|
|---|
| 111 | Q_DECLARE_PRIVATE(QTreeWidgetItemIterator)
|
|---|
| 112 | };
|
|---|
| 113 |
|
|---|
| 114 | inline const QTreeWidgetItemIterator QTreeWidgetItemIterator::operator++(int)
|
|---|
| 115 | {
|
|---|
| 116 | QTreeWidgetItemIterator it = *this;
|
|---|
| 117 | ++(*this);
|
|---|
| 118 | return it;
|
|---|
| 119 | }
|
|---|
| 120 |
|
|---|
| 121 | inline const QTreeWidgetItemIterator QTreeWidgetItemIterator::operator--(int)
|
|---|
| 122 | {
|
|---|
| 123 | QTreeWidgetItemIterator it = *this;
|
|---|
| 124 | --(*this);
|
|---|
| 125 | return it;
|
|---|
| 126 | }
|
|---|
| 127 |
|
|---|
| 128 | inline QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator+=(int n)
|
|---|
| 129 | {
|
|---|
| 130 | if (n < 0)
|
|---|
| 131 | return (*this) -= (-n);
|
|---|
| 132 | while (current && n--)
|
|---|
| 133 | ++(*this);
|
|---|
| 134 | return *this;
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | inline QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator-=(int n)
|
|---|
| 138 | {
|
|---|
| 139 | if (n < 0)
|
|---|
| 140 | return (*this) += (-n);
|
|---|
| 141 | while (current && n--)
|
|---|
| 142 | --(*this);
|
|---|
| 143 | return *this;
|
|---|
| 144 | }
|
|---|
| 145 |
|
|---|
| 146 | inline QTreeWidgetItem *QTreeWidgetItemIterator::operator*() const
|
|---|
| 147 | {
|
|---|
| 148 | return current;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | Q_DECLARE_OPERATORS_FOR_FLAGS(QTreeWidgetItemIterator::IteratorFlags)
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 | QT_END_NAMESPACE
|
|---|
| 155 | #endif // QT_NO_TREEWIDGET
|
|---|
| 156 | QT_END_HEADER
|
|---|
| 157 |
|
|---|
| 158 | #endif // QTREEWIDGETITEMITERATOR_H
|
|---|