diff options
author | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2010-05-25 18:09:00 (GMT) |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dietrich-de@nokia.com> | 2010-05-26 08:30:25 (GMT) |
commit | 00edad4373d394ed9f828b1fa887003f87c5fa6f (patch) | |
tree | a6a35d37c0e1f58685b32699c77ab7dcd9f52e84 /src/gui/widgets/qcombobox.cpp | |
parent | 2e0ac76a76f02e22f101b24ba222f8251d0c2580 (diff) | |
download | Qt-00edad4373d394ed9f828b1fa887003f87c5fa6f.zip Qt-00edad4373d394ed9f828b1fa887003f87c5fa6f.tar.gz Qt-00edad4373d394ed9f828b1fa887003f87c5fa6f.tar.bz2 |
QComboBox::modelColumn was not respected when selecting an item
Auto-test included
Reviewed-by: Olivier
Task-number: QTBUG-10491
Diffstat (limited to 'src/gui/widgets/qcombobox.cpp')
-rw-r--r-- | src/gui/widgets/qcombobox.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 6cf24a6..213ca95 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -2003,11 +2003,18 @@ void QComboBox::setCurrentIndex(int index) void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) { Q_Q(QComboBox); - bool indexChanged = (mi != currentIndex); + + QModelIndex normalized; + if (mi.column() != modelColumn) + normalized = model->index(mi.row(), modelColumn, mi.parent()); + if (!normalized.isValid()) + normalized = mi; // Fallback to passed index. + + bool indexChanged = (normalized != currentIndex); if (indexChanged) - currentIndex = QPersistentModelIndex(mi); + currentIndex = QPersistentModelIndex(normalized); if (lineEdit) { - QString newText = q->itemText(currentIndex.row()); + QString newText = q->itemText(normalized.row()); if (lineEdit->text() != newText) lineEdit->setText(newText); updateLineEditGeometry(); |