QitemSelectionModel: Fix a bug in isColumnSelected

Previously the code for isColumnSelected and isRowSelected differed
slightly, in how unselectable indexes would be treated.

This made isColumnSelected return false for a column, which mixed
unselectable indexes and selected indexes. Thus in some situations,
the user could not deselect a column via a QTableView header.

By copying the isRowSelected code to isColumnSelected, rows and
columns behave identical.

Task-number: QTBUG-18001
Change-Id: I6ca85ac64b31a481fafeaa3bec958b18283eed8d
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Daniel Teske 2017-11-03 13:24:18 +01:00
parent d6b9cba812
commit edf6debbab

View File

@ -1577,8 +1577,12 @@ bool QItemSelectionModel::isColumnSelected(int column, const QModelIndex &parent
for (int row = 0; row < rowCount; ++row) {
for (it = joined.constBegin(); it != joined.constEnd(); ++it) {
if ((*it).contains(row, column, parent)) {
Qt::ItemFlags flags = d->model->index(row, column, parent).flags();
if ((flags & Qt::ItemIsSelectable) && (flags & Qt::ItemIsEnabled)) {
bool selectable = false;
for (int i = row; !selectable && i <= (*it).bottom(); ++i) {
Qt::ItemFlags flags = d->model->index(i, column, parent).flags();
selectable = flags & Qt::ItemIsSelectable;
}
if (selectable){
row = qMax(row, (*it).bottom());
break;
}