Qt 4.8
Public Functions | Properties | List of all members
ModelIndexIterator Class Reference

Public Functions

QModelIndex current () const
 
bool isHidden () const
 
 ModelIndexIterator (QAbstractItemView *view, const QModelIndex &start=QModelIndex())
 
bool next (int count=1)
 

Properties

QListViewlist
 
QModelIndex m_current
 
QAbstractItemViewm_view
 
QTableViewtable
 
QTreeViewtree
 

Detailed Description

Definition at line 710 of file complexwidgets.cpp.

Constructors and Destructors

◆ ModelIndexIterator()

ModelIndexIterator::ModelIndexIterator ( QAbstractItemView view,
const QModelIndex start = QModelIndex() 
)
inline

Definition at line 713 of file complexwidgets.cpp.

713  : m_view(view)
714  {
715 #ifndef QT_NO_LISTVIEW
717 #endif
718 #ifndef QT_NO_TREEVIEW
720 #endif
721 #ifndef QT_NO_TABLEVIEW
723 #endif
724  if (start.isValid()) {
725  m_current = start;
726  } else if (m_view && m_view->model()) {
727  m_current = view->rootIndex().isValid() ?
728  view->rootIndex().child(0,0) : view->model()->index(0, 0);
729  }
730  }
T qobject_cast(QObject *object)
Definition: qobject.h:375
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index...
The QTreeView class provides a default model/view implementation of a tree view.
Definition: qtreeview.h:58
The QTableView class provides a default model/view implementation of a table view.
Definition: qtableview.h:58
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
QModelIndex child(int row, int column) const
Returns the child of the model index that is stored in the given row and column.
The QListView class provides a list or icon view onto a model.
Definition: qlistview.h:57
QAbstractItemView * m_view
QModelIndex rootIndex() const
Returns the model index of the model's root item.
QAbstractItemModel * model() const
Returns the model that this view is presenting.

Functions

◆ current()

QModelIndex ModelIndexIterator::current ( ) const
inline

Definition at line 787 of file complexwidgets.cpp.

Referenced by QAccessibleItemView::childIndex().

787  {
788  return m_current;
789  }

◆ isHidden()

bool ModelIndexIterator::isHidden ( ) const
inline

Definition at line 769 of file complexwidgets.cpp.

769  {
770  if (false) {
771 #ifndef QT_NO_LISTVIEW
772  } else if (list) {
773  return list->isRowHidden(m_current.row());
774 #endif
775 #ifndef QT_NO_TREEVIEW
776  } else if (tree) {
778 #endif
779 #ifndef QT_NO_TABLEVIEW
780  } else if (table) {
781  return table->isRowHidden(m_current.row());
782 #endif
783  }
784  return false;
785  }
bool isRowHidden(int row, const QModelIndex &parent) const
Returns true if the item in the given row of the parent is hidden; otherwise returns false...
Definition: qtreeview.cpp:609
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
int row() const
Returns the row this model index refers to.
bool isRowHidden(int row) const
Returns true if the given row is hidden; otherwise returns false.
bool isRowHidden(int row) const
Returns true if the row is hidden; otherwise returns false.
Definition: qlistview.cpp:563

◆ next()

bool ModelIndexIterator::next ( int  count = 1)
inline

Definition at line 732 of file complexwidgets.cpp.

Referenced by QAccessibleItemView::childCount(), and QAccessibleItemView::childIndex().

732  {
733  for (int i = 0; i < count; ++i) {
734  do {
735  if (m_current.isValid()) {
736  const QAbstractItemModel *m = m_current.model();
737 #ifndef QT_NO_TREEVIEW
739  m_current = m_current.child(0, 0);
740  } else
741 #endif
742  {
743  int row = m_current.row();
744  QModelIndex par = m_current.parent();
745 
746  // Go up to the parent if we reach the end of the rows
747  // If m_curent becomses invalid, stop going up.
748  while (row + 1 >= m->rowCount(par)) {
749  m_current = par;
750  if (m_current.isValid()) {
751  row = m_current.row();
752  par = m_current.parent();
753  } else {
754  row = 0;
755  par = QModelIndex();
756  break;
757  }
758  }
759 
760  if (m_current.isValid())
761  m_current = m_current.sibling(row + 1, 0);
762  }
763  }
764  } while (isHidden());
765  }
766  return m_current.isValid();
767  }
QModelIndex sibling(int row, int column) const
Returns the sibling at row and column.
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const =0
Returns the number of rows under the given parent.
bool isExpanded(const QModelIndex &index) const
Returns true if the model item index is expanded; otherwise returns false.
Definition: qtreeview.cpp:859
QModelIndex parent() const
Returns the parent of the model index, or QModelIndex() if it has no parent.
virtual bool hasChildren(const QModelIndex &parent=QModelIndex()) const
Returns true if parent has any children; otherwise returns false.
int row() const
Returns the row this model index refers to.
const QAbstractItemModel * model() const
Returns a pointer to the model containing the item that this index refers to.
bool isValid() const
Returns true if this model index is valid; otherwise returns false.
The QAbstractItemModel class provides the abstract interface for item model classes.
QModelIndex child(int row, int column) const
Returns the child of the model index that is stored in the given row and column.
The QModelIndex class is used to locate data in a data model.

Properties

◆ list

QListView* ModelIndexIterator::list
private

Definition at line 799 of file complexwidgets.cpp.

◆ m_current

QModelIndex ModelIndexIterator::m_current
private

Definition at line 792 of file complexwidgets.cpp.

◆ m_view

QAbstractItemView* ModelIndexIterator::m_view
private

Definition at line 793 of file complexwidgets.cpp.

◆ table

QTableView* ModelIndexIterator::table
private

Definition at line 802 of file complexwidgets.cpp.

◆ tree

QTreeView* ModelIndexIterator::tree
private

Definition at line 796 of file complexwidgets.cpp.


The documentation for this class was generated from the following file: