]> 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)
src/kitemviews/kfileitemlistview.cpp
src/kitemviews/kfileitemlistview.h
src/kitemviews/kitemlistview.cpp
src/statusbar/dolphinstatusbar.cpp

index 1f0fcbd6f7b88b78c3850d072ba7d4a0fdf3fd61..8950c9a1ee4f65ce364f07ff7d5d33bfce938f62 100644 (file)
 // #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 @@ KFileItemListView::KFileItemListView(QGraphicsWidget* parent) :
 
     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");
@@ -303,7 +311,6 @@ void KFileItemListView::resizeEvent(QGraphicsSceneResizeEvent* event)
 void KFileItemListView::slotItemsRemoved(const KItemRangeList& itemRanges)
 {
     KStandardItemListView::slotItemsRemoved(itemRanges);
-    updateTimersInterval();
 }
 
 void KFileItemListView::slotSortRoleChanged(const QByteArray& current, const QByteArray& previous)
@@ -322,7 +329,12 @@ void KFileItemListView::triggerVisibleIndexRangeUpdate()
         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 +347,7 @@ 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()
@@ -355,6 +357,11 @@ 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()
@@ -365,35 +372,13 @@ 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 49ff77318cff99b283f88eb02c8d530736dbeb61..bdc63b01bdb21bd8d6c8105f76ff9c3f81743e2a 100644 (file)
@@ -103,8 +103,6 @@ private slots:
     void updateIconSize();
 
 private:
-    void updateTimersInterval();
-
     /**
      * Applies the roles defined by KItemListView::visibleRoles() to the
      * KFileItemModel and KFileItemModelRolesUpdater. As the model does not
index d8edcfc50ac0a2a54314565ca502d2c2ceaa0e39..b3d805a917ef2c07be519c49acd33a3ce5f6ff8c 100644 (file)
@@ -504,7 +504,11 @@ void KItemListView::scrollToItem(int index)
         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();
index bff95664204b6941ee1da1a33b7d195c7572c4fe..671ef4f961b76219333c0832627ed38cc12a176e 100644 (file)
@@ -30,7 +30,6 @@
 #include "statusbarspaceinfo.h"
 
 #include <QApplication>
-#include <QClipboard>
 #include <QHBoxLayout>
 #include <QLabel>
 #include <QProgressBar>
@@ -261,7 +260,6 @@ void DolphinStatusBar::contextMenuEvent(QContextMenuEvent* event)
 
     KMenu menu(this);
 
-    QAction* copyAction = menu.addAction(i18nc("@action:inmenu", "Copy Text"));
     QAction* showZoomSliderAction = menu.addAction(i18nc("@action:inmenu", "Show Zoom Slider"));
     showZoomSliderAction->setCheckable(true);
     showZoomSliderAction->setChecked(GeneralSettings::showZoomSlider());
@@ -271,11 +269,7 @@ void DolphinStatusBar::contextMenuEvent(QContextMenuEvent* event)
     showSpaceInfoAction->setChecked(GeneralSettings::showSpaceInfo());
 
     const QAction* action = menu.exec(QCursor::pos());
-    if (action == copyAction) {
-        QMimeData* mimeData = new QMimeData();
-        mimeData->setText(text());
-        QApplication::clipboard()->setMimeData(mimeData);
-    } else if (action == showZoomSliderAction) {
+    if (action == showZoomSliderAction) {
         const bool visible = showZoomSliderAction->isChecked();
         GeneralSettings::setShowZoomSlider(visible);
         m_zoomSlider->setVisible(visible);