MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / showFindReplaceDialog

Method showFindReplaceDialog

src/dialogs/MainWindow.cpp:1566–1606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1564}
1565
1566void MainWindow::showFindReplaceDialog(int index)
1567{
1568 ScintillaNext *editor = currentEditor();
1569 FindReplaceDialog *frd = findChild<FindReplaceDialog *>(QString(), Qt::FindDirectChildrenOnly);
1570
1571 if (frd == Q_NULLPTR) {
1572 frd = new FindReplaceDialog(determineSearchResultsHandler(), this);
1573 }
1574 else {
1575 frd->setSearchResultsHandler(determineSearchResultsHandler());
1576 }
1577
1578 // TODO: if dockedEditor::editorActivated() is fired, or if the editor get closed
1579 // the FindReplaceDialog's editor pointer needs updated...
1580
1581 // Get any selected text
1582 if (!editor->selectionEmpty()) {
1583 int selection = editor->mainSelection();
1584 int start = editor->selectionNStart(selection);
1585 int end = editor->selectionNEnd(selection);
1586 if (end > start) {
1587 auto selText = editor->get_text_range(start, end);
1588 frd->setFindString(QString::fromUtf8(selText));
1589 }
1590 }
1591 else {
1592 int start = editor->wordStartPosition(editor->currentPos(), true);
1593 int end = editor->wordEndPosition(editor->currentPos(), true);
1594 if (end > start) {
1595 editor->setSelectionStart(start);
1596 editor->setSelectionEnd(end);
1597 auto selText = editor->get_text_range(start, end);
1598 frd->setFindString(QString::fromUtf8(selText));
1599 }
1600 }
1601
1602 frd->setTab(index);
1603 frd->show();
1604 frd->raise();
1605 frd->activateWindow();
1606}
1607
1608void MainWindow::updateFileStatusBasedUi(ScintillaNext *editor)
1609{

Callers

nothing calls this directly

Calls 3

setFindStringMethod · 0.80
setTabMethod · 0.80

Tested by

no test coverage detected