#include <kdirmodel.h>
#include <kfilepreviewgenerator.h>
#include <QAbstractItemView>
+#include <QApplication>
ViewExtensionsFactory::ViewExtensionsFactory(QAbstractItemView* view,
DolphinViewController* dolphinViewController,
const ViewModeController* viewModeController) :
QObject(view),
+ m_appliedPointingHandCursor(false),
m_view(view),
m_dolphinViewController(dolphinViewController),
m_toolTipManager(0),
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()));
}
ViewExtensionsFactory::~ViewExtensionsFactory()
bool ViewExtensionsFactory::eventFilter(QObject* watched, QEvent* event)
{
Q_UNUSED(watched);
- if ((event->type() == QEvent::Wheel) && (m_selectionManager != 0)) {
- m_selectionManager->reset();
+
+ switch (event->type()) {
+ case QEvent::Wheel:
+ if (m_selectionManager != 0) {
+ m_selectionManager->reset();
+ }
+ break;
+
+ case QEvent::Leave:
+ restoreCursor();
+ break;
+
+ default: break;
}
+
return false;
}
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());