]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphiniconsview.cpp
fixed most regressions due to the previous column-view refactoring
[dolphin.git] / src / dolphiniconsview.cpp
index 6b584612cc9cec51fcfb74ba9b84370c314f132e..f1ad25e3dd62b9300b119e44e511d3fcf80b58c6 100644 (file)
@@ -26,6 +26,7 @@
 #include "dolphin_iconsmodesettings.h"
 
 #include <kdialog.h>
+#include <kdirmodel.h>
 
 #include <QAbstractProxyModel>
 #include <QApplication>
@@ -53,13 +54,11 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     // RETURN-key in keyPressEvent().
     if (KGlobalSettings::singleClick()) {
         connect(this, SIGNAL(clicked(const QModelIndex&)),
-                controller, SLOT(triggerItem(const QModelIndex&)));
+                this, SLOT(triggerItem(const QModelIndex&)));
     } else {
         connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
-                controller, SLOT(triggerItem(const QModelIndex&)));
+                this, SLOT(triggerItem(const QModelIndex&)));
     }
-    connect(this, SIGNAL(entered(const QModelIndex&)),
-            controller, SLOT(emitItemEntered(const QModelIndex&)));
     connect(this, SIGNAL(viewportEntered()),
             controller, SLOT(emitViewportEntered()));
     connect(controller, SIGNAL(showPreviewChanged(bool)),
@@ -71,6 +70,9 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     connect(controller, SIGNAL(zoomOut()),
             this, SLOT(zoomOut()));
 
+    connect(this, SIGNAL(entered(const QModelIndex&)),
+            this, SLOT(slotEntered(const QModelIndex&)));
+
     // apply the icons mode settings to the widget
     const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
     Q_ASSERT(settings != 0);
@@ -220,14 +222,24 @@ void DolphinIconsView::keyPressEvent(QKeyEvent* event)
 
     const QItemSelectionModel* selModel = selectionModel();
     const QModelIndex currentIndex = selModel->currentIndex();
-    const bool triggerItem = currentIndex.isValid()
-                             && (event->key() == Qt::Key_Return)
-                             && (selModel->selectedIndexes().count() <= 1);
-    if (triggerItem) {
-        m_controller->triggerItem(currentIndex);
+    const bool trigger = currentIndex.isValid()
+                         && (event->key() == Qt::Key_Return)
+                         && (selModel->selectedIndexes().count() <= 1);
+    if (trigger) {
+        triggerItem(currentIndex);
     }
 }
 
+void DolphinIconsView::triggerItem(const QModelIndex& index)
+{
+    m_controller->triggerItem(itemForIndex(index));
+}
+
+void DolphinIconsView::slotEntered(const QModelIndex& index)
+{
+    m_controller->emitItemEntered(itemForIndex(index));
+}
+
 void DolphinIconsView::slotShowPreviewChanged(bool showPreview)
 {
     updateGridSize(showPreview, m_controller->additionalInfoCount());
@@ -381,4 +393,13 @@ void DolphinIconsView::updateGridSize(bool showPreview, int additionalInfoCount)
     m_controller->setZoomOutPossible(isZoomOutPossible());
 }
 
+KFileItem DolphinIconsView::itemForIndex(const QModelIndex& index) const
+{
+    QAbstractProxyModel* proxyModel = static_cast<QAbstractProxyModel*>(model());
+    KDirModel* dirModel = static_cast<KDirModel*>(proxyModel->sourceModel());
+    const QModelIndex dirIndex = proxyModel->mapToSource(index);
+    return dirModel->itemForIndex(dirIndex);
+}
+
+
 #include "dolphiniconsview.moc"