Merge remote-tracking branch 'origin/KDE/4.11'

This commit is contained in:
Frank Reininghaus 2013-07-25 22:35:37 +02:00
commit 611c935e03
2 changed files with 24 additions and 13 deletions

View file

@ -257,6 +257,7 @@ void KItemListContainer::updateScrollOffsetScrollBar()
QScrollBar* scrollOffsetScrollBar = 0; QScrollBar* scrollOffsetScrollBar = 0;
int singleStep = 0; int singleStep = 0;
int pageStep = 0; int pageStep = 0;
int maximum = 0;
if (view->scrollOrientation() == Qt::Vertical) { if (view->scrollOrientation() == Qt::Vertical) {
smoothScroller = m_verticalSmoothScroller; smoothScroller = m_verticalSmoothScroller;
scrollOffsetScrollBar = verticalScrollBar(); scrollOffsetScrollBar = verticalScrollBar();
@ -264,15 +265,21 @@ void KItemListContainer::updateScrollOffsetScrollBar()
// We cannot use view->size().height() because this height might // We cannot use view->size().height() because this height might
// include the header widget, which is not part of the scrolled area. // include the header widget, which is not part of the scrolled area.
pageStep = view->verticalPageStep(); pageStep = view->verticalPageStep();
// However, the total height of the view must be considered for the
// maximum value of the scroll bar. Note that the view's scrollOffset()
// refers to the offset of the top part of the view, which might be
// hidden behind the header.
maximum = qMax(0, int(view->maximumScrollOffset() - view->size().height()));
} else { } else {
smoothScroller = m_horizontalSmoothScroller; smoothScroller = m_horizontalSmoothScroller;
scrollOffsetScrollBar = horizontalScrollBar(); scrollOffsetScrollBar = horizontalScrollBar();
singleStep = view->itemSize().width(); singleStep = view->itemSize().width();
pageStep = view->size().width(); pageStep = view->size().width();
maximum = qMax(0, int(view->maximumScrollOffset() - view->size().width()));
} }
const int value = view->scrollOffset(); const int value = view->scrollOffset();
const int maximum = qMax(0, int(view->maximumScrollOffset() - pageStep));
if (smoothScroller->requestScrollBarUpdate(maximum)) { if (smoothScroller->requestScrollBarUpdate(maximum)) {
const bool updatePolicy = (scrollOffsetScrollBar->maximum() > 0 && maximum == 0) const bool updatePolicy = (scrollOffsetScrollBar->maximum() > 0 && maximum == 0)
|| horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOn; || horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOn;

View file

@ -1635,10 +1635,13 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
widget->resize(itemBounds.size()); widget->resize(itemBounds.size());
if (animate && changedCount < 0) { if (animate && changedCount < 0) {
// Items have been deleted, move the created item to the // Items have been deleted.
// imaginary old position. They will get animated to the new position if (i >= changedIndex) {
// later. // The item is located behind the removed range. Move the
const QRectF itemRect = m_layouter->itemRect(i - changedCount); // created item to the imaginary old position outside the
// view. It will get animated to the new position later.
const int previousIndex = i - changedCount;
const QRectF itemRect = m_layouter->itemRect(previousIndex);
if (itemRect.isEmpty()) { if (itemRect.isEmpty()) {
const QPointF invisibleOldPos = (scrollOrientation() == Qt::Vertical) const QPointF invisibleOldPos = (scrollOrientation() == Qt::Vertical)
? QPointF(0, size().height()) : QPointF(size().width(), 0); ? QPointF(0, size().height()) : QPointF(size().width(), 0);
@ -1648,6 +1651,7 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
} }
applyNewPos = false; applyNewPos = false;
} }
}
if (supportsExpanding && changedCount == 0) { if (supportsExpanding && changedCount == 0) {
if (firstSibblingIndex < 0) { if (firstSibblingIndex < 0) {
@ -1665,7 +1669,7 @@ void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int cha
const bool itemsRemoved = (changedCount < 0); const bool itemsRemoved = (changedCount < 0);
const bool itemsInserted = (changedCount > 0); const bool itemsInserted = (changedCount > 0);
if (itemsRemoved && (i >= changedIndex + changedCount + 1)) { if (itemsRemoved && (i >= changedIndex)) {
// The item is located after the removed items. Animate the moving of the position. // The item is located after the removed items. Animate the moving of the position.
applyNewPos = !moveWidget(widget, newPos); applyNewPos = !moveWidget(widget, newPos);
} else if (itemsInserted && i >= changedIndex) { } else if (itemsInserted && i >= changedIndex) {