-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpqComboBoxEventPlayer.cxx
64 lines (59 loc) · 1.91 KB
/
pqComboBoxEventPlayer.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
59
60
61
62
63
64
// SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
// SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
// SPDX-License-Identifier: BSD-3-Clause
#include "pqComboBoxEventPlayer.h"
#include "pqEventTypes.h"
#include "pqObjectNaming.h"
#include <QComboBox>
#include <QDebug>
//-----------------------------------------------------------------------------
pqComboBoxEventPlayer::pqComboBoxEventPlayer(QObject* parentObject)
: Superclass(parentObject)
{
}
//-----------------------------------------------------------------------------
pqComboBoxEventPlayer::~pqComboBoxEventPlayer() {}
//-----------------------------------------------------------------------------
bool pqComboBoxEventPlayer::playEvent(
QObject* object, const QString& command, const QString& arguments, int eventType, bool& error)
{
QComboBox* comboBox = qobject_cast<QComboBox*>(object);
if (!comboBox)
{
return false;
}
if (eventType == pqEventTypes::ACTION_EVENT)
{
if (command == "activated" || command == "editTextChanged")
{
int index = comboBox->findText(arguments);
if (index != -1)
{
comboBox->setCurrentIndex(index);
if (command == "activated")
{
Q_EMIT comboBox->activated(index);
}
}
else if (comboBox->isEditable() && command == "editTextChanged")
{
comboBox->setCurrentText(arguments);
}
else
{
QString possibles;
for (int i = 0; i < comboBox->count(); i++)
{
possibles += QString("\t") + comboBox->itemText(i) + QString("\n");
}
qCritical() << "Unable to find " << arguments
<< " in combo box: " << pqObjectNaming::GetName(*comboBox)
<< "\nPossible values are:\n"
<< possibles;
error = true;
}
}
return true;
}
return this->Superclass::playEvent(object, command, arguments, eventType, error);
}