MCPcopy Create free account
hub / github.com/cjcliffe/CubicSDR / doUpdateActiveList

Method doUpdateActiveList

src/forms/Bookmark/BookmarkView.cpp:353–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351
352
353void BookmarkView::doUpdateActiveList() {
354
355 auto demods = wxGetApp().getDemodMgr().getDemodulators();
356 auto lastActiveDemodulator = wxGetApp().getDemodMgr().getCurrentModem();
357
358 //capture the previously selected item info BY COPY (because the original will be destroyed together with the destroyed tree items) to restore it again after
359 //having rebuilding the whole tree.
360 TreeViewItem* prevSel = itemToTVI(m_treeView->GetSelection());
361 TreeViewItem* prevSelCopy = nullptr;
362
363 if (prevSel != nullptr) {
364 prevSelCopy = new TreeViewItem(*prevSel);
365 }
366
367 // Actives
368 m_treeView->DeleteChildren(activeBranch);
369
370 bool activeExpandState = expandState["active"];
371 bool searchState = !searchKeywords.empty();
372
373 wxTreeItemId selItem = nullptr;
374 for (const auto& demod_i : demods) {
375 wxString activeLabel = BookmarkMgr::getActiveDisplayName(demod_i);
376
377 if (searchState) {
378 std::string freqStr = frequencyToStr(demod_i->getFrequency());
379 std::string bwStr = frequencyToStr(demod_i->getBandwidth());
380 std::string mtype = demod_i->getDemodulatorType();
381
382 std::wstring fullText = activeLabel.ToStdWstring() +
383 L" " + demod_i->getDemodulatorUserLabel() +
384 L" " + std::to_wstring(demod_i->getFrequency()) +
385 L" " + wxString(freqStr).ToStdWstring() +
386 L" " + wxString(bwStr).ToStdWstring() +
387 L" " + wxString(mtype).ToStdWstring();
388
389 if (!isKeywordMatch(fullText, searchKeywords)) {
390 continue;
391 }
392 }
393
394 auto* tvi = new TreeViewItem();
395 tvi->type = TreeViewItem::Type::TREEVIEW_ITEM_TYPE_ACTIVE;
396 tvi->demod = demod_i;
397
398 wxTreeItemId itm = m_treeView->AppendItem(activeBranch,activeLabel);
399 SetTreeItemData(itm, tvi);
400
401 if (nextDemod != nullptr && nextDemod == demod_i) {
402 selItem = itm;
403 nextDemod = nullptr;
404 } else if (!selItem && activeExpandState && lastActiveDemodulator && lastActiveDemodulator == demod_i) {
405 selItem = itm;
406 }
407 }
408
409 bool rangeExpandState = !searchState && expandState["range"];
410

Callers

nothing calls this directly

Calls 13

frequencyToStrFunction · 0.85
getDemodulatorsMethod · 0.80
getCurrentModemMethod · 0.80
getDemodulatorTypeMethod · 0.80
getRangesMethod · 0.80
getRecentsMethod · 0.80
elementMethod · 0.80
childMethod · 0.80
emptyMethod · 0.45
getFrequencyMethod · 0.45
getBandwidthMethod · 0.45

Tested by

no test coverage detected