| 2377 | } |
| 2378 | |
| 2379 | void FindWin::slot_replaceAllInOpenDoc() |
| 2380 | { |
| 2381 | if (ui.replaceTextBox->currentText().isEmpty()) |
| 2382 | { |
| 2383 | ui.statusbar->showMessage(tr("what find is null !"), 8000); |
| 2384 | QApplication::beep(); |
| 2385 | return; |
| 2386 | } |
| 2387 | |
| 2388 | if (QMessageBox::Yes != QMessageBox::question(this, tr("Replace All Open Doc"), tr("Are you sure replace all occurrences in all open documents?"))) |
| 2389 | { |
| 2390 | return; |
| 2391 | } |
| 2392 | |
| 2393 | updateParameterFromUI(); |
| 2394 | |
| 2395 | int replaceNums = 0; |
| 2396 | |
| 2397 | |
| 2398 | QString whatFind = ui.replaceTextBox->currentText(); |
| 2399 | QString whatReplace = m_replaceWithText; |
| 2400 | |
| 2401 | if (m_extend) |
| 2402 | { |
| 2403 | QString extendFind; |
| 2404 | convertExtendedToString(whatFind, extendFind); |
| 2405 | whatFind = extendFind; |
| 2406 | |
| 2407 | QString extendReplace; |
| 2408 | convertExtendedToString(whatReplace, extendReplace); |
| 2409 | whatReplace = extendReplace; |
| 2410 | } |
| 2411 | |
| 2412 | for (int i = 0; i < m_editTabWidget->count(); ++i) |
| 2413 | { |
| 2414 | QWidget* pw = m_editTabWidget->widget(i); |
| 2415 | ScintillaEditView* pEdit = dynamic_cast<ScintillaEditView*>(pw); |
| 2416 | if (pEdit != nullptr) |
| 2417 | { |
| 2418 | //只读的文档不能替换 |
| 2419 | if (pEdit->isReadOnly()) |
| 2420 | { |
| 2421 | continue; |
| 2422 | } |
| 2423 | replaceNums += doReplaceAll(pEdit, whatFind, whatReplace); |
| 2424 | #if 0 |
| 2425 | //无条件进行第一次查找,从0行0列开始查找,而且不回环。如果没有找到,则替换完毕 |
| 2426 | if (!pEdit->findFirst(whatFind, m_re, m_cs, m_wo, false, true, FINDNEXTTYPE_REPLACENEXT,0, 0)) |
| 2427 | { |
| 2428 | continue; |
| 2429 | } |
| 2430 | |
| 2431 | pEdit->replace(whatReplace); |
| 2432 | |
| 2433 | dealWithZeroFound(pEdit); |
| 2434 | |
| 2435 | ++replaceNums; |
| 2436 |
nothing calls this directly
no test coverage detected