| 351 | |
| 352 | |
| 353 | void 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 |
nothing calls this directly
no test coverage detected