void KItemListView::onModelChanged(KItemModelBase* current, KItemModelBase* previous)
{
+ Q_UNUSED(current);
Q_UNUSED(previous);
-
- m_sizeHintResolver->clearCache();
- const int itemCount = current->count();
- if (itemCount > 0) {
- m_sizeHintResolver->itemsInserted(0, itemCount);
- }
}
void KItemListView::onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous)
}
}
+ // In case if items of the same group have been inserted before an item that
+ // currently represents the first item of the group, the group header of
+ // this item must be removed.
+ if (m_grouped && index + count < m_model->count()) {
+ updateGroupHeaderForWidget(m_visibleItems.value(index + count));
+ }
+
if (m_model->count() == count && m_activeTransactions == 0) {
// Check whether a scrollbar is required to show the inserted items. In this case
// the size of the layouter will be decreased before calling doLayout(): This prevents
}
}
+ // In case if the first item of a group has been removed, the group header
+ // must be applied to the next visible item.
+ if (m_grouped && index < m_model->count()) {
+ updateGroupHeaderForWidget(m_visibleItems.value(index));
+ }
+
if (!hasMultipleRanges) {
// The decrease-layout-size optimization in KItemListView::slotItemsInserted()
// assumes an updated geometry. If items are removed during an active transaction,
this, SLOT(slotSortRoleChanged(QByteArray,QByteArray)));
}
+ m_sizeHintResolver->clearCache();
+
m_model = model;
m_layouter->setModel(model);
m_grouped = model->groupedSorting();
const int itemCount = m_model->count();
if (itemCount > 0) {
+ m_sizeHintResolver->itemsInserted(0, itemCount);
slotItemsInserted(KItemRangeList() << KItemRange(0, itemCount));
}
}
bool startMovingAnim = false;
- // When having a grid the moving-animation should only be started, if it is done within
- // one row in the vertical scroll-orientation or one column in the horizontal scroll-orientation.
- // Otherwise instead of a moving-animation a create-animation on the new position will be used
- // instead. This is done to prevent overlapping (and confusing) moving-animations.
- const int index = widget->index();
- const Cell cell = m_visibleCells.value(index);
- if (cell.column >= 0 && cell.row >= 0) {
- if (scrollOrientation() == Qt::Vertical) {
- startMovingAnim = (cell.row == m_layouter->itemRow(index));
- } else {
- startMovingAnim = (cell.column == m_layouter->itemColumn(index));
+ if (m_itemSize.isEmpty()) {
+ // The items are not aligned in a grid but either as columns or rows.
+ startMovingAnim = !supportsItemExpanding();
+ } else {
+ // When having a grid the moving-animation should only be started, if it is done within
+ // one row in the vertical scroll-orientation or one column in the horizontal scroll-orientation.
+ // Otherwise instead of a moving-animation a create-animation on the new position will be used
+ // instead. This is done to prevent overlapping (and confusing) moving-animations.
+ const int index = widget->index();
+ const Cell cell = m_visibleCells.value(index);
+ if (cell.column >= 0 && cell.row >= 0) {
+ if (scrollOrientation() == Qt::Vertical) {
+ startMovingAnim = (cell.row == m_layouter->itemRow(index));
+ } else {
+ startMovingAnim = (cell.column == m_layouter->itemColumn(index));
+ }
}
}
// In the vertical scroll orientation the group header should always span
// the whole width no matter which temporary position the parent widget
// has. In this case the x-position and width will be adjusted manually.
- groupHeader->setPos(-widget->x(), -groupHeaderRect.height());
- groupHeader->resize(size().width(), groupHeaderRect.size().height());
+ const qreal x = -widget->x() - itemOffset();
+ const qreal width = maximumItemOffset();
+ groupHeader->setPos(x, -groupHeaderRect.height());
+ groupHeader->resize(width, groupHeaderRect.size().height());
} else {
groupHeader->setPos(groupHeaderRect.x() - itemRect.x(), -widget->y());
groupHeader->resize(groupHeaderRect.size());
bool KItemListView::animateChangedItemCount(int changedItemCount) const
{
+ if (m_itemSize.isEmpty()) {
+ // We have only columns or only rows, but no grid: An animation is usually
+ // welcome when inserting or removing items.
+ return !supportsItemExpanding();
+ }
+
if (m_layouter->size().isEmpty() || m_layouter->itemSize().isEmpty()) {
return false;
}