-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpqAbstractIntEventPlayer.cxx
58 lines (49 loc) · 1.28 KB
/
pqAbstractIntEventPlayer.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
// SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
// SPDX-License-Identifier: BSD-3-Clause
#include "pqAbstractIntEventPlayer.h"
#include <QAbstractSlider>
#include <QSpinBox>
#include <QtDebug>
pqAbstractIntEventPlayer::pqAbstractIntEventPlayer(QObject* p)
: pqWidgetEventPlayer(p)
{
}
bool pqAbstractIntEventPlayer::playEvent(
QObject* Object, const QString& Command, const QString& Arguments, bool& Error)
{
if (Command != "set_int" && Command != "spin")
return false;
const int value = Arguments.toInt();
if (QAbstractSlider* const object = qobject_cast<QAbstractSlider*>(Object))
{
object->setValue(value);
return true;
}
if (QSpinBox* const object = qobject_cast<QSpinBox*>(Object))
{
if (Command == "set_int")
{
object->setValue(value);
return true;
}
else if (Command == "spin" && Arguments == "up")
{
object->stepUp();
return true;
}
else if (Command == "spin" && Arguments == "down")
{
object->stepDown();
return true;
}
}
if (Command == "spin")
{
// let pqAbstractEventPlayer handle it if possible.
return false;
}
qCritical() << "calling set_int on unhandled type " << Object;
Error = true;
return true;
}