QComboBox: use QModelIndex::sibling() instead of index()+parent()

QAIM::sibling() may be more efficient, esp. in cases where only the
column number needs to be adjusted. It is a no-op if the column
number is already correct.

Change-Id: Iabb8d5ef58d083da971a9d2f3702908257e5cc0a
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
Marc Mutz 2015-01-29 12:19:14 +01:00
parent 6c117ee4aa
commit a29374fc8e

View File

@ -2069,9 +2069,7 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi)
{
Q_Q(QComboBox);
QModelIndex normalized;
if (mi.column() != modelColumn)
normalized = model->index(mi.row(), modelColumn, mi.parent());
QModelIndex normalized = mi.sibling(mi.row(), modelColumn); // no-op if mi.column() == modelColumn
if (!normalized.isValid())
normalized = mi; // Fallback to passed index.