Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

void QItemSelectionModel::setCurrentIndex ( const QModelIndex index,
QItemSelectionModel::SelectionFlags  command 
) [slot]

Sets the model item index to be the current item, and emits currentChanged(). The current item is used for keyboard navigation and focus indication; it is independent of any selected items, although a selected item can also be the current item.

Depending on the specified command, the index can also become part of the current selection.

See also:
select()

Definition at line 1078 of file qitemselectionmodel.cpp.

References QPersistentModelIndex::column(), currentChanged(), currentColumnChanged(), currentRowChanged(), QPersistentModelIndex::row(), and select().

Referenced by QAbstractItemView::focusInEvent(), QTreeView::keyboardSearch(), and QComboBox::showPopup().

{
    Q_D(QItemSelectionModel);
    if (index == d->currentIndex) {
        if (command != NoUpdate)
            select(index, command); // select item
        return;
    }
    QPersistentModelIndex previous = d->currentIndex;
    d->currentIndex = index; // set current before emitting selection changed below
    if (command != NoUpdate)
        select(d->currentIndex, command); // select item
    emit currentChanged(d->currentIndex, previous);
    if (d->currentIndex.row() != previous.row())
        emit currentRowChanged(d->currentIndex, previous);
    if (d->currentIndex.column() != previous.column())
        emit currentColumnChanged(d->currentIndex, previous);
}


Generated by  Doxygen 1.6.0   Back to index