#include <q3listview.h>
Collaboration diagram for Q3ListViewItemIterator:

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, 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.
Definition at line 525 of file q3listview.h.
These flags can be passed to a Q3ListViewItemIterator constructor (OR-ed together if more than one is used), so that the iterator will only iterate over items that match the given flags.
Visible Invisible Selected Unselected Selectable NotSelectable DragEnabled DragDisabled DropEnabled DropDisabled Expandable NotExpandable Checked NotChecked
Definition at line 532 of file q3listview.h.
00532 { 00533 Visible = 0x00000001, 00534 Invisible = 0x00000002, 00535 Selected = 0x00000004, 00536 Unselected = 0x00000008, 00537 Selectable = 0x00000010, 00538 NotSelectable = 0x00000020, 00539 DragEnabled = 0x00000040, 00540 DragDisabled = 0x00000080, 00541 DropEnabled = 0x00000100, 00542 DropDisabled = 0x00000200, 00543 Expandable = 0x00000400, 00544 NotExpandable = 0x00000800, 00545 Checked = 0x00001000, 00546 NotChecked = 0x00002000 00547 };
| Q3ListViewItemIterator::Q3ListViewItemIterator | ( | ) |
| Q3ListViewItemIterator::Q3ListViewItemIterator | ( | Q3ListViewItem * | item | ) |
Constructs an iterator for the Q3ListView that contains the item. The current iterator item is set to point to the item.
Definition at line 7269 of file q3listview.cpp.
References QList< T >::append(), Q3ListView::d, Q3ListViewItem::enforceSortOrderBackToRoot(), Q3ListViewPrivate::iterators, Q3ListViewItem::listView(), and listView.
07270 : curr(item), listView(0), flags(0) 07271 { 07272 if (item) { 07273 item->enforceSortOrderBackToRoot(); 07274 listView = item->listView(); 07275 } 07276 if (listView) 07277 listView->d->iterators.append(this); 07278 }
Here is the call graph for this function:

| Q3ListViewItemIterator::Q3ListViewItemIterator | ( | Q3ListViewItem * | item, | |
| int | iteratorFlags | |||
| ) |
Constructs an iterator for the Q3ListView that contains the item using the flags iteratorFlags. The current iterator item is set to point to item or the next matching item if item doesn't match the flags.
Definition at line 7289 of file q3listview.cpp.
References QList< T >::append(), curr, Q3ListView::d, Q3ListViewItem::enforceSortOrderBackToRoot(), Q3ListViewPrivate::iterators, Q3ListViewItem::listView(), listView, and matchesFlags().
07290 : curr(item), listView(0), flags(iteratorFlags) 07291 { 07292 // go to next matching item if the current don't match 07293 if (curr && !matchesFlags(curr)) 07294 ++(*this); 07295 07296 if (curr) { 07297 curr->enforceSortOrderBackToRoot(); 07298 listView = curr->listView(); 07299 } 07300 if (listView) 07301 listView->d->iterators.append(this); 07302 }
Here is the call graph for this function:

| Q3ListViewItemIterator::Q3ListViewItemIterator | ( | const Q3ListViewItemIterator & | it | ) |
Constructs an iterator for the same Q3ListView as it. The current iterator item is set to point on the current item of it.
Definition at line 7311 of file q3listview.cpp.
References QList< T >::append(), Q3ListView::d, Q3ListViewPrivate::iterators, and listView.
07312 : curr(it.curr), listView(it.listView), flags(it.flags) 07313 { 07314 if (listView) 07315 listView->d->iterators.append(this); 07316 }
Here is the call graph for this function:

| 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.
Definition at line 7324 of file q3listview.cpp.
References QList< T >::append(), Q3ListView::d, Q3ListViewPrivate::iterators, and listView.
07325 : curr(lv->firstChild()), listView(lv), flags(0) 07326 { 07327 if (listView) 07328 listView->d->iterators.append(this); 07329 }
Here is the call graph for this function:

| 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.
Definition at line 7339 of file q3listview.cpp.
References QList< T >::append(), curr, Q3ListView::d, Q3ListViewPrivate::iterators, listView, and matchesFlags().
07340 : curr (lv->firstChild()), listView(lv), flags(iteratorFlags) 07341 { 07342 if (listView) 07343 listView->d->iterators.append(this); 07344 if (!matchesFlags(curr)) 07345 ++(*this); 07346 }
Here is the call graph for this function:

| Q3ListViewItemIterator::~Q3ListViewItemIterator | ( | ) |
Destroys the iterator.
Definition at line 7377 of file q3listview.cpp.
References Q3ListView::d, Q3ListViewPrivate::iterators, listView, and QList< T >::removeAll().
Here is the call graph for this function:

| Q3ListViewItemIterator & Q3ListViewItemIterator::operator= | ( | const Q3ListViewItemIterator & | it | ) |
Assignment. Makes a copy of it and returns a reference to its iterator.
Definition at line 7355 of file q3listview.cpp.
References QList< T >::append(), curr, Q3ListView::d, flags, Q3ListViewPrivate::iterators, listView, matchesFlags(), and QList< T >::removeAll().
07356 { 07357 if (listView) 07358 listView->d->iterators.removeAll(this); 07359 07360 listView = it.listView; 07361 curr = it.curr; 07362 flags = it.flags; 07363 if (listView) 07364 listView->d->iterators.append(this); 07365 07366 // go to next matching item if the current don't match 07367 if (curr && !matchesFlags(curr)) 07368 ++(*this); 07369 07370 return *this; 07371 }
Here is the call graph for this function:

| 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 is 0.
Definition at line 7389 of file q3listview.cpp.
References curr, Q3ListViewItem::firstChild(), matchesFlags(), Q3ListViewItem::nextSibling(), and Q3ListViewItem::parent().
07390 { 07391 if (!curr) 07392 return *this; 07393 07394 Q3ListViewItem *item = curr->firstChild(); 07395 if (!item) { 07396 while ((item = curr->nextSibling()) == 0 ) { 07397 curr = curr->parent(); 07398 if (curr == 0) 07399 break; 07400 } 07401 } 07402 curr = item; 07403 // if the next one doesn't match the flags we try one more ahead 07404 if (curr && !matchesFlags(curr)) 07405 ++(*this); 07406 return *this; 07407 }
Here is the call graph for this function:

| const Q3ListViewItemIterator Q3ListViewItemIterator::operator++ | ( | int | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Postfix ++. Makes the next item the new current item and returns the item that was the current item.
Definition at line 7416 of file q3listview.cpp.
07417 { 07418 Q3ListViewItemIterator oldValue = *this; 07419 ++(*this); 07420 return oldValue; 07421 }
| 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.
Definition at line 7429 of file q3listview.cpp.
References curr.
| 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 is 0.
Definition at line 7443 of file q3listview.cpp.
References curr, Q3ListViewItem::firstChild(), Q3ListView::firstChild(), i, Q3ListViewItem::listView(), matchesFlags(), and Q3ListViewItem::parent().
07444 { 07445 if (!curr) 07446 return *this; 07447 07448 if (!curr->parent()) { 07449 // we are in the first depth 07450 if (curr->listView()) { 07451 if (curr->listView()->firstChild() != curr) { 07452 // go the previous sibling 07453 Q3ListViewItem *i = curr->listView()->firstChild(); 07454 while (i && i->siblingItem != curr) 07455 i = i->siblingItem; 07456 07457 curr = i; 07458 07459 if (i && i->firstChild()) { 07460 // go to the last child of this item 07461 Q3ListViewItemIterator it(curr->firstChild()); 07462 for (; it.current() && it.current()->parent(); ++it) 07463 curr = it.current(); 07464 } 07465 07466 if (curr && !matchesFlags(curr)) 07467 --(*this); 07468 07469 return *this; 07470 } else { 07471 //we are already the first child of the list view, so it's over 07472 curr = 0; 07473 return *this; 07474 } 07475 } else 07476 return *this; 07477 } else { 07478 Q3ListViewItem *parent = curr->parent(); 07479 07480 if (curr != parent->firstChild()) { 07481 // go to the previous sibling 07482 Q3ListViewItem *i = parent->firstChild(); 07483 while (i && i->siblingItem != curr) 07484 i = i->siblingItem; 07485 07486 curr = i; 07487 07488 if (i && i->firstChild()) { 07489 // go to the last child of this item 07490 Q3ListViewItemIterator it(curr->firstChild()); 07491 for (; it.current() && it.current()->parent() != parent; ++it) 07492 curr = it.current(); 07493 } 07494 07495 if (curr && !matchesFlags(curr)) 07496 --(*this); 07497 07498 return *this; 07499 } else { 07500 // make our parent the current item 07501 curr = parent; 07502 07503 if (curr && !matchesFlags(curr)) 07504 --(*this); 07505 07506 return *this; 07507 } 07508 } 07509 }
Here is the call graph for this function:

| const Q3ListViewItemIterator Q3ListViewItemIterator::operator-- | ( | int | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Postfix --. Makes the previous item the new current item and returns the item that was the current item.
Definition at line 7518 of file q3listview.cpp.
07519 { 07520 Q3ListViewItemIterator oldValue = *this; 07521 --(*this); 07522 return oldValue; 07523 }
| 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.
Definition at line 7531 of file q3listview.cpp.
References curr.
| Q3ListViewItem * Q3ListViewItemIterator::operator * | ( | ) |
Dereference operator. Returns a reference to the current item. The same as current().
Definition at line 7544 of file q3listview.cpp.
References curr, matchesFlags(), and qWarning().
07545 { 07546 if (curr != 0 && !matchesFlags(curr)) 07547 qWarning("Q3ListViewItemIterator::operator*() curr out of sync"); 07548 return curr; 07549 }
Here is the call graph for this function:

| Q3ListViewItem * Q3ListViewItemIterator::current | ( | ) | const |
Returns iterator's current item.
Definition at line 7555 of file q3listview.cpp.
References curr, matchesFlags(), and qWarning().
Referenced by Q3ListView::clearRange(), Q3ListView::findItem(), findLVItem(), Q3ListView::invertSelection(), QAccessibleListView::itemAt(), Q3FileDialog::itemChanged(), QAccessibleListView::itemCount(), Q3FileDialog::newFolderClicked(), Q3ListView::removeColumn(), Q3FileDialog::removeEntry(), Q3ListView::selectAll(), QAccessibleListView::selection(), Q3ListView::selectRange(), and QAccessibleListView::setSelected().
07556 { 07557 if (curr != 0 && !matchesFlags(curr)) 07558 qWarning("Q3ListViewItemIterator::current() curr out of sync"); 07559 return curr; 07560 }
Here is the call graph for this function:

| void Q3ListViewItemIterator::currentRemoved | ( | ) | [private] |
Definition at line 7568 of file q3listview.cpp.
References curr, Q3ListView::firstChild(), listView, Q3ListViewItem::nextSibling(), and Q3ListViewItem::parent().
07569 { 07570 if (!curr) return; 07571 07572 if (curr->parent()) 07573 curr = curr->parent(); 07574 else if (curr->nextSibling()) 07575 curr = curr->nextSibling(); 07576 else if (listView && listView->firstChild() && 07577 listView->firstChild() != curr) 07578 curr = listView->firstChild(); 07579 else 07580 curr = 0; 07581 }
Here is the call graph for this function:

| bool Q3ListViewItemIterator::matchesFlags | ( | const Q3ListViewItem * | ) | const [private] |
Definition at line 7586 of file q3listview.cpp.
References Checked, DragDisabled, Q3ListViewItem::dragEnabled(), DragEnabled, DropDisabled, Q3ListViewItem::dropEnabled(), DropEnabled, Expandable, flags, Invisible, isChecked(), Q3ListViewItem::isExpandable(), Q3ListViewItem::isSelectable(), Q3ListViewItem::isSelected(), Q3ListViewItem::isVisible(), NotChecked, NotExpandable, NotSelectable, Selectable, Selected, Unselected, and Visible.
Referenced by current(), operator *(), operator++(), operator--(), operator=(), and Q3ListViewItemIterator().
07587 { 07588 if (!item) 07589 return false; 07590 07591 if (flags == 0) 07592 return true; 07593 07594 if (flags & Visible && !item->isVisible()) 07595 return false; 07596 if (flags & Invisible && item->isVisible()) 07597 return false; 07598 if (flags & Selected && !item->isSelected()) 07599 return false; 07600 if (flags & Unselected && item->isSelected()) 07601 return false; 07602 if (flags & Selectable && !item->isSelectable()) 07603 return false; 07604 if (flags & NotSelectable && item->isSelectable()) 07605 return false; 07606 if (flags & DragEnabled && !item->dragEnabled()) 07607 return false; 07608 if (flags & DragDisabled && item->dragEnabled()) 07609 return false; 07610 if (flags & DropEnabled && !item->dropEnabled()) 07611 return false; 07612 if (flags & DropDisabled && item->dropEnabled()) 07613 return false; 07614 if (flags & Expandable && !item->isExpandable()) 07615 return false; 07616 if (flags & NotExpandable && item->isExpandable()) 07617 return false; 07618 if (flags & Checked && !isChecked(item)) 07619 return false; 07620 if (flags & NotChecked && isChecked(item)) 07621 return false; 07622 07623 return true; 07624 }
Here is the call graph for this function:

| bool Q3ListViewItemIterator::testPair | ( | Q3ListViewItemIterator::IteratorFlag | , | |
| Q3ListViewItemIterator::IteratorFlag | , | |||
| bool | ||||
| ) | const [private] |
| bool Q3ListViewItemIterator::isChecked | ( | const Q3ListViewItem * | ) | const [private] |
Definition at line 7630 of file q3listview.cpp.
References Q3ListViewItem::rtti().
Referenced by matchesFlags().
07631 { 07632 if (item->rtti() == 1) 07633 return ((const Q3CheckListItem*)item)->isOn(); 07634 else return false; 07635 }
Here is the call graph for this function:

friend struct Q3ListViewPrivate [friend] |
Definition at line 527 of file q3listview.h.
friend class Q3ListView [friend] |
Definition at line 528 of file q3listview.h.
friend class Q3ListViewItem [friend] |
Definition at line 529 of file q3listview.h.
Q3ListViewItem* Q3ListViewItemIterator::curr [private] |
Definition at line 573 of file q3listview.h.
Referenced by current(), currentRemoved(), operator *(), operator++(), operator+=(), operator--(), operator-=(), operator=(), and Q3ListViewItemIterator().
Q3ListView* Q3ListViewItemIterator::listView [private] |
Definition at line 574 of file q3listview.h.
Referenced by currentRemoved(), operator=(), Q3ListViewItemIterator(), and ~Q3ListViewItemIterator().
int Q3ListViewItemIterator::flags [private] |
1.5.1