在后台批量高亮
| 1449 | |
| 1450 | //在后台批量高亮 |
| 1451 | int FindWin::markAtBack(QStringList& keyword) |
| 1452 | { |
| 1453 | if (keyword.isEmpty()) |
| 1454 | { |
| 1455 | return 0; |
| 1456 | } |
| 1457 | |
| 1458 | QWidget* pw = autoAdjustCurrentEditWin(); |
| 1459 | ScintillaEditView* pEdit = dynamic_cast<ScintillaEditView*>(pw); |
| 1460 | if (pEdit != nullptr) |
| 1461 | { |
| 1462 | if (pEdit->isReadOnly()) |
| 1463 | { |
| 1464 | ui.statusbar->showMessage(tr("The ReadOnly document does not allow replacement."), 8000); |
| 1465 | QApplication::beep(); |
| 1466 | return 0; |
| 1467 | } |
| 1468 | } |
| 1469 | |
| 1470 | m_isStatic = true; |
| 1471 | int times = 0; |
| 1472 | |
| 1473 | ProgressWin* loadFileProcessWin = nullptr; |
| 1474 | |
| 1475 | if (keyword.size() > 1000) |
| 1476 | { |
| 1477 | loadFileProcessWin = new ProgressWin(this); |
| 1478 | |
| 1479 | loadFileProcessWin->setWindowModality(Qt::WindowModal); |
| 1480 | |
| 1481 | loadFileProcessWin->info(tr("total %1 keyword, please wait ...").arg(keyword.size())); |
| 1482 | |
| 1483 | loadFileProcessWin->setTotalSteps(keyword.size() / 100); |
| 1484 | |
| 1485 | loadFileProcessWin->show(); |
| 1486 | } |
| 1487 | |
| 1488 | QString text = pEdit->text(); |
| 1489 | |
| 1490 | QByteArray bytes = text.toUtf8(); |
| 1491 | |
| 1492 | QByteArray findBytes; |
| 1493 | int keyLens = 0; |
| 1494 | |
| 1495 | int index = 0; |
| 1496 | |
| 1497 | QMap<QByteArray, QVector<int>* > keyPos; |
| 1498 | |
| 1499 | for (int i = 0; i < keyword.size(); ++i) |
| 1500 | { |
| 1501 | if ((loadFileProcessWin != nullptr) && loadFileProcessWin->isCancel()) |
| 1502 | { |
| 1503 | break; |
| 1504 | } |
| 1505 | index = 0; |
| 1506 | |
| 1507 | //20230223 不走老的逻辑了,批量替换太慢。直接把文件读取处理,在内存中一次性处理完毕。 |
| 1508 | //但是这样就不知道到底有多少字符串被替换了 |
no test coverage detected