| 5542 | } |
| 5543 | |
| 5544 | bool MainWindow::activateMemorySpot(int memoryIndex, const QString& preferredPanId) |
| 5545 | { |
| 5546 | auto* slice = preferredMemorySlice(preferredPanId); |
| 5547 | if (!slice) { |
| 5548 | statusBar()->showMessage( |
| 5549 | preferredPanId.isEmpty() |
| 5550 | ? "Open a slice before recalling a memory." |
| 5551 | : "Open a slice on this pan before recalling a memory.", |
| 5552 | 3000); |
| 5553 | return false; |
| 5554 | } |
| 5555 | if (slice->isLocked()) { |
| 5556 | slice->notifyTuneBlockedByLock(); |
| 5557 | statusBar()->showMessage("Unlock the target slice before recalling a memory.", 3000); |
| 5558 | return false; |
| 5559 | } |
| 5560 | |
| 5561 | const auto it = m_radioModel.memories().constFind(memoryIndex); |
| 5562 | if (it == m_radioModel.memories().constEnd()) |
| 5563 | return false; |
| 5564 | |
| 5565 | const int sliceId = slice->sliceId(); |
| 5566 | if (!activeSlice() || activeSlice()->sliceId() != sliceId) |
| 5567 | setActiveSlice(sliceId); |
| 5568 | |
| 5569 | slice = m_radioModel.slice(sliceId); |
| 5570 | if (!slice) |
| 5571 | return false; |
| 5572 | |
| 5573 | const double memoryFreqMhz = it->freq; |
| 5574 | const bool hasMemoryFrequency = memoryFreqMhz > 0.0; |
| 5575 | const QString slicePanId = slice->panId(); |
| 5576 | |
| 5577 | if (hasMemoryFrequency) { |
| 5578 | const QString memoryBand = BandSettings::bandForFrequency(memoryFreqMhz); |
| 5579 | const QString currentBand = BandSettings::bandForFrequency(slice->frequency()); |
| 5580 | if (memoryBand != currentBand) { |
| 5581 | const auto xvtrs = xvtrPolicyBandsFrom(m_radioModel.xvtrList()); |
| 5582 | const auto stackKeyResult = |
| 5583 | XvtrPolicy::resolveBandStackKey(memoryBand, xvtrs, m_radioModel.capabilities()); |
| 5584 | if (stackKeyResult.isSupported()) { |
| 5585 | qCDebug(lcProtocol).noquote().nospace() |
| 5586 | << "MainWindow: memory recall preselecting band stack memory=" |
| 5587 | << memoryIndex |
| 5588 | << " pan=" << slicePanId |
| 5589 | << " from_band=" << currentBand |
| 5590 | << " to_band=" << memoryBand |
| 5591 | << " key=" << stackKeyResult.key; |
| 5592 | clearSwrSweepForBandChange(-1, slicePanId, memoryBand); |
| 5593 | m_bandSettings.setCurrentBand(memoryBand); |
| 5594 | m_radioModel.sendCommand( |
| 5595 | QString("display pan set %1 band=%2").arg(slicePanId, stackKeyResult.key)); |
| 5596 | QTimer::singleShot(300, this, [this, slicePanId]() { |
| 5597 | reassertUnmutedSliceAudioForPan(slicePanId); |
| 5598 | }); |
| 5599 | } else { |
| 5600 | qCWarning(lcProtocol).noquote().nospace() |
| 5601 | << "MainWindow: memory recall cannot preselect band stack memory=" |
nothing calls this directly
no test coverage detected