Skip to content

Commit

Permalink
Revert "QTreeView: Make sure QHeaderView is notified on layoutChanged()"
Browse files Browse the repository at this point in the history
It caused some sorting issues.
This reverts commit 93dabeb.

Change-Id: Ie8c7f2d47885be6626ddb6284474a78dcf09cf33
Task-number: QTBUG-65478
Reviewed-by: Thorbjørn Lund Martsum <[email protected]>
Reviewed-by: Christian Ehrlicher <[email protected]>
Reviewed-by: Friedemann Kleint <[email protected]>
Reviewed-by: Richard Moe Gustavsen <[email protected]>
  • Loading branch information
tmartsum authored and jaheikk committed Jan 5, 2018
1 parent 7e94603 commit d5a11a0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
3 changes: 3 additions & 0 deletions src/widgets/itemviews/qtreeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ void QTreeView::setModel(QAbstractItemModel *model)
// QAbstractItemView connects to a private slot
disconnect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SLOT(_q_rowsRemoved(QModelIndex,int,int)));
// do header layout after the tree
disconnect(d->model, SIGNAL(layoutChanged()),
d->header, SLOT(_q_layoutChanged()));
// QTreeView has a public slot for this
connect(d->model, SIGNAL(rowsRemoved(QModelIndex,int,int)),
this, SLOT(rowsRemoved(QModelIndex,int,int)));
Expand Down
24 changes: 0 additions & 24 deletions tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,17 +313,6 @@ class QtTestModel: public QAbstractItemModel
endRemoveColumns();
}

void removeAddLastColumnLayoutChanged() // for taskQTBUG_41124
{
// make sure QHeaderView::_q_layoutChanged() is called
emit layoutAboutToBeChanged();
--cols;
emit layoutChanged();
emit layoutAboutToBeChanged();
++cols;
emit layoutChanged();
}

void removeAllColumns()
{
beginRemoveColumns(QModelIndex(), 0, cols - 1);
Expand Down Expand Up @@ -1317,19 +1306,6 @@ void tst_QTreeView::columnHidden()
for (int c = 0; c < model.columnCount(); ++c)
QCOMPARE(view.isColumnHidden(c), true);
view.update();

// QTBUG_41124:
// QHeaderViewPrivate::_q_layoutChanged was not called because it was
// disconnected in QTreeView::setModel(). _q_layoutChanged restores
// the hidden sections which is tested here
view.setColumnHidden(model.cols - 1, true);
model.removeAddLastColumnLayoutChanged();
// we removed the last column and added a new one
// (with layoutToBeChanged/layoutChanged() for both) so column
// 1 is a new column and therefore must not be hidden when
// _q_layoutChanged() is called and is doing the right stuff
QCOMPARE(view.isColumnHidden(model.cols - 1), false);

}

void tst_QTreeView::rowHidden()
Expand Down

0 comments on commit d5a11a0

Please sign in to comment.