+bool KItemListView::changesItemGridLayout(const QSizeF& newGridSize, const QSizeF& newItemSize) const
+{
+ if (newItemSize.isEmpty() || newGridSize.isEmpty()) {
+ return false;
+ }
+
+ if (m_layouter->scrollOrientation() == Qt::Vertical) {
+ const qreal itemWidth = m_layouter->itemSize().width();
+ if (itemWidth > 0) {
+ const int oldColumnCount = m_layouter->size().width() / itemWidth;
+ const int newColumnCount = newGridSize.width() / newItemSize.width();
+ return oldColumnCount != newColumnCount;
+ }
+ } else {
+ const qreal itemHeight = m_layouter->itemSize().height();
+ if (itemHeight > 0) {
+ const int oldRowCount = m_layouter->size().height() / itemHeight;
+ const int newRowCount = newGridSize.height() / newItemSize.height();
+ return oldRowCount != newRowCount;
+ }
+ }
+
+ return false;
+}
+
+bool KItemListView::animateChangedItemCount(int changedItemCount) const
+{
+ if (m_layouter->size().isEmpty() || m_layouter->itemSize().isEmpty()) {
+ return false;
+ }
+
+ const int maximum = (scrollOrientation() == Qt::Vertical)
+ ? m_layouter->size().width() / m_layouter->itemSize().width()
+ : m_layouter->size().height() / m_layouter->itemSize().height();
+ // Only animate if up to 2/3 of a row or column are inserted or removed
+ return changedItemCount <= maximum * 2 / 3;
+}
+