Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Ben Boeckel
QtTesting
Commits
0c71e3fa
Commit
0c71e3fa
authored
Nov 23, 2011
by
Benjamin Long
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix all the QDoubleSpinBox issues - Close #88
parent
8fdcd1e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
34 deletions
+42
-34
pqDoubleSpinBoxEventTranslator.cxx
pqDoubleSpinBoxEventTranslator.cxx
+35
-34
pqDoubleSpinBoxEventTranslator.h
pqDoubleSpinBoxEventTranslator.h
+7
-0
No files found.
pqDoubleSpinBoxEventTranslator.cxx
View file @
0c71e3fa
...
...
@@ -39,7 +39,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QStyleOptionSpinBox>
pqDoubleSpinBoxEventTranslator
::
pqDoubleSpinBoxEventTranslator
(
QObject
*
p
)
:
pqWidgetEventTranslator
(
p
)
:
pqWidgetEventTranslator
(
p
),
CurrentObject
(
0
)
{
}
...
...
@@ -56,46 +57,46 @@ bool pqDoubleSpinBoxEventTranslator::translateEvent(QObject* Object, QEvent* Eve
if
(
!
object
)
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
(
me
->
button
()
==
Qt
::
LeftButton
)
if
(
this
->
CurrentObject
)
{
QStyle
*
style
=
object
->
style
();
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"
);
}
disconnect
(
this
->
CurrentObject
,
0
,
this
,
0
);
}
this
->
CurrentObject
=
Object
;
this
->
Value
=
object
->
value
();
connect
(
object
,
SIGNAL
(
valueChanged
(
double
)),
this
,
SLOT
(
onValueChanged
(
double
)));
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
();
if
(
keyText
.
length
()
&&
keyText
.
at
(
0
).
isLetterOrNumber
())
{
QKeyEvent
*
ke
=
static_cast
<
QKeyEvent
*>
(
Event
);
QString
keyText
=
ke
->
text
();
if
(
keyText
.
length
()
&&
keyText
.
at
(
0
).
isLetterOrNumber
())
{
emit
recordEvent
(
object
,
"set_double"
,
QString
(
"%1"
).
arg
(
object
->
value
()));
}
else
{
emit
recordEvent
(
object
,
"key"
,
QString
(
"%1"
).
arg
(
ke
->
key
()));
}
emit
recordEvent
(
object
,
"set_double"
,
QString
(
"%1"
).
arg
(
object
->
value
()));
}
else
{
emit
recordEvent
(
object
,
"key"
,
QString
(
"%1"
).
arg
(
ke
->
key
()));
}
default:
break
;
}
return
true
;
}
void
pqDoubleSpinBoxEventTranslator
::
onDestroyed
(
QObject
*
/*Object*/
)
{
this
->
CurrentObject
=
0
;
}
void
pqDoubleSpinBoxEventTranslator
::
onValueChanged
(
double
number
)
{
QString
sens
=
(
number
-
this
->
Value
>
0
)
?
"up"
:
"down"
;
this
->
Value
=
number
;
emit
recordEvent
(
this
->
CurrentObject
,
"spin"
,
sens
);
}
pqDoubleSpinBoxEventTranslator.h
View file @
0c71e3fa
...
...
@@ -55,6 +55,13 @@ private:
pqDoubleSpinBoxEventTranslator
(
const
pqDoubleSpinBoxEventTranslator
&
);
pqDoubleSpinBoxEventTranslator
&
operator
=
(
const
pqDoubleSpinBoxEventTranslator
&
);
int
Value
;
QObject
*
CurrentObject
;
private
slots
:
void
onDestroyed
(
QObject
*
);
void
onValueChanged
(
double
number
);
};
#endif // !_pqDoubleSpinBoxEventTranslator_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