void KReplaceDialog::slotButtonClicked( int button ) { if( button != KDialog::Ok ) KAbstractFindDialog::slotButtonClicked( button ); else { hide(); rememberCurrentSettings(); mTool->setSearchData( data() ); mTool->setReplaceData( replaceData() ); mTool->setCaseSensitivity( caseSensitivity() ); mTool->setDoPrompt( prompt() ); mTool->replace( direction(), fromCursor(), inSelection() ); } }
void FindDialog::accept() { TextEditor *current = m_parent->m_activeEditor; QTextDocument *doc = current->getTextDocument(); QTextCursor start = current->textCursor(); QTextCursor result; int startPos = -1, endPos = -1; // see if we're supposed to search within a selection if (start.hasSelection() && searchSelection()) { startPos = start.selectionStart(); endPos = start.selectionEnd(); // get rid of selection if (findBackwards()) start.setPosition(endPos); else start.setPosition(startPos); } else if (!fromCursor() && !m_searching) start.movePosition(QTextCursor::Start); if (isFind()) { result = find(start, doc); // test if result was outside of selection if (!result.isNull() && ((endPos > 0 && result.selectionEnd() > endPos) || (startPos > 0 && result.selectionStart() < startPos))) result = QTextCursor(); // null cursor } else result = replace(start, doc, endPos); if (result.isNull()) { STATUS_BAR->showMessage(QString("%1 '%2' not found with the Options given").arg((regularExpression() ? QString("RegExp") : QString("String")), getSearchString())); m_searching = false; updateReplace(isReplace()); } else { current->changeTextCursor(result); STATUS_BAR->clearMessage(); m_searching = true; updateReplace(isReplace()); } }