| 396 | } |
| 397 | |
| 398 | void SetFindText(QString text) |
| 399 | { |
| 400 | if(m_FindString == text) |
| 401 | return; |
| 402 | |
| 403 | if(!m_Ctx.IsCaptureLoaded()) |
| 404 | return; |
| 405 | |
| 406 | rdcarray<QModelIndex> oldResults; |
| 407 | oldResults.swap(m_FindResults); |
| 408 | |
| 409 | m_FindString = text; |
| 410 | m_FindResults.clear(); |
| 411 | |
| 412 | bool eidSearch = false; |
| 413 | // if the user puts in @123 |
| 414 | if(!text.isEmpty() && text[0] == QLatin1Char('@')) |
| 415 | { |
| 416 | eidSearch = true; |
| 417 | text = text.mid(1); |
| 418 | } |
| 419 | |
| 420 | bool eidOK = false; |
| 421 | uint32_t eid = text.toUInt(&eidOK); |
| 422 | |
| 423 | // include EID in results first if the text parses as an integer |
| 424 | if(eidOK && eid > 0 && eid < m_Actions.size()) |
| 425 | { |
| 426 | // if the text doesn't exactly match the EID after converting back, don't treat this as an |
| 427 | // EID-only search |
| 428 | eidSearch = (text.trimmed() == QString::number(eid)); |
| 429 | |
| 430 | if(eidSearch) |
| 431 | m_FindResults.push_back(GetIndexForEID(eid)); |
| 432 | } |
| 433 | |
| 434 | m_FindEIDSearch = eidSearch; |
| 435 | |
| 436 | if(!m_FindString.isEmpty() && !eidSearch) |
| 437 | { |
| 438 | // do a depth-first search to find results |
| 439 | AccumulateFindResults(createIndex(0, 0, TagRoot)); |
| 440 | } |
| 441 | |
| 442 | for(QModelIndex i : oldResults) |
| 443 | RefreshIcon(i); |
| 444 | for(QModelIndex i : m_FindResults) |
| 445 | RefreshIcon(i); |
| 446 | } |
| 447 | |
| 448 | QModelIndex Find(bool forward, QModelIndex eidStart) |
| 449 | { |
no test coverage detected