- Disable performance debugging output
- Force a synchronous layout during scrolling. This prevents having a jerky
scroll-animation if there are pending operations ongoing in parallel.
- Minor coding style cleanups
#include <QTextLine>
#include <QTimer>
#include <QTextLine>
#include <QTimer>
-#define KFILEITEMLISTVIEW_DEBUG
+// #define KFILEITEMLISTVIEW_DEBUG
namespace {
const int ShortInterval = 50;
namespace {
const int ShortInterval = 50;
#include <QTextLayout>
#include <QTextLine>
#include <QTextLayout>
#include <QTextLine>
-//#define KFILEITEMLISTWIDGET_DEBUG
+// #define KFILEITEMLISTWIDGET_DEBUG
KFileItemListWidget::KFileItemListWidget(QGraphicsItem* parent) :
KItemListWidget(parent),
KFileItemListWidget::KFileItemListWidget(QGraphicsItem* parent) :
KItemListWidget(parent),
#include <QMimeData>
#include <QTimer>
#include <QMimeData>
#include <QTimer>
-#define KFILEITEMMODEL_DEBUG
+// #define KFILEITEMMODEL_DEBUG
KFileItemModel::KFileItemModel(KDirLister* dirLister, QObject* parent) :
KItemModelBase("name", parent),
KFileItemModel::KFileItemModel(KDirLister* dirLister, QObject* parent) :
KItemModelBase("name", parent),
-#define KFILEITEMMODELROLESUPDATER_DEBUG
+// #define KFILEITEMMODELROLESUPDATER_DEBUG
namespace {
// Maximum time in ms that the KFileItemModelRolesUpdater
namespace {
// Maximum time in ms that the KFileItemModelRolesUpdater
- doLayout(Animation, 0, 0);
onScrollOrientationChanged(orientation, previousOrientation);
emit scrollOrientationChanged(orientation, previousOrientation);
onScrollOrientationChanged(orientation, previousOrientation);
emit scrollOrientationChanged(orientation, previousOrientation);
}
m_sizeHintResolver->clearCache();
}
m_sizeHintResolver->clearCache();
- doLayout(Animation, 0, 0);
onItemSizeChanged(itemSize, previousSize);
}
onItemSizeChanged(itemSize, previousSize);
}
m_layouter->setScrollOffset(offset);
m_animation->setScrollOffset(offset);
m_layouter->setScrollOffset(offset);
m_animation->setScrollOffset(offset);
- if (!m_layoutTimer->isActive()) {
- doLayout(NoAnimation, 0, 0);
- }
+
+ // Don't check whether the m_layoutTimer is active: Changing the
+ // scroll offset must always trigger a synchronous layout, otherwise
+ // the smooth-scrolling might get jerky.
+ doLayout(NoAnimation);
onScrollOffsetChanged(offset, previousOffset);
}
onScrollOffsetChanged(offset, previousOffset);
}
m_header->setPos(-offset, 0);
}
if (!m_layoutTimer->isActive()) {
m_header->setPos(-offset, 0);
}
if (!m_layoutTimer->isActive()) {
- doLayout(NoAnimation, 0, 0);
}
updateVisibleRolesSizes();
}
updateVisibleRolesSizes();
- doLayout(Animation, 0, 0);
onVisibleRolesChanged(roles, previousRoles);
}
onVisibleRolesChanged(roles, previousRoles);
}
}
m_sizeHintResolver->clearCache();
}
m_sizeHintResolver->clearCache();
- doLayout(Animation, 0, 0);
onStyleOptionChanged(option, previousOption);
}
onStyleOptionChanged(option, previousOption);
}
if (m_activeTransactions == 0) {
onTransactionEnd();
if (m_activeTransactions == 0) {
onTransactionEnd();
- doLayout(Animation, 0, 0);
m_layouter->markAsDirty();
if (m_model->count() == count && maximumScrollOffset() > size().height()) {
m_layouter->markAsDirty();
if (m_model->count() == count && maximumScrollOffset() > size().height()) {
- kDebug() << "Scrollbar required, skipping layout";
const int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
QSizeF layouterSize = m_layouter->size();
if (scrollOrientation() == Qt::Vertical) {
const int scrollBarExtent = style()->pixelMetric(QStyle::PM_ScrollBarExtent);
QSizeF layouterSize = m_layouter->size();
if (scrollOrientation() == Qt::Vertical) {
- doLayout(NoAnimation, 0, 0);
}
void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
}
void KItemListView::slotItemsChanged(const KItemRangeList& itemRanges,
// The sort-role has been changed which might result
// in modified group headers
updateVisibleGroupHeaders();
// The sort-role has been changed which might result
// in modified group headers
updateVisibleGroupHeaders();
- doLayout(NoAnimation, 0, 0);
Q_ASSERT(m_visibleGroups.isEmpty());
}
Q_ASSERT(m_visibleGroups.isEmpty());
}
- doLayout(Animation, 0, 0);
}
void KItemListView::slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous)
}
void KItemListView::slotSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous)
Q_UNUSED(previous);
if (m_grouped) {
updateVisibleGroupHeaders();
Q_UNUSED(previous);
if (m_grouped) {
updateVisibleGroupHeaders();
- doLayout(Animation, 0, 0);
Q_UNUSED(previous);
if (m_grouped) {
updateVisibleGroupHeaders();
Q_UNUSED(previous);
if (m_grouped) {
updateVisibleGroupHeaders();
- doLayout(Animation, 0, 0);
void KItemListView::slotLayoutTimerFinished()
{
m_layouter->setSize(geometry().size());
void KItemListView::slotLayoutTimerFinished()
{
m_layouter->setSize(geometry().size());
- doLayout(Animation, 0, 0);
}
void KItemListView::slotRubberBandPosChanged()
}
void KItemListView::slotRubberBandPosChanged()
widget->setVisibleRolesSizes(m_stretchedVisibleRolesSizes);
}
widget->setVisibleRolesSizes(m_stretchedVisibleRolesSizes);
}
- doLayout(Animation, 0, 0);
void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount)
{
if (m_layoutTimer->isActive()) {
void KItemListView::doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount)
{
if (m_layoutTimer->isActive()) {
- kDebug() << "Stopping layout timer, synchronous layout requested";
if (animate && changedCount < 0) {
// Items have been deleted, move the created item to the
if (animate && changedCount < 0) {
// Items have been deleted, move the created item to the
- // imaginary old position.
+ // imaginary old position. They will get animated to the new position
+ // later.
const QRectF itemRect = m_layouter->itemRect(i - changedCount);
if (itemRect.isEmpty()) {
const QPointF invisibleOldPos = (scrollOrientation() == Qt::Vertical)
const QRectF itemRect = m_layouter->itemRect(i - changedCount);
if (itemRect.isEmpty()) {
const QPointF invisibleOldPos = (scrollOrientation() == Qt::Vertical)
if (animate) {
const bool itemsRemoved = (changedCount < 0);
const bool itemsInserted = (changedCount > 0);
if (animate) {
const bool itemsRemoved = (changedCount < 0);
const bool itemsInserted = (changedCount > 0);
if (itemsRemoved && (i >= changedIndex + changedCount + 1)) {
// The item is located after the removed items. Animate the moving of the position.
m_animation->start(widget, KItemListViewAnimation::MovingAnimation, newPos);
if (itemsRemoved && (i >= changedIndex + changedCount + 1)) {
// The item is located after the removed items. Animate the moving of the position.
m_animation->start(widget, KItemListViewAnimation::MovingAnimation, newPos);
KItemListRubberBand* rubberBand() const;
KItemListRubberBand* rubberBand() const;
- void doLayout(LayoutAnimationHint hint, int changedIndex, int changedCount);
- void doGroupHeadersLayout(LayoutAnimationHint hint, int changedIndex, int changedCount);
+ void doLayout(LayoutAnimationHint hint, int changedIndex = 0, int changedCount = 0);
+
void emitOffsetChanges();
KItemListWidget* createWidget(int index);
void emitOffsetChanges();
KItemListWidget* createWidget(int index);
-#define KITEMLISTVIEWLAYOUTER_DEBUG
+// #define KITEMLISTVIEWLAYOUTER_DEBUG
KItemListViewLayouter::KItemListViewLayouter(QObject* parent) :
QObject(parent),
KItemListViewLayouter::KItemListViewLayouter(QObject* parent) :
QObject(parent),