]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphiniconsview.cpp
SVN_SILENT: updated version number
[dolphin.git] / src / dolphiniconsview.cpp
index a45b08dcf9886b27d7235c07900798ebca0468c6..21debe745e54f9fff5216c1cb93a88fec69a77c3 100644 (file)
@@ -33,6 +33,7 @@
 #include <QApplication>
 #include <QPainter>
 #include <QPoint>
+#include <QScrollBar>
 
 DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controller) :
     KCategorizedView(parent),
@@ -229,8 +230,15 @@ void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event)
         const KFileItem item = itemForIndex(index);
         if (!item.isNull() && item.isDir()) {
             m_dropRect = visualRect(index);
+        } else {
+            m_dropRect.setSize(QSize()); // set as invalid
         }
     }
+    if (event->mimeData()->hasUrls()) {
+        // accept url drops, independently from the destination item
+        event->acceptProposedAction();
+    }
+
     setDirtyRegion(m_dropRect);
 }
 
@@ -260,7 +268,7 @@ void DolphinIconsView::paintEvent(QPaintEvent* event)
     // TODO: remove this code when the issue #160611 is solved in Qt 4.4
     if (m_dragging) {
         const QBrush& brush = viewOptions().palette.brush(QPalette::Normal, QPalette::Highlight);
-        DragAndDropHelper::drawHoverIndication(viewport(), m_dropRect, brush);
+        DragAndDropHelper::drawHoverIndication(this, m_dropRect, brush);
     }
 }
 
@@ -278,6 +286,25 @@ void DolphinIconsView::keyPressEvent(QKeyEvent* event)
     }
 }
 
+void DolphinIconsView::wheelEvent(QWheelEvent* event)
+{
+    KCategorizedView::wheelEvent(event);
+
+    // if the icons are aligned left to right, the vertical wheel event should
+    // be applied to the horizontal scrollbar
+    const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+    const bool scrollHorizontal = (event->orientation() == Qt::Vertical) &&
+                                  (settings->arrangement() == QListView::LeftToRight);
+    if (scrollHorizontal) {
+        QWheelEvent horizEvent(event->pos(),
+                               event->delta(),
+                               event->buttons(),
+                               event->modifiers(),
+                               Qt::Horizontal);
+        QApplication::sendEvent(horizontalScrollBar(), &horizEvent);
+    }
+}
+
 void DolphinIconsView::triggerItem(const QModelIndex& index)
 {
     m_controller->triggerItem(itemForIndex(index));
@@ -296,11 +323,6 @@ void DolphinIconsView::slotShowPreviewChanged()
 
 void DolphinIconsView::slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info)
 {
-    const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
-    if (!settings->showAdditionalInfo()) {
-        return;
-    }
-
     const bool showPreview = m_controller->dolphinView()->showPreview();
     updateGridSize(showPreview, info.count());
 }
@@ -461,8 +483,7 @@ KFileItem DolphinIconsView::itemForIndex(const QModelIndex& index) const
 int DolphinIconsView::additionalInfoCount() const
 {
     const DolphinView* view = m_controller->dolphinView();
-    const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
-    return settings->showAdditionalInfo() ? view->additionalInfo().count() : 0;
+    return view->additionalInfo().count();
 }
 
 #include "dolphiniconsview.moc"