QComboBox: simplify code
Remove an useless check and hoist a costly call out of a loop. Change-Id: Ibd1750026af44462a4f0223a9b2f422ebcc7c0e3 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
This commit is contained in:
parent
3c6a960b5b
commit
8cbf402123
@ -1990,13 +1990,12 @@ void QComboBox::setModel(QAbstractItemModel *model)
|
||||
|
||||
bool currentReset = false;
|
||||
|
||||
if (count()) {
|
||||
for (int pos=0; pos < count(); pos++) {
|
||||
if (d->model->index(pos, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled) {
|
||||
setCurrentIndex(pos);
|
||||
currentReset = true;
|
||||
break;
|
||||
}
|
||||
const int rowCount = count();
|
||||
for (int pos=0; pos < rowCount; pos++) {
|
||||
if (d->model->index(pos, d->modelColumn, d->root).flags() & Qt::ItemIsEnabled) {
|
||||
setCurrentIndex(pos);
|
||||
currentReset = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user