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
8fdcd1e9
Commit
8fdcd1e9
authored
Nov 22, 2011
by
Benjamin Long
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix all the QSpinBox issues - Close #88
parent
f4a72877
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
35 deletions
+42
-35
pqSpinBoxEventTranslator.cxx
pqSpinBoxEventTranslator.cxx
+36
-35
pqSpinBoxEventTranslator.h
pqSpinBoxEventTranslator.h
+6
-0
No files found.
pqSpinBoxEventTranslator.cxx
View file @
8fdcd1e9
...
@@ -41,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...
@@ -41,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
pqSpinBoxEventTranslator
::
pqSpinBoxEventTranslator
(
QObject
*
p
)
pqSpinBoxEventTranslator
::
pqSpinBoxEventTranslator
(
QObject
*
p
)
:
pqWidgetEventTranslator
(
p
)
:
pqWidgetEventTranslator
(
p
)
{
{
this
->
CurrentObject
=
0
;
}
}
bool
pqSpinBoxEventTranslator
::
translateEvent
(
QObject
*
Object
,
QEvent
*
Event
,
bool
&
/*Error*/
)
bool
pqSpinBoxEventTranslator
::
translateEvent
(
QObject
*
Object
,
QEvent
*
Event
,
bool
&
/*Error*/
)
...
@@ -54,49 +55,49 @@ bool pqSpinBoxEventTranslator::translateEvent(QObject* Object, QEvent* Event, bo
...
@@ -54,49 +55,49 @@ bool pqSpinBoxEventTranslator::translateEvent(QObject* Object, QEvent* Event, bo
}
}
if
(
!
object
)
if
(
!
object
)
return
false
;
return
false
;
switch
(
Event
->
type
())
if
(
Event
->
type
()
==
QEvent
::
Enter
&&
Object
==
object
)
{
{
case
QEvent
::
MouseButtonPress
:
if
(
this
->
CurrentObject
!=
Object
)
{
{
QMouseEvent
*
me
=
static_cast
<
QMouseEvent
*>
(
Event
);
if
(
this
->
CurrentObject
)
if
(
me
->
button
()
==
Qt
::
LeftButton
)
{
{
QStyle
*
style
=
object
->
style
();
disconnect
(
this
->
CurrentObject
,
0
,
this
,
0
);
QStyleOptionSpinBox
option
;
option
.
initFrom
(
object
);
option
.
subControls
=
QStyle
::
SC_All
;
QStyle
::
SubControl
sub
=
style
->
hitTestComplexControl
(
QStyle
::
CC_SpinBox
,
&
option
,
me
->
pos
(),
object
);
if
(
sub
==
QStyle
::
SC_SpinBoxUp
)
{
emit
recordEvent
(
object
,
"spin"
,
"up"
);
}
else
if
(
sub
==
QStyle
::
SC_SpinBoxDown
)
{
emit
recordEvent
(
object
,
"spin"
,
"down"
);
}
}
}
this
->
CurrentObject
=
Object
;
this
->
Value
=
object
->
value
();
connect
(
object
,
SIGNAL
(
valueChanged
(
int
)),
this
,
SLOT
(
onValueChanged
(
int
)));
connect
(
object
,
SIGNAL
(
destroyed
(
QObject
*
)),
this
,
SLOT
(
onDestroyed
(
QObject
*
)));
}
}
break
;
}
case
QEvent
::
KeyRelease
:
if
(
Event
->
type
()
==
QEvent
::
KeyRelease
&&
Object
==
object
)
{
QKeyEvent
*
ke
=
static_cast
<
QKeyEvent
*>
(
Event
);
QString
keyText
=
ke
->
text
();
this
->
Value
=
object
->
value
();
if
(
keyText
.
length
()
&&
keyText
.
at
(
0
).
isLetterOrNumber
())
{
{
QKeyEvent
*
ke
=
static_cast
<
QKeyEvent
*>
(
Event
);
emit
recordEvent
(
object
,
"set_int"
,
QString
(
"%1"
).
arg
(
object
->
value
()));
QString
keyText
=
ke
->
text
();
}
if
(
keyText
.
length
()
&&
keyText
.
at
(
0
).
isLetterOrNumber
())
else
{
{
emit
recordEvent
(
object
,
"set_int"
,
QString
(
"%1"
).
arg
(
object
->
value
()));
emit
recordEvent
(
object
,
"key"
,
QString
(
"%1"
).
arg
(
ke
->
key
()));
}
else
{
emit
recordEvent
(
object
,
"key"
,
QString
(
"%1"
).
arg
(
ke
->
key
()));
}
}
}
default:
break
;
}
}
return
true
;
return
true
;
}
}
void
pqSpinBoxEventTranslator
::
onDestroyed
(
QObject
*
/*Object*/
)
{
this
->
CurrentObject
=
0
;
}
void
pqSpinBoxEventTranslator
::
onValueChanged
(
int
number
)
{
QString
sens
=
(
number
-
this
->
Value
>
0
)
?
"up"
:
"down"
;
this
->
Value
=
number
;
emit
recordEvent
(
this
->
CurrentObject
,
"spin"
,
sens
);
}
pqSpinBoxEventTranslator.h
View file @
8fdcd1e9
...
@@ -55,6 +55,12 @@ private:
...
@@ -55,6 +55,12 @@ private:
pqSpinBoxEventTranslator
(
const
pqSpinBoxEventTranslator
&
);
pqSpinBoxEventTranslator
(
const
pqSpinBoxEventTranslator
&
);
pqSpinBoxEventTranslator
&
operator
=
(
const
pqSpinBoxEventTranslator
&
);
pqSpinBoxEventTranslator
&
operator
=
(
const
pqSpinBoxEventTranslator
&
);
int
Value
;
QObject
*
CurrentObject
;
private
slots
:
void
onDestroyed
(
QObject
*
);
void
onValueChanged
(
int
number
);
};
};
#endif // !_pqSpinBoxEventTranslator_h
#endif // !_pqSpinBoxEventTranslator_h
...
...
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