| 4 | namespace AetherSDR { |
| 5 | |
| 6 | void 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 | |
| 54 | void SpotModel::removeSpot(int index) |
| 55 | { |
no test coverage detected