QItemWidgets: emit layoutChanged with proper sortHint
layout(AboutToBe)Changed gained a sortHint parameter with Qt5.0 but the itemmodels did not set a proper value where possible. Since the sorting of the ItemWidgets is only per column, it is reasonable to pass QAbstractItemModel::VerticalSortHint in the various layoutChanged calls. Change-Id: Ia11322bae1a96bc0d7d8422558a11cdfe04c2808 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>bb10
parent
47f815cb26
commit
6d648961c6
|
|
@ -329,7 +329,7 @@ void QListModel::sort(int column, Qt::SortOrder order)
|
|||
if (column != 0)
|
||||
return;
|
||||
|
||||
emit layoutAboutToBeChanged();
|
||||
emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
|
||||
QVector < QPair<QListWidgetItem*,int> > sorting(items.count());
|
||||
for (int i = 0; i < items.count(); ++i) {
|
||||
|
|
@ -353,7 +353,7 @@ void QListModel::sort(int column, Qt::SortOrder order)
|
|||
}
|
||||
changePersistentIndexList(fromIndexes, toIndexes);
|
||||
|
||||
emit layoutChanged();
|
||||
emit layoutChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ void QTableModel::setItem(int row, int column, QTableWidgetItem *item)
|
|||
sortedRow = qMax((int)(it - colItems.begin()), 0);
|
||||
}
|
||||
if (sortedRow != row) {
|
||||
emit layoutAboutToBeChanged();
|
||||
emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
// move the items @ row to sortedRow
|
||||
int cc = columnCount();
|
||||
QVector<QTableWidgetItem*> rowItems(cc);
|
||||
|
|
@ -209,7 +209,7 @@ void QTableModel::setItem(int row, int column, QTableWidgetItem *item)
|
|||
changePersistentIndexList(oldPersistentIndexes,
|
||||
newPersistentIndexes);
|
||||
|
||||
emit layoutChanged();
|
||||
emit layoutChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -548,12 +548,12 @@ void QTableModel::sort(int column, Qt::SortOrder order)
|
|||
}
|
||||
}
|
||||
|
||||
emit layoutAboutToBeChanged();
|
||||
emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
|
||||
tableItems = sorted_table;
|
||||
changePersistentIndexList(from, to); // ### slow
|
||||
|
||||
emit layoutChanged();
|
||||
emit layoutChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -598,7 +598,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
|
|||
vit = colItems.insert(vit, item);
|
||||
if (newRow != oldRow) {
|
||||
if (!changed) {
|
||||
emit layoutAboutToBeChanged();
|
||||
emit layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
oldPersistentIndexes = persistentIndexList();
|
||||
newPersistentIndexes = oldPersistentIndexes;
|
||||
changed = true;
|
||||
|
|
@ -633,7 +633,7 @@ void QTableModel::ensureSorted(int column, Qt::SortOrder order,
|
|||
verticalHeaderItems = newVertical;
|
||||
changePersistentIndexList(oldPersistentIndexes,
|
||||
newPersistentIndexes);
|
||||
emit layoutChanged();
|
||||
emit layoutChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -656,7 +656,7 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
|
|||
// we are going to change the persistent indexes, so we need to prepare
|
||||
if (!changed) { // this will only happen once
|
||||
changed = true;
|
||||
emit layoutAboutToBeChanged(); // the selection model needs to know
|
||||
emit layoutAboutToBeChanged({parent}, QAbstractItemModel::VerticalSortHint); // the selection model needs to know
|
||||
oldPersistentIndexes = persistentIndexList();
|
||||
newPersistentIndexes = oldPersistentIndexes;
|
||||
}
|
||||
|
|
@ -689,7 +689,7 @@ void QTreeModel::ensureSorted(int column, Qt::SortOrder order,
|
|||
if (changed) {
|
||||
itm->children = lst;
|
||||
changePersistentIndexList(oldPersistentIndexes, newPersistentIndexes);
|
||||
emit layoutChanged();
|
||||
emit layoutChanged({parent}, QAbstractItemModel::VerticalSortHint);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2185,9 +2185,9 @@ void QTreeWidgetItem::sortChildren(int column, Qt::SortOrder order, bool climb)
|
|||
QTreeModel::SkipSorting skipSorting(model);
|
||||
int oldSortColumn = view->d_func()->explicitSortColumn;
|
||||
view->d_func()->explicitSortColumn = column;
|
||||
emit model->layoutAboutToBeChanged();
|
||||
emit model->layoutAboutToBeChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
d->sortChildren(column, order, climb);
|
||||
emit model->layoutChanged();
|
||||
emit model->layoutChanged({}, QAbstractItemModel::VerticalSortHint);
|
||||
view->d_func()->explicitSortColumn = oldSortColumn;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue