┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/selectiontoggle.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2010-10-08 19:10:53 +0000
committerPeter Penz <[email protected]>2010-10-08 19:10:53 +0000
commitf955ee200da38d80be4833d8b421221874896ca1 (patch)
tree28cb1fa19131e59b864be7ef1d92a529cf1ce1ac /src/views/selectiontoggle.cpp
parentfff40080bcc4719526cde17f826810d1b193ad52 (diff)
Move the changing of the cursor-shape from the extensions-factory and the selection-toggle to the selection-manager. Beside simplifying the code this also solves some corner-cases where the shape has not been restored correctly.
svn path=/trunk/KDE/kdebase/apps/; revision=1183934
Diffstat (limited to 'src/views/selectiontoggle.cpp')
-rw-r--r--src/views/selectiontoggle.cpp58
1 files changed, 8 insertions, 50 deletions
diff --git a/src/views/selectiontoggle.cpp b/src/views/selectiontoggle.cpp
index cbd273b11..c1272fa0f 100644
--- a/src/views/selectiontoggle.cpp
+++ b/src/views/selectiontoggle.cpp
@@ -32,11 +32,12 @@
#include <QTimer>
#include <QTimeLine>
+#include <kdebug.h>
+
SelectionToggle::SelectionToggle(QWidget* parent) :
QAbstractButton(parent),
m_isHovered(false),
m_leftMouseButtonPressed(false),
- m_appliedArrowCursor(false),
m_fadingValue(0),
m_margin(0),
m_icon(),
@@ -106,25 +107,12 @@ void SelectionToggle::setVisible(bool visible)
bool SelectionToggle::eventFilter(QObject* obj, QEvent* event)
{
- if (obj == parent()) {
- switch (event->type()) {
- case QEvent::Leave:
- hide();
- break;
-
- case QEvent::MouseMove:
- if (m_leftMouseButtonPressed) {
- // Don't forward mouse move events to the viewport,
- // otherwise a rubberband selection will be shown when
- // clicking on the selection toggle and moving the mouse
- // above the viewport.
- return true;
- }
- break;
-
- default:
- break;
- }
+ if ((obj == parent()) && (event->type() == QEvent::MouseMove) && m_leftMouseButtonPressed) {
+ // Don't forward mouse move events to the viewport,
+ // otherwise a rubberband selection will be shown when
+ // clicking on the selection toggle and moving the mouse
+ // above the viewport.
+ return true;
}
return QAbstractButton::eventFilter(obj, event);
@@ -134,19 +122,6 @@ void SelectionToggle::enterEvent(QEvent* event)
{
QAbstractButton::enterEvent(event);
- if (!m_appliedArrowCursor) {
- m_appliedArrowCursor = true;
- // Apply the arrow asynchronously. This is required for
- // the following usecase:
- // 1. Cursor is above the viewport left beside an item
- // 2. Cursor is moved above the item, so that the selection-toggle
- // and the item are entered equally.
- // In this situation it is not defined who gets the enter-event first.
- // As the selection-toggle is above the item, it should overwrite possible
- // cursor changes done by the item.
- QTimer::singleShot(0, this, SLOT(applyArrowCursor()));
- }
-
// if the mouse cursor is above the selection toggle, display
// it immediately without fading timer
m_isHovered = true;
@@ -163,13 +138,6 @@ void SelectionToggle::leaveEvent(QEvent* event)
{
QAbstractButton::leaveEvent(event);
- if (m_appliedArrowCursor) {
- // Reset the cursor asynchronously. See SelectionToggle::enterEvent()
- // for a more information.
- m_appliedArrowCursor = false;
- QTimer::singleShot(0, this, SLOT(restoreCursor()));
- }
-
m_isHovered = false;
update();
}
@@ -245,16 +213,6 @@ void SelectionToggle::refreshIcon()
setIconOverlay(isChecked());
}
-void SelectionToggle::applyArrowCursor()
-{
- QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor));
-}
-
-void SelectionToggle::restoreCursor()
-{
- QApplication::restoreOverrideCursor();
-}
-
void SelectionToggle::startFading()
{
Q_ASSERT(m_fadingTimeLine == 0);