]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincolumnwidget.cpp
Especially when using the details view in combination with the split functionality...
[dolphin.git] / src / dolphincolumnwidget.cpp
index 31f5c61935663652cb004e081bc99e3f6e44a021..a9b0b8244573d7101e4eecd0e40b7745d6afe644 100644 (file)
@@ -25,6 +25,7 @@
 #include "dolphindirlister.h"
 #include "dolphinsortfilterproxymodel.h"
 #include "dolphinsettings.h"
+#include "dolphinviewautoscroller.h"
 #include "dolphin_columnmodesettings.h"
 #include "dolphin_generalsettings.h"
 #include "draganddrophelper.h"
@@ -45,6 +46,7 @@
 #include <QClipboard>
 #include <QPainter>
 #include <QPoint>
+#include <QScrollBar>
 
 DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
                                          DolphinColumnView* columnView,
@@ -76,6 +78,8 @@ DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
     setVerticalScrollMode(QListView::ScrollPerPixel);
     setHorizontalScrollMode(QListView::ScrollPerPixel);
 
+    new DolphinViewAutoScroller(this);
+
     // apply the column mode settings to the widget
     const ColumnModeSettings* settings = DolphinSettings::instance().columnModeSettings();
     Q_ASSERT(settings != 0);
@@ -142,7 +146,7 @@ DolphinColumnWidget::DolphinColumnWidget(QWidget* parent,
 
     connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
             this, SLOT(updateFont()));
-     
+
     FolderExpander* folderExpander = new FolderExpander(this, m_proxyModel);
     folderExpander->setEnabled(DolphinSettings::instance().generalSettings()->autoExpandFolders());
     connect (folderExpander, SIGNAL(enterDir(const QModelIndex&)),
@@ -277,6 +281,12 @@ KFileItemList DolphinColumnWidget::selectedItems() const
     return itemList;
 }
 
+QMimeData* DolphinColumnWidget::selectionMimeData() const
+{
+    const QItemSelection selection = m_proxyModel->mapSelectionToSource(selectionModel()->selection());
+    return m_dolphinModel->mimeData(selection.indexes());
+}
+
 QStyleOptionViewItem DolphinColumnWidget::viewOptions() const
 {
     QStyleOptionViewItem viewOptions = QListView::viewOptions();
@@ -412,6 +422,10 @@ void DolphinColumnWidget::wheelEvent(QWheelEvent* event)
         return;
     }
 
+    const int height = m_decorationSize.height();
+    const int step = (height >= KIconLoader::SizeHuge) ? height / 10 : (KIconLoader::SizeHuge - height) / 2;
+    verticalScrollBar()->setSingleStep(step);
+
     QListView::wheelEvent(event);
 }
 
@@ -433,6 +447,14 @@ void DolphinColumnWidget::selectionChanged(const QItemSelection& selected, const
     selModel->select(deselected, QItemSelectionModel::Deselect);
 }
 
+void DolphinColumnWidget::currentChanged(const QModelIndex& current, const QModelIndex& previous)
+{
+    QListView::currentChanged(current, previous);
+    if (current.isValid()) {
+        scrollTo(current);
+    }
+}
+
 void DolphinColumnWidget::slotEntered(const QModelIndex& index)
 {
     m_view->m_controller->setItemView(this);