Q3ListViewItemIterator Class

The Q3ListViewItemIterator class provides an iterator for collections of Q3ListViewItems. 更多...

头: #include <Q3ListViewItemIterator>

公共类型

enum IteratorFlag { Visible, Invisible, Selected, Unselected, ..., NotChecked }

公共函数

Q3ListViewItemIterator ()
Q3ListViewItemIterator (Q3ListViewItem * item )
Q3ListViewItemIterator (Q3ListViewItem * item , int iteratorFlags )
Q3ListViewItemIterator (const Q3ListViewItemIterator & it )
Q3ListViewItemIterator (Q3ListView * lv )
Q3ListViewItemIterator (Q3ListView * lv , int iteratorFlags )
~Q3ListViewItemIterator ()
Q3ListViewItem * current () const
Q3ListViewItem * operator* ()
Q3ListViewItemIterator & operator++ ()
const Q3ListViewItemIterator operator++ (int)
Q3ListViewItemIterator & operator+= (int j )
Q3ListViewItemIterator & operator-- ()
const Q3ListViewItemIterator operator-- (int)
Q3ListViewItemIterator & operator-= (int j )
Q3ListViewItemIterator & operator= (const Q3ListViewItemIterator & it )

详细描述

The Q3ListViewItemIterator class provides an iterator for collections of Q3ListViewItems.

Construct an instance of a Q3ListViewItemIterator , with either a Q3ListView * or a Q3ListViewItem * as argument, to operate on the tree of Q3ListViewItems, starting from the argument.

A Q3ListViewItemIterator iterates over all the items from its starting point. This means that it always makes the first child of the current item the new current item. If there is no child, the next sibling becomes the new current item; and if there is no next sibling, the next sibling of the parent becomes current.

The following example creates a list of all the items that have been selected by the user, storing pointers to the items in a QList :

QList<Q3ListViewItem *> lst;
Q3ListViewItemIterator it(myListView);
while (it.current()) {
    if (it.current()->isSelected())
        lst.append(it.current());
    ++it;
}
					

An alternative approach is to use an IteratorFlag :

QList<Q3ListViewItem *> lst;
Q3ListViewItemIterator it(myListView, Q3ListViewItemIterator::Selected);
while (it.current()) {
    lst.append(it.current());
    ++it;
}
					

A Q3ListViewItemIterator provides a convenient and easy way to traverse a hierarchical Q3ListView .

Multiple Q3ListViewItemIterators can operate on the tree of Q3ListViewItems. A Q3ListView knows about all iterators operating on its Q3ListViewItems. So when a Q3ListViewItem gets removed all iterators that point to this item are updated and point to the following item if possible, otherwise to a valid item before the current one or to 0. Note however that deleting the parent item of an item that an iterator points to is not safe.

另请参阅 Q3ListView and Q3ListViewItem .

成员类型文档编制

enum Q3ListViewItemIterator:: IteratorFlag

这些标志可以传递给 Q3ListViewItemIterator 构造函数 (OR 在一起若使用一个以上),以便迭代器将仅迭代匹配给定标志的项。

常量
Q3ListViewItemIterator::Visible 0x00000001
Q3ListViewItemIterator::Invisible 0x00000002
Q3ListViewItemIterator::Selected 0x00000004
Q3ListViewItemIterator::Unselected 0x00000008
Q3ListViewItemIterator::Selectable 0x00000010
Q3ListViewItemIterator::NotSelectable 0x00000020
Q3ListViewItemIterator::DragEnabled 0x00000040
Q3ListViewItemIterator::DragDisabled 0x00000080
Q3ListViewItemIterator::DropEnabled 0x00000100
Q3ListViewItemIterator::DropDisabled 0x00000200
Q3ListViewItemIterator::Expandable 0x00000400
Q3ListViewItemIterator::NotExpandable 0x00000800
Q3ListViewItemIterator::Checked 0x00001000
Q3ListViewItemIterator::NotChecked 0x00002000

成员函数文档编制

Q3ListViewItemIterator:: Q3ListViewItemIterator ()

Constructs an empty iterator.

Q3ListViewItemIterator:: Q3ListViewItemIterator ( Q3ListViewItem * item )

Constructs an iterator for the Q3ListView 包含 item . The current iterator item is set to point to the item .

Q3ListViewItemIterator:: Q3ListViewItemIterator ( Q3ListViewItem * item , int iteratorFlags )

Constructs an iterator for the Q3ListView 包含 item using the flags iteratorFlags . The current iterator item is set to point to item or the next matching item if item 不匹配标志。

另请参阅 Q3ListViewItemIterator::IteratorFlag .

Q3ListViewItemIterator:: Q3ListViewItemIterator (const Q3ListViewItemIterator & it )

构造迭代器为相同 Q3ListView as it 。当前迭代器项被设为指向当前项在 it .

Q3ListViewItemIterator:: Q3ListViewItemIterator ( Q3ListView * lv )

Constructs an iterator for the Q3ListView lv . The current iterator item is set to point on the first child ( Q3ListViewItem ) of lv .

Q3ListViewItemIterator:: Q3ListViewItemIterator ( Q3ListView * lv , int iteratorFlags )

Constructs an iterator for the Q3ListView lv with the flags iteratorFlags . The current iterator item is set to point on the first child ( Q3ListViewItem ) of lv that matches the flags.

另请参阅 Q3ListViewItemIterator::IteratorFlag .

Q3ListViewItemIterator:: ~Q3ListViewItemIterator ()

销毁迭代器。

Q3ListViewItem * Q3ListViewItemIterator:: current () const

Returns iterator's current item.

Q3ListViewItem * Q3ListViewItemIterator:: operator* ()

Dereference operator. Returns a reference to the current item. The same as current ().

Q3ListViewItemIterator & Q3ListViewItemIterator:: operator++ ()

Prefix ++. Makes the next item the new current item and returns it. Returns 0 if the current item is the last item or the Q3ListView 为 0。

const Q3ListViewItemIterator Q3ListViewItemIterator:: operator++ ( int )

这是重载函数。

Postfix ++. Makes the next item the new current item and returns the item that was the current item.

Q3ListViewItemIterator & Q3ListViewItemIterator:: operator+= ( int j )

Sets the current item to the item j positions after the current item. If that item is beyond the last item, the current item is set to 0. Returns the current item.

Q3ListViewItemIterator & Q3ListViewItemIterator:: operator-- ()

Prefix --. Makes the previous item the new current item and returns it. Returns 0 if the current item is the first item or the Q3ListView 为 0。

const Q3ListViewItemIterator Q3ListViewItemIterator:: operator-- ( int )

这是重载函数。

Postfix --. Makes the previous item the new current item and returns the item that was the current item.

Q3ListViewItemIterator & Q3ListViewItemIterator:: operator-= ( int j )

Sets the current item to the item j positions before the current item. If that item is before the first item, the current item is set to 0. Returns the current item.

Q3ListViewItemIterator & Q3ListViewItemIterator:: operator= (const Q3ListViewItemIterator & it )

赋值。制作副本为 it 并返回其迭代器的引用。