diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-01-29 12:19:14 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-02-04 19:38:04 +0000 |
commit | a29374fc8ecb9fc17ac125d730eed9c8ec98badb (patch) | |
tree | f33dba2e81b660641d76deaf71357b524cccfb8d /src/widgets/widgets | |
parent | 6c117ee4aa4974556c6d6ac3799277a4da67b112 (diff) |
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>
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 16e1024085..65ec3f7d7b 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -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. |