forked from OpenPanzerProject/OP-Config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombo_triggersource.cpp
107 lines (89 loc) · 3.22 KB
/
combo_triggersource.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include "combo_triggersource.h"
TriggerSourceComboBox::TriggerSourceComboBox(QWidget *parent) : QComboBox(parent)
{
// We fill the combo box with a list of all the triggers - their descriptions in the Label column, and their codes in the user Data column.
// We get these key/value pairs from our OP_QMaps class (it holds a bunch of maps of interest)
OPQMap = new OP_QMaps;
TSQMap = OPQMap->getAllTriggerSourcesQMap();
TSDigitalQMap = OPQMap->getDigitalTriggerSourcesQMap();
TSAnalogQMap = OPQMap->getAnalogTriggerSourcesQMap();
// We don't populate this combo box. It is set later by other processes
_EIA_Present = false;
_EIB_Present = false;
// If either the text or index has changed, emit our custom signal
//connect(this, SIGNAL(editTextChanged(QString)), this, SLOT(CurrentTriggerSourceChangedSlot(QString)));
//connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(CurrentTriggerSourceChangedSlot(QString)));
}
boolean TriggerSourceComboBox::isTriggerSourceAux(_trigger_source ts)
{
return OPQMap->isTriggerSourceAuxChannel(ts);
}
void TriggerSourceComboBox::addExternalInputA(void)
{
boolean alreadyThere = false;
for (int i=0; i<this->count(); i++)
{
if (this->itemData(i) == TS_INPUT_A) alreadyThere = true;
}
if (!alreadyThere)
{
this->insertItem(count(), TSQMap.value(TS_INPUT_A), TS_INPUT_A);
_EIA_Present = true;
emit externalInputA_Added(); // Let the world know this has been added
}
}
void TriggerSourceComboBox::addExternalInputB(void)
{
boolean alreadyThere = false;
for (int i=0; i<this->count(); i++)
{
if (this->itemData(i) == TS_INPUT_B) alreadyThere = true;
}
if (!alreadyThere)
{
this->insertItem(count(), TSQMap.value(TS_INPUT_B), TS_INPUT_B);
_EIB_Present = true;
emit externalInputB_Added(); // Let the world know this has been added
}
}
boolean TriggerSourceComboBox::isExternalInputAPresent(void)
{
return _EIA_Present;
}
boolean TriggerSourceComboBox::isExternalInputBPresent(void)
{
return _EIB_Present;
}
void TriggerSourceComboBox::removeExternalInputA(void)
{
for (int i=0; i<this->count(); i++)
{
if (this->itemData(i) == TS_INPUT_A) this->removeItem(i); _EIA_Present = false;
}
}
void TriggerSourceComboBox::removeExternalInputB(void)
{
for (int i=0; i<this->count(); i++)
{
if (this->itemData(i) == TS_INPUT_B) this->removeItem(i); _EIB_Present = false;
}
}
// We can programmatically set the combo box to a value by passing it directly the enum code
void TriggerSourceComboBox::setCurrentTriggerSource(int ts)
{
this->setCurrentIndex(this->findData(ts));
}
// We can programmatically set the combo box to a value by passing it a special_function enum member name
void TriggerSourceComboBox::setCurrentTriggerSource(const _trigger_source& ts)
{
this->setCurrentIndex(this->findData(ts));
}
void TriggerSourceComboBox::clearCurrentTriggerSource(void)
{
this->setCurrentTriggerSource(TS_NULL_TRIGGER);
}
// This returns the current actual trigger source
_trigger_source TriggerSourceComboBox::getCurrentTriggerSource(void)
{
return static_cast<_trigger_source>(this->currentData().toInt());
}