Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Ben Boeckel
QtTesting
Commits
b85c0b4f
Commit
b85c0b4f
authored
Dec 15, 2011
by
Benjamin Long
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mousewheel support to both basic widget and itemView
parent
1452c3d2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
3 deletions
+63
-3
pqAbstractItemViewEventPlayer.cxx
pqAbstractItemViewEventPlayer.cxx
+10
-2
pqAbstractItemViewEventTranslator.cxx
pqAbstractItemViewEventTranslator.cxx
+28
-0
pqBasicWidgetEventPlayer.cxx
pqBasicWidgetEventPlayer.cxx
+9
-1
pqBasicWidgetEventTranslator.cxx
pqBasicWidgetEventTranslator.cxx
+16
-0
No files found.
pqAbstractItemViewEventPlayer.cxx
View file @
b85c0b4f
...
...
@@ -40,6 +40,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QtDebug>
#include <QList>
#include <QListWidget>
#include <QWheelEvent>
#include "pqEventDispatcher.h"
...
...
@@ -152,7 +153,6 @@ bool pqAbstractItemViewEventPlayer::playEvent(QObject* Object, const QString& Co
QStringList
args
=
Arguments
.
split
(
','
);
if
(
args
.
size
()
==
6
)
{
Qt
::
MouseButton
button
=
static_cast
<
Qt
::
MouseButton
>
(
args
[
0
].
toInt
());
Qt
::
MouseButtons
buttons
=
static_cast
<
Qt
::
MouseButton
>
(
args
[
1
].
toInt
());
Qt
::
KeyboardModifiers
keym
=
static_cast
<
Qt
::
KeyboardModifier
>
(
args
[
2
].
toInt
());
int
x
=
args
[
3
].
toInt
();
...
...
@@ -178,7 +178,15 @@ bool pqAbstractItemViewEventPlayer::playEvent(QObject* Object, const QString& Co
QRect
r
=
object
->
visualRect
(
idx
);
pt
=
r
.
topLeft
()
+
QPoint
(
x
,
y
);
}
if
(
Command
==
"mouseWheel"
)
{
// QEvent::Type type = QEvent::Wheel;
int
delta
=
args
[
0
].
toInt
();
QWheelEvent
we
(
QPoint
(
x
,
y
),
delta
,
buttons
,
keym
);
QCoreApplication
::
sendEvent
(
Object
,
&
we
);
return
true
;
}
Qt
::
MouseButton
button
=
static_cast
<
Qt
::
MouseButton
>
(
args
[
0
].
toInt
());
QEvent
::
Type
type
=
QEvent
::
MouseButtonPress
;
type
=
Command
==
"mouseMove"
?
QEvent
::
MouseMove
:
type
;
type
=
Command
==
"mouseRelease"
?
QEvent
::
MouseButtonRelease
:
type
;
...
...
pqAbstractItemViewEventTranslator.cxx
View file @
b85c0b4f
...
...
@@ -136,6 +136,34 @@ bool pqAbstractItemViewEventTranslator::translateEvent(QObject* Object, QEvent*
emit
recordEvent
(
object
,
"mouseRelease"
,
info
);
}
}
case
QEvent
::
Wheel
:
{
if
(
Object
==
object
)
{
return
false
;
}
QPoint
relPt
=
QPoint
(
0
,
0
);
QWheelEvent
*
wheelEvent
=
dynamic_cast
<
QWheelEvent
*>
(
Event
);
if
(
wheelEvent
)
{
QString
idxStr
;
QModelIndex
idx
=
object
->
indexAt
(
wheelEvent
->
pos
());
idxStr
=
toIndexStr
(
idx
);
QRect
r
=
object
->
visualRect
(
idx
);
relPt
=
wheelEvent
->
pos
()
-
r
.
topLeft
();
int
numStep
=
wheelEvent
->
delta
();
int
buttons
=
wheelEvent
->
buttons
();
int
modifiers
=
wheelEvent
->
modifiers
();
emit
emit
recordEvent
(
Object
,
"mouseWheel"
,
QString
(
"%1,%2,%3,%4,%5"
)
.
arg
(
numStep
)
.
arg
(
buttons
)
.
arg
(
modifiers
)
.
arg
(
relPt
.
x
())
.
arg
(
relPt
.
y
())
.
arg
(
idxStr
));
}
}
break
;
default:
break
;
}
...
...
pqBasicWidgetEventPlayer.cxx
View file @
b85c0b4f
...
...
@@ -83,12 +83,20 @@ bool pqBasicWidgetEventPlayer::playEvent(QObject* Object,
QStringList
args
=
Arguments
.
split
(
','
);
if
(
args
.
size
()
==
5
)
{
Qt
::
MouseButton
button
=
static_cast
<
Qt
::
MouseButton
>
(
args
[
0
].
toInt
());
Qt
::
MouseButtons
buttons
=
static_cast
<
Qt
::
MouseButton
>
(
args
[
1
].
toInt
());
Qt
::
KeyboardModifiers
keym
=
static_cast
<
Qt
::
KeyboardModifier
>
(
args
[
2
].
toInt
());
int
x
=
args
[
3
].
toInt
();
int
y
=
args
[
4
].
toInt
();
QPoint
pt
(
x
,
y
);
if
(
Command
==
"mouseWheel"
)
{
// QEvent::Type type = QEvent::Wheel;
int
delta
=
args
[
0
].
toInt
();
QWheelEvent
we
(
QPoint
(
x
,
y
),
delta
,
buttons
,
keym
);
QCoreApplication
::
sendEvent
(
Object
,
&
we
);
return
true
;
}
Qt
::
MouseButton
button
=
static_cast
<
Qt
::
MouseButton
>
(
args
[
0
].
toInt
());
QEvent
::
Type
type
=
QEvent
::
MouseButtonPress
;
type
=
Command
==
"mouseMove"
?
QEvent
::
MouseMove
:
type
;
type
=
Command
==
"mouseRelease"
?
QEvent
::
MouseButtonRelease
:
type
;
...
...
pqBasicWidgetEventTranslator.cxx
View file @
b85c0b4f
...
...
@@ -95,6 +95,22 @@ bool pqBasicWidgetEventTranslator::translateEvent(QObject* Object,
}
}
break
;
case
QEvent
::
Wheel
:
{
QWheelEvent
*
wheelEvent
=
dynamic_cast
<
QWheelEvent
*>
(
Event
);
if
(
wheelEvent
)
{
int
buttons
=
wheelEvent
->
buttons
();
int
modifiers
=
wheelEvent
->
modifiers
();
emit
emit
recordEvent
(
Object
,
"mouseWheel"
,
QString
(
"%1,%2,%3,%4,%5"
)
.
arg
(
wheelEvent
->
delta
())
.
arg
(
buttons
)
.
arg
(
modifiers
)
.
arg
(
wheelEvent
->
x
())
.
arg
(
wheelEvent
->
y
()));
}
}
break
;
default:
break
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment