]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphiniconsview.cpp
* Don't ignore the maximum file size for previews in the information panel. Correspon...
[dolphin.git] / src / dolphiniconsview.cpp
index b95de351a8c6abf6812ac375d0651bc7508bf60a..d30ef321eb974e416d839ece5e8eb7585154cf57 100644 (file)
@@ -43,6 +43,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     m_enableScrollTo(false),
     m_controller(controller),
     m_selectionManager(0),
+    m_autoScroller(0),
     m_categoryDrawer(0),
     m_font(),
     m_decorationSize(),
@@ -62,7 +63,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     viewport()->setAcceptDrops(true);
 
     setMouseTracking(true);
-    new DolphinViewAutoScroller(this);
+    m_autoScroller = new DolphinViewAutoScroller(this);
 
     connect(this, SIGNAL(clicked(const QModelIndex&)),
             controller, SLOT(requestTab(const QModelIndex&)));
@@ -277,10 +278,10 @@ void DolphinIconsView::wheelEvent(QWheelEvent* event)
         event->ignore();
         return;
     }
-    
+
     horizontalScrollBar()->setSingleStep(m_itemSize.width() / 10);
     verticalScrollBar()->setSingleStep(m_itemSize.height() / 10);
-    
+
     KCategorizedView::wheelEvent(event);
     // if the icons are aligned left to right, the vertical wheel event should
     // be applied to the horizontal scrollbar
@@ -314,6 +315,14 @@ void DolphinIconsView::leaveEvent(QEvent* event)
     m_controller->emitViewportEntered();
 }
 
+void DolphinIconsView::currentChanged(const QModelIndex& current, const QModelIndex& previous)
+{
+    KCategorizedView::currentChanged(current, previous);
+    if (current.isValid() && !m_autoScroller->isActive()) {
+        scrollTo(current);
+    }
+}
+
 void DolphinIconsView::slotShowPreviewChanged()
 {
     const DolphinView* view = m_controller->dolphinView();