From: Frank Reininghaus Date: Sat, 14 Sep 2013 13:11:17 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/KDE/4.11' X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/083248d16bf92003dfeb2106890ed4b068344dfc?hp=-c Merge remote-tracking branch 'origin/KDE/4.11' --- 083248d16bf92003dfeb2106890ed4b068344dfc diff --combined src/kitemviews/kfileitemlistview.cpp index 1f0fcbd6f,1ffd5019b..8950c9a1e --- a/src/kitemviews/kfileitemlistview.cpp +++ b/src/kitemviews/kfileitemlistview.cpp @@@ -37,7 -37,15 +37,15 @@@ // #define KFILEITEMLISTVIEW_DEBUG namespace { + // If the visible index range changes, KFileItemModelRolesUpdater is not + // informed immediatetly, but with a short delay. This ensures that scrolling + // always feels smooth and is not interrupted by icon loading (which can be + // quite expensive if a disk access is required to determine the final icon). const int ShortInterval = 50; + + // If the icon size changes, a longer delay is used. This prevents that + // the expensive re-generation of all previews is triggered repeatedly when + // chaning the zoom level. const int LongInterval = 300; } @@@ -58,7 -66,7 +66,7 @@@ KFileItemListView::KFileItemListView(QG m_updateIconSizeTimer = new QTimer(this); m_updateIconSizeTimer->setSingleShot(true); - m_updateIconSizeTimer->setInterval(ShortInterval); + m_updateIconSizeTimer->setInterval(LongInterval); connect(m_updateIconSizeTimer, SIGNAL(timeout()), this, SLOT(updateIconSize())); setVisibleRoles(QList() << "text"); @@@ -213,6 -221,12 +221,6 @@@ void KFileItemListView::onPreviewsShown void KFileItemListView::onItemLayoutChanged(ItemLayout current, ItemLayout previous) { - if (previous == DetailsLayout || current == DetailsLayout) { - // The details-layout requires some invisible roles that - // must be added to the model if the new layout is "details". - // If the old layout was "details" the roles will get removed. - applyRolesToModel(); - } KStandardItemListView::onItemLayoutChanged(current, previous); triggerVisibleIndexRangeUpdate(); } @@@ -303,7 -317,6 +311,6 @@@ void KFileItemListView::resizeEvent(QGr void KFileItemListView::slotItemsRemoved(const KItemRangeList& itemRanges) { KStandardItemListView::slotItemsRemoved(itemRanges); - updateTimersInterval(); } void KFileItemListView::slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) @@@ -322,7 -335,12 +329,12 @@@ void KFileItemListView::triggerVisibleI return; } m_modelRolesUpdater->setPaused(true); - m_updateVisibleIndexRangeTimer->start(); + + // If the icon size has been changed recently, wait until + // m_updateIconSizeTimer expires. + if (!m_updateIconSizeTimer->isActive()) { + m_updateVisibleIndexRangeTimer->start(); + } } void KFileItemListView::updateVisibleIndexRange() @@@ -335,17 -353,7 +347,7 @@@ const int count = lastVisibleIndex() - index + 1; m_modelRolesUpdater->setMaximumVisibleItems(maximumVisibleItems()); m_modelRolesUpdater->setVisibleIndexRange(index, count); - - if (m_updateIconSizeTimer->isActive()) { - // If the icon-size update is pending do an immediate update - // of the icon-size before unpausing m_modelRolesUpdater. This prevents - // an unnecessary expensive recreation of all previews afterwards. - m_updateIconSizeTimer->stop(); - m_modelRolesUpdater->setIconSize(availableIconSize()); - } - m_modelRolesUpdater->setPaused(isTransactionActive()); - updateTimersInterval(); } void KFileItemListView::triggerIconSizeUpdate() @@@ -355,6 -363,11 +357,11 @@@ } m_modelRolesUpdater->setPaused(true); m_updateIconSizeTimer->start(); + + // The visible index range will be updated when m_updateIconSizeTimer expires. + // Stop m_updateVisibleIndexRangeTimer to prevent an expensive re-generation + // of all previews (note that the user might change the icon size again soon). + m_updateVisibleIndexRangeTimer->stop(); } void KFileItemListView::updateIconSize() @@@ -365,35 -378,13 +372,13 @@@ m_modelRolesUpdater->setIconSize(availableIconSize()); - if (m_updateVisibleIndexRangeTimer->isActive()) { - // If the visibility-index-range update is pending do an immediate update - // of the range before unpausing m_modelRolesUpdater. This prevents - // an unnecessary expensive recreation of all previews afterwards. - m_updateVisibleIndexRangeTimer->stop(); - const int index = firstVisibleIndex(); - const int count = lastVisibleIndex() - index + 1; - m_modelRolesUpdater->setVisibleIndexRange(index, count); - } + // Update the visible index range (which has most likely changed after the + // icon size change) before unpausing m_modelRolesUpdater. + const int index = firstVisibleIndex(); + const int count = lastVisibleIndex() - index + 1; + m_modelRolesUpdater->setVisibleIndexRange(index, count); m_modelRolesUpdater->setPaused(isTransactionActive()); - updateTimersInterval(); - } - - void KFileItemListView::updateTimersInterval() - { - if (!model()) { - return; - } - - // The ShortInterval is used for cases like switching the directory: If the - // model is empty and filled later the creation of the previews should be done - // as soon as possible. The LongInterval is used when the model already contains - // items and assures that operations like zooming don't result in too many temporary - // recreations of the previews. - - const int interval = (model()->count() <= 0) ? ShortInterval : LongInterval; - m_updateVisibleIndexRangeTimer->setInterval(interval); - m_updateIconSizeTimer->setInterval(interval); } void KFileItemListView::applyRolesToModel() diff --combined src/kitemviews/kitemlistview.cpp index d8edcfc50,a66715090..b3d805a91 --- a/src/kitemviews/kitemlistview.cpp +++ b/src/kitemviews/kitemlistview.cpp @@@ -504,7 -504,11 +504,11 @@@ void KItemListView::scrollToItem(int in const qreal headerHeight = m_headerWidget->size().height(); viewGeometry.adjust(0, headerHeight, 0, 0); } - const QRectF currentRect = itemRect(index); + QRectF currentRect = itemRect(index); + + // Fix for Bug 311099 - View the underscore when using Ctrl + PagDown + currentRect.adjust(-m_styleOption.horizontalMargin, -m_styleOption.verticalMargin, + m_styleOption.horizontalMargin, m_styleOption.verticalMargin); if (!viewGeometry.contains(currentRect)) { qreal newOffset = scrollOffset(); @@@ -1229,13 -1233,6 +1233,13 @@@ void KItemListView::slotItemsChanged(co QAccessible::updateAccessibility(this, 0, QAccessible::TableModelChanged); } +void KItemListView::slotGroupsChanged() +{ + updateVisibleGroupHeaders(); + doLayout(NoAnimation); + updateSiblingsInformation(); +} + void KItemListView::slotGroupedSortingChanged(bool current) { m_grouped = current; @@@ -1530,8 -1527,6 +1534,8 @@@ void KItemListView::setModel(KItemModel this, SLOT(slotItemsRemoved(KItemRangeList))); disconnect(m_model, SIGNAL(itemsMoved(KItemRange,QList)), this, SLOT(slotItemsMoved(KItemRange,QList))); + disconnect(m_model, SIGNAL(groupsChanged()), + this, SLOT(slotGroupsChanged())); disconnect(m_model, SIGNAL(groupedSortingChanged(bool)), this, SLOT(slotGroupedSortingChanged(bool))); disconnect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)), @@@ -1555,8 -1550,6 +1559,8 @@@ this, SLOT(slotItemsRemoved(KItemRangeList))); connect(m_model, SIGNAL(itemsMoved(KItemRange,QList)), this, SLOT(slotItemsMoved(KItemRange,QList))); + connect(m_model, SIGNAL(groupsChanged()), + this, SLOT(slotGroupsChanged())); connect(m_model, SIGNAL(groupedSortingChanged(bool)), this, SLOT(slotGroupedSortingChanged(bool))); connect(m_model, SIGNAL(sortOrderChanged(Qt::SortOrder,Qt::SortOrder)),