forked from FLAME-HPC/flame_visualiser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconditiondialog.cpp
76 lines (65 loc) · 2.32 KB
/
conditiondialog.cpp
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
65
66
67
68
69
70
71
72
73
74
75
76
/*!
* \file conditiondialog.cpp
* \author Simon Coakley
* \date 2012
* \copyright Copyright (c) 2012 University of Sheffield
* \brief Implementation of condition dialog
*/
#include <QtGui>
#include "./conditiondialog.h"
ConditionDialog::ConditionDialog(QList<AgentType> *ats, QString agentType,
int r, QWidget *parent)
: QDialog(parent) {
setupUi(this);
agentTypes = ats;
row = r;
for (int i = 0; i < agentTypes->count(); i++) {
if (QString::compare(agentTypes->at(i).name, agentType) == 0) {
for (int j = 0; j < agentTypes->at(i).variables.count(); j++) {
variableComboBox->insertItem(j,
agentTypes->at(i).variables.at(j));
}
}
}
valueSpinBox->setMaximum(9999.99);
valueSpinBox->setMinimum(-9999.99);
operators << "==" << "!=" << ">" << "<" << ">=" << "<=";
opComboBox->addItems(operators);
connect(this, SIGNAL(setVariableComboBox(int)),
variableComboBox, SLOT(setCurrentIndex(int)));
connect(this, SIGNAL(setOpComboBox(int)),
opComboBox, SLOT(setCurrentIndex(int)));
connect(checkBox, SIGNAL(clicked(bool)), this, SLOT(updateEnable(bool)));
connect(buttonBox, SIGNAL(accepted()), this, SIGNAL(okButton()));
connect(buttonBox, SIGNAL(rejected()), this, SIGNAL(cancelButton()));
}
void ConditionDialog::updateEnable(bool c) {
variableComboBox->setEnabled(c);
opComboBox->setEnabled(c);
valueSpinBox->setEnabled(c);
}
void ConditionDialog::setCondition(Condition c) {
condition = c;
emit(checkBox->setChecked(condition.enable));
updateEnable(condition.enable);
int index = 0;
for (int i = 0; i < variableComboBox->count(); i++) {
if (variableComboBox->itemText(i) == condition.variable)
index = i;
}
emit(setVariableComboBox(index));
index = 0;
for (int i = 0; i < opComboBox->count(); i++) {
if (opComboBox->itemText(i) == condition.op)
index = i;
}
emit(setOpComboBox(index));
valueSpinBox->setValue(condition.value);
}
Condition ConditionDialog::getCondition() {
condition.enable = checkBox->isChecked();
condition.variable = variableComboBox->currentText();
condition.op = opComboBox->currentText();
condition.value = valueSpinBox->value();
return condition;
}