- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# qtreewidgetitemiterator.h

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    00004 ** All rights reserved.
    00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
    00006 **
    00007 ** This file is part of the QtGui module of the Qt Toolkit.
    00008 **
    00009 ** $QT_BEGIN_LICENSE:LGPL$
    00010 ** Commercial Usage
    00011 ** Licensees holding valid Qt Commercial licenses may use this file in
    00012 ** accordance with the Qt Commercial License Agreement provided with the
    00013 ** Software or, alternatively, in accordance with the terms contained in
    00014 ** a written agreement between you and Nokia.
    00015 **
    00016 ** GNU Lesser General Public License Usage
    00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
    00018 ** General Public License version 2.1 as published by the Free Software
    00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
    00020 ** packaging of this file.  Please review the following information to
    00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00023 **
    00024 ** In addition, as a special exception, Nokia gives you certain additional
    00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
    00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
    00027 **
    00028 ** GNU General Public License Usage
    00029 ** Alternatively, this file may be used under the terms of the GNU
    00030 ** General Public License version 3.0 as published by the Free Software
    00031 ** Foundation and appearing in the file LICENSE.GPL included in the
    00032 ** packaging of this file.  Please review the following information to
    00033 ** ensure the GNU General Public License version 3.0 requirements will be
    00034 ** met: http://www.gnu.org/copyleft/gpl.html.
    00035 **
    00036 ** If you have questions regarding the use of this file, please contact
    00037 ** Nokia at qt-info@nokia.com.
    00038 ** $QT_END_LICENSE$
    00039 **
    00040 ****************************************************************************/
    00041
    00042 #ifndef QTREEWIDGETITEMITERATOR_H
    00043 #define QTREEWIDGETITEMITERATOR_H
    00044
    00045 #include <QtCore/qglobal.h>
    00046 #include <QtCore/qscopedpointer.h>
    00047
    00048 QT_BEGIN_HEADER
    00049
    00050 QT_BEGIN_NAMESPACE
    00051
    00052 QT_MODULE(Gui)
    00053
    00054 #ifndef QT_NO_TREEWIDGET
    00055
    00056 class QTreeWidget;
    00057 class QTreeWidgetItem;
    00058 class QTreeModel;
    00059
    00060 class QTreeWidgetItemIteratorPrivate;
    00061 class Q_GUI_EXPORT QTreeWidgetItemIterator
    00062 {
    00063     friend class QTreeModel;
    00064
    00065 public:
    00066     enum IteratorFlag {
    00067         All           = 0x00000000,
    00068         Hidden        = 0x00000001,
    00069         NotHidden     = 0x00000002,
    00070         Selected      = 0x00000004,
    00071         Unselected    = 0x00000008,
    00072         Selectable    = 0x00000010,
    00073         NotSelectable = 0x00000020,
    00074         DragEnabled   = 0x00000040,
    00075         DragDisabled  = 0x00000080,
    00076         DropEnabled   = 0x00000100,
    00077         DropDisabled  = 0x00000200,
    00078         HasChildren   = 0x00000400,
    00079         NoChildren    = 0x00000800,
    00080         Checked       = 0x00001000,
    00081         NotChecked    = 0x00002000,
    00082         Enabled       = 0x00004000,
    00083         Disabled      = 0x00008000,
    00084         Editable      = 0x00010000,
    00085         NotEditable   = 0x00020000,
    00086         UserFlag      = 0x01000000 // The first flag that can be used by the user.
    00087     };
    00088     Q_DECLARE_FLAGS(IteratorFlags, IteratorFlag)
    00089
    00090     QTreeWidgetItemIterator(const QTreeWidgetItemIterator &it);
    00091     explicit QTreeWidgetItemIterator(QTreeWidget *widget, IteratorFlags flags = All);
    00092     explicit QTreeWidgetItemIterator(QTreeWidgetItem *item, IteratorFlags flags = All);
    00093     ~QTreeWidgetItemIterator();
    00094
    00095     QTreeWidgetItemIterator &operator=(const QTreeWidgetItemIterator &it);
    00096
    00097     QTreeWidgetItemIterator &operator++();
    00098     inline const QTreeWidgetItemIterator operator++(int);
    00099     inline QTreeWidgetItemIterator &operator+=(int n);
    00100
    00101     QTreeWidgetItemIterator &operator--();
    00102     inline const QTreeWidgetItemIterator operator--(int);
    00103     inline QTreeWidgetItemIterator &operator-=(int n);
    00104
    00105     inline QTreeWidgetItem *operator*() const;
    00106
    00107 private:
    00108     bool matchesFlags(const QTreeWidgetItem *item) const;
    00109     QScopedPointer<QTreeWidgetItemIteratorPrivate> d_ptr;
    00110     QTreeWidgetItem *current;
    00111     IteratorFlags flags;
    00112     Q_DECLARE_PRIVATE(QTreeWidgetItemIterator)
    00113 };
    00114
    00115 inline const QTreeWidgetItemIterator QTreeWidgetItemIterator::operator++(int)
    00116 {
    00117     QTreeWidgetItemIterator it = *this;
    00118     ++(*this);
    00119     return it;
    00120 }
    00121
    00122 inline const QTreeWidgetItemIterator QTreeWidgetItemIterator::operator--(int)
    00123 {
    00124     QTreeWidgetItemIterator it = *this;
    00125     --(*this);
    00126     return it;
    00127 }
    00128
    00129 inline QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator+=(int n)
    00130 {
    00131     if (n < 0)
    00132         return (*this) -= (-n);
    00133     while (current && n--)
    00134         ++(*this);
    00135     return *this;
    00136 }
    00137
    00138 inline QTreeWidgetItemIterator &QTreeWidgetItemIterator::operator-=(int n)
    00139 {
    00140     if (n < 0)
    00141         return (*this) += (-n);
    00142     while (current && n--)
    00143         --(*this);
    00144     return *this;
    00145 }
    00146
    00147 inline QTreeWidgetItem *QTreeWidgetItemIterator::operator*() const
    00148 {
    00149     return current;
    00150 }
    00151
    00152 Q_DECLARE_OPERATORS_FOR_FLAGS(QTreeWidgetItemIterator::IteratorFlags)
    00153
    00154
    00155 QT_END_NAMESPACE
    00156 #endif // QT_NO_TREEWIDGET
    00157 QT_END_HEADER
    00158
    00159 #endif // QTREEWIDGETITEMITERATOR_H