MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / applySpotStatus

Method applySpotStatus

src/models/SpotModel.cpp:6–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4namespace AetherSDR {
5
6void SpotModel::applySpotStatus(int index, const QMap<QString, QString>& kvs)
7{
8 bool isNew = !m_spots.contains(index);
9 auto& spot = m_spots[index];
10 spot.index = index;
11 if (isNew)
12 spot.addedMs = QDateTime::currentMSecsSinceEpoch();
13
14 for (auto it = kvs.constBegin(); it != kvs.constEnd(); ++it) {
15 const QString& key = it.key();
16 const QString& val = it.value();
17
18 if (key == "callsign")
19 spot.callsign = QString(val).replace(QChar(0x7f), ' ');
20 else if (key == "rx_freq")
21 spot.rxFreqMhz = val.toDouble();
22 else if (key == "tx_freq")
23 spot.txFreqMhz = val.toDouble();
24 else if (key == "mode")
25 spot.mode = val;
26 else if (key == "color")
27 spot.color = val;
28 else if (key == "background_color")
29 spot.backgroundColor = val;
30 else if (key == "source")
31 spot.source = val;
32 else if (key == "spotter_callsign")
33 spot.spotterCallsign = val;
34 else if (key == "comment")
35 spot.comment = QString(val).replace(QChar(0x7f), ' ');
36 else if (key == "timestamp") {
37 bool ok;
38 qint64 ts = val.toLongLong(&ok);
39 if (ok)
40 spot.timestamp = QDateTime::fromSecsSinceEpoch(ts, Qt::UTC);
41 }
42 else if (key == "lifetime_seconds")
43 spot.lifetimeSeconds = val.toInt();
44 else if (key == "priority")
45 spot.priority = val.toInt();
46 }
47
48 if (isNew)
49 emit spotAdded(spot);
50 else
51 emit spotUpdated(spot);
52}
53
54void SpotModel::removeSpot(int index)
55{

Callers 5

cmdSpotMethod · 0.80
syncMemorySpotMethod · 0.80
wireSpotSubsystemMethod · 0.80
wirePanadapterMethod · 0.80
onStatusReceivedMethod · 0.80

Calls 3

containsMethod · 0.80
keyMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected