]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge remote-tracking branch 'origin/KDE/4.11'
authorFrank Reininghaus <frank78ac@googlemail.com>
Sat, 14 Sep 2013 13:11:17 +0000 (15:11 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Sat, 14 Sep 2013 13:11:17 +0000 (15:11 +0200)
1  2 
src/kitemviews/kfileitemlistview.cpp
src/kitemviews/kitemlistview.cpp

index 1f0fcbd6f7b88b78c3850d072ba7d4a0fdf3fd61,1ffd5019b48dd9ac4719d3bbc12a2460279164bb..8950c9a1ee4f65ce364f07ff7d5d33bfce938f62
  // #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<QByteArray>() << "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()
      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()
      }
      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()
  
      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()
index d8edcfc50ac0a2a54314565ca502d2c2ceaa0e39,a667150904147ecd72568abdf95e9eb0ce332739..b3d805a917ef2c07be519c49acd33a3ce5f6ff8c
@@@ -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<int>)),
                     this,    SLOT(slotItemsMoved(KItemRange,QList<int>)));
 +        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)),
                  this,    SLOT(slotItemsRemoved(KItemRangeList)));
          connect(m_model, SIGNAL(itemsMoved(KItemRange,QList<int>)),
                  this,    SLOT(slotItemsMoved(KItemRange,QList<int>)));
 +        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)),