]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/viewextensionsfactory.cpp
SVN_SILENT made messages (.desktop file)
[dolphin.git] / src / views / viewextensionsfactory.cpp
index 1523962538dcd88b35acf7e1e0123e38e23a984e..a52871ff447afe1d62c2a1cdc10eed9a51bc82dc 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at>                  *
+ *   Copyright (C) 2009 by Peter Penz <peter.penz19@gmail.com>             *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -33,9 +33,9 @@
 
 #include "dolphin_generalsettings.h"
 
-#include <kdirlister.h>
-#include <kdirmodel.h>
-#include <kfilepreviewgenerator.h>
+#include <KDirLister>
+#include <KDirModel>
+#include <KFilePreviewGenerator>
 #include <QAbstractItemView>
 #include <QApplication>
 
@@ -43,7 +43,6 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
                                              DolphinViewController* dolphinViewController,
                                              const ViewModeController* viewModeController) :
     QObject(view),
-    m_appliedPointingHandCursor(false),
     m_view(view),
     m_dolphinViewController(dolphinViewController),
     m_toolTipManager(0),
@@ -74,17 +73,21 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
             this, SLOT(slotZoomLevelChanged()));
     connect(viewModeController, SIGNAL(cancelPreviews()),
             this, SLOT(cancelPreviews()));
+
+    // slotPreviewChanged() is connected as Qt::QueuedConnection to prevent performance
+    // issues when the directory lister changes its URL after the preview-changes have
+    // been applied. Usecase: Switch from directory A having no previews to
+    // directory B with previews (see sequence in DolphinView::setUrl()).
     connect(dolphinViewController->view(), SIGNAL(showPreviewChanged()),
-            this, SLOT(slotShowPreviewChanged()));
+            this, SLOT(slotShowPreviewChanged()),
+            Qt::QueuedConnection);
 
     // initialize selection manager
-    if (settings->showSelectionToggle()) {
-        m_selectionManager = new SelectionManager(view);
-        connect(m_selectionManager, SIGNAL(selectionChanged()),
-                this, SLOT(requestActivation()));
-        connect(viewModeController, SIGNAL(urlChanged(const KUrl&)),
-                m_selectionManager, SLOT(reset()));
-    }
+    m_selectionManager = new SelectionManager(view);
+    connect(m_selectionManager, SIGNAL(selectionChanged()),
+            this, SLOT(requestActivation()));
+    connect(viewModeController, SIGNAL(urlChanged(const KUrl&)),
+            m_selectionManager, SLOT(reset()));
 
     // initialize auto scroller
     m_autoScroller = new DolphinViewAutoScroller(view);
@@ -129,11 +132,6 @@ ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
             this, SLOT(slotNameFilterChanged(const QString&)));
 
     view->viewport()->installEventFilter(this);
-
-    // Apply a pointing-hand cursor when hovering files
-    connect(view, SIGNAL(entered(const QModelIndex&)), SLOT(applyPointingHandCursor()));
-    connect(view, SIGNAL(viewportEntered()), SLOT(restoreCursor()));
-    connect(viewModeController, SIGNAL(urlChanged(const KUrl&)), SLOT(restoreCursor()));
 }
 
 ViewExtensionsFactory::~ViewExtensionsFactory()
@@ -163,28 +161,16 @@ bool ViewExtensionsFactory::autoFolderExpandingEnabled() const
 bool ViewExtensionsFactory::eventFilter(QObject* watched, QEvent* event)
 {
     Q_UNUSED(watched);
-
-    switch (event->type()) {
-    case QEvent::Wheel:
-        if (m_selectionManager != 0) {
-            m_selectionManager->reset();
-        }
-        break;
-
-    case QEvent::Leave:
-        restoreCursor();
-        break;
-
-    default: break;
+    if ((event->type() == QEvent::Wheel) && m_selectionManager) {
+        m_selectionManager->reset();
     }
-
     return false;
 }
 
 void ViewExtensionsFactory::slotZoomLevelChanged()
 {
     m_previewGenerator->updateIcons();
-    if (m_selectionManager != 0) {
+    if (m_selectionManager) {
         m_selectionManager->reset();
     }
 }
@@ -254,22 +240,6 @@ void ViewExtensionsFactory::requestActivation()
     m_dolphinViewController->requestActivation();
 }
 
-void ViewExtensionsFactory::applyPointingHandCursor()
-{
-    if (!m_appliedPointingHandCursor &&  !(QApplication::mouseButtons() & Qt::LeftButton)) {
-        QApplication::setOverrideCursor(QCursor(Qt::PointingHandCursor));
-        m_appliedPointingHandCursor = true;
-    }
-}
-
-void ViewExtensionsFactory::restoreCursor()
-{
-    if (m_appliedPointingHandCursor) {
-        QApplication::restoreOverrideCursor();
-        m_appliedPointingHandCursor = false;
-    }
-}
-
 DolphinSortFilterProxyModel* ViewExtensionsFactory::proxyModel() const
 {
     return static_cast<DolphinSortFilterProxyModel*>(m_view->model());