-
Notifications
You must be signed in to change notification settings - Fork 18
/
bandplan.cpp
50 lines (39 loc) · 1.16 KB
/
bandplan.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
#include "bandplan.h"
bandPlan::bandPlan (QString fileName) {
labelTable. resize (0);
loadPlan (fileName);
}
bandPlan::~bandPlan () {
}
const
QString bandPlan::getFrequencyLabel (uint32_t Frequency) {
int freq = Frequency / 1000;
for (int i = 0; i < labelTable. size (); i ++) {
if ((labelTable. at (i). low <= freq) &&
(freq <= labelTable. at (i). high))
return QString (labelTable. at (i). label);
}
return QString ("");
}
bool bandPlan::loadPlan (QString fileName) {
QDomDocument xmlBOM;
QFile f (fileName);
this -> fileName = fileName;
if (!f. open (QIODevice::ReadOnly))
return false;
xmlBOM. setContent (&f);
f. close ();
QDomElement root = xmlBOM. documentElement ();
QDomElement component = root. firstChild (). toElement ();
while (!component. isNull ()) {
if (component. tagName () == "Band") {
bandElement bd;
bd. low = component. attribute ("Low", "0"). toInt ();
bd. high = component. attribute ("High", "0"). toInt ();
bd. label = component. attribute ("Label", "");
labelTable. push_back (bd);
}
component = component. nextSibling (). toElement ();
}
return true;
}