在walkDirfile中用作回调函数处理。命中则返回true
| 2614 | |
| 2615 | //在walkDirfile中用作回调函数处理。命中则返回true |
| 2616 | bool FindWin::findTextInFile(QString &filePath, int &findNums, QVector<FindRecords*>* allfileInDirRecord) |
| 2617 | { |
| 2618 | pEditTemp->clear(); |
| 2619 | |
| 2620 | if (0 != FileManager::getInstance().loadFileForSearch(pEditTemp, filePath)) |
| 2621 | { |
| 2622 | return false; |
| 2623 | } |
| 2624 | |
| 2625 | FindRecords* results = new FindRecords(); |
| 2626 | //返回结果的edit无条件写无。注意不要忘记 |
| 2627 | results->pEdit = nullptr; |
| 2628 | results->findFilePath = filePath; |
| 2629 | |
| 2630 | //无条件进行第一次查找,从0行0列开始查找,而且不回环。如果没有找到,则替换完毕 |
| 2631 | results->findText = m_expr; |
| 2632 | QString whatFind = m_expr; |
| 2633 | |
| 2634 | if (m_extend) |
| 2635 | { |
| 2636 | QString extendFind; |
| 2637 | convertExtendedToString(whatFind, extendFind); |
| 2638 | whatFind = extendFind; |
| 2639 | } |
| 2640 | |
| 2641 | if (!pEditTemp->findFirst(whatFind, m_re, m_cs, m_wo, false, m_forward, FINDNEXTTYPE_FINDNEXT, 0, 0,false)) |
| 2642 | { |
| 2643 | delete results; |
| 2644 | return false; |
| 2645 | } |
| 2646 | else |
| 2647 | { |
| 2648 | dealWithZeroFound(pEditTemp); |
| 2649 | } |
| 2650 | |
| 2651 | addCurFindRecord(pEditTemp, *results); |
| 2652 | |
| 2653 | ++findNums; |
| 2654 | |
| 2655 | //找到了,把结果收集起来 |
| 2656 | while (pEditTemp->findNext()) |
| 2657 | { |
| 2658 | addCurFindRecord(pEditTemp, *results); |
| 2659 | ++findNums; |
| 2660 | dealWithZeroFound(pEditTemp); |
| 2661 | } |
| 2662 | |
| 2663 | allfileInDirRecord->append(results); |
| 2664 | |
| 2665 | return true; |
| 2666 | } |
| 2667 | |
| 2668 | //在walkDirfile中用作回调函数处理。命中则返回true 第三个参数不需要,为了复用walkdir,暂时保留和findTextInFile一致 |
| 2669 | bool FindWin::replaceTextInFile(QString &filePath, int &replaceNums, QVector<FindRecords*>*) |
nothing calls this directly
no test coverage detected