]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphiniconsview.cpp
use a smaller step size when using the scroll wheel
[dolphin.git] / src / dolphiniconsview.cpp
index 9947a27551e8a40e6711190d28e9a211dbef20fa..b95de351a8c6abf6812ac375d0651bc7508bf60a 100644 (file)
@@ -22,6 +22,7 @@
 #include "dolphincategorydrawer.h"
 #include "dolphincontroller.h"
 #include "dolphinsettings.h"
+#include "dolphinviewautoscroller.h"
 #include "dolphin_iconsmodesettings.h"
 #include "dolphin_generalsettings.h"
 #include "draganddrophelper.h"
@@ -61,11 +62,10 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     viewport()->setAcceptDrops(true);
 
     setMouseTracking(true);
+    new DolphinViewAutoScroller(this);
 
-    // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
-    // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
-    // necessary connecting the signal 'singleClick()' or 'doubleClick' and to handle the
-    // RETURN-key in keyPressEvent().
+    connect(this, SIGNAL(clicked(const QModelIndex&)),
+            controller, SLOT(requestTab(const QModelIndex&)));
     if (KGlobalSettings::singleClick()) {
         connect(this, SIGNAL(clicked(const QModelIndex&)),
                 controller, SLOT(triggerItem(const QModelIndex&)));
@@ -154,7 +154,7 @@ void DolphinIconsView::dataChanged(const QModelIndex& topLeft, const QModelIndex
     KCategorizedView::dataChanged(topLeft, bottomRight);
 
     KCategorizedSortFilterProxyModel* proxyModel = dynamic_cast<KCategorizedSortFilterProxyModel*>(model());
-    if ((flow() == QListView::LeftToRight) && !proxyModel->isCategorizedModel()) {
+    if (!proxyModel->isCategorizedModel()) {
         // bypass a QListView issue that items are not layout correctly if the decoration size of
         // an index changes
         scheduleDelayedItemsLayout();
@@ -209,12 +209,12 @@ void DolphinIconsView::startDrag(Qt::DropActions supportedActions)
     // TODO: invoking KCategorizedView::startDrag() should not be necessary, we'll
     // fix this in KDE 4.1
     KCategorizedView::startDrag(supportedActions);
-    DragAndDropHelper::startDrag(this, supportedActions);
+    DragAndDropHelper::instance().startDrag(this, supportedActions, m_controller);
 }
 
 void DolphinIconsView::dragEnterEvent(QDragEnterEvent* event)
 {
-    if (event->mimeData()->hasUrls()) {
+    if (DragAndDropHelper::instance().isMimeDataSupported(event->mimeData())) {
         event->acceptProposedAction();
     }
 }
@@ -242,7 +242,7 @@ void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
             m_dropRect.setSize(QSize()); // set as invalid
         }
     }
-    if (event->mimeData()->hasUrls()) {
+    if (DragAndDropHelper::instance().isMimeDataSupported(event->mimeData())) {
         // accept url drops, independently from the destination item
         event->acceptProposedAction();
     }
@@ -252,17 +252,9 @@ void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
 
 void DolphinIconsView::dropEvent(QDropEvent* event)
 {
-    if (!selectionModel()->isSelected(indexAt(event->pos()))) {
-        const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
-        if (!urls.isEmpty()) {
-            const QModelIndex index = indexAt(event->pos());
-            const KFileItem item = m_controller->itemForIndex(index);
-            m_controller->indicateDroppedUrls(urls,
-                                              m_controller->url(),
-                                              item);
-            event->acceptProposedAction();
-        }
-    }
+    const QModelIndex index = indexAt(event->pos());
+    const KFileItem item = m_controller->itemForIndex(index);
+    m_controller->indicateDroppedUrls(item, m_controller->url(), event);
 
     KCategorizedView::dropEvent(event);
 }
@@ -285,6 +277,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