From: Peter Penz Date: Thu, 19 Aug 2010 17:30:36 +0000 (+0000) Subject: Set the toggle invisible, if a mouse button has been pressed outside the toggle bound... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/0d54de1d650e16461033e9d7501d54955e4d1ef6 Set the toggle invisible, if a mouse button has been pressed outside the toggle boundaries. This e.g. assures, that the toggle gets invisible during dragging items. BUG: 244304 FIXED-IN: 4.6.0 svn path=/trunk/KDE/kdebase/apps/; revision=1165577 --- diff --git a/src/views/selectionmanager.cpp b/src/views/selectionmanager.cpp index 0d3efae09..ac5f1c939 100644 --- a/src/views/selectionmanager.cpp +++ b/src/views/selectionmanager.cpp @@ -49,12 +49,27 @@ SelectionManager::SelectionManager(QAbstractItemView* parent) : m_toggle->hide(); connect(m_toggle, SIGNAL(clicked(bool)), this, SLOT(setItemSelected(bool))); + + m_view->viewport()->installEventFilter(this); } SelectionManager::~SelectionManager() { } +bool SelectionManager::eventFilter(QObject* watched, QEvent* event) +{ + Q_ASSERT(watched == m_view->viewport()); + if (event->type() == QEvent::MouseButtonPress) { + // Set the toggle invisible, if a mouse button has been pressed + // outside the toggle boundaries. This e.g. assures, that the toggle + // gets invisible during dragging items. + const QRect toggleBounds(m_toggle->mapToGlobal(QPoint(0, 0)), m_toggle->size()); + m_toggle->setVisible(toggleBounds.contains(QCursor::pos())); + } + return QObject::eventFilter(watched, event); +} + void SelectionManager::reset() { m_toggle->reset(); diff --git a/src/views/selectionmanager.h b/src/views/selectionmanager.h index c2fcc88b4..85145a50b 100644 --- a/src/views/selectionmanager.h +++ b/src/views/selectionmanager.h @@ -42,6 +42,7 @@ class SelectionManager : public QObject public: SelectionManager(QAbstractItemView* parent); virtual ~SelectionManager(); + virtual bool eventFilter(QObject* watched, QEvent* event); public slots: /**