Commit b9475af0 authored by Laurent Montel's avatar Laurent Montel 😁

Use new searchText() method

parent 7ae9e9c9
......@@ -83,7 +83,7 @@ void TextEditFindBarBase::showFind()
if (documentIsEmpty()) {
return;
}
mReplaceWidget->slotSearchStringEmpty(mFindWidget->search()->text().isEmpty());
mReplaceWidget->slotSearchStringEmpty(mFindWidget->searchText().isEmpty());
show();
if (mReplaceWidget->isVisible()) {
mReplaceWidget->hide();
......@@ -104,7 +104,7 @@ void TextEditFindBarBase::showReplace()
if (documentIsEmpty()) {
return;
}
mReplaceWidget->slotSearchStringEmpty(mFindWidget->search()->text().isEmpty());
mReplaceWidget->slotSearchStringEmpty(mFindWidget->searchText().isEmpty());
show();
if (!mReplaceWidget->isVisible()) {
mReplaceWidget->show();
......@@ -119,7 +119,7 @@ void TextEditFindBarBase::setText(const QString &text)
QString TextEditFindBarBase::text() const
{
return mFindWidget->search()->text();
return mFindWidget->searchText();
}
void TextEditFindBarBase::focusAndSetCursor()
......@@ -161,7 +161,7 @@ void TextEditFindBarBase::messageInfo(bool backward, bool isAutoSearch, bool fou
bool TextEditFindBarBase::searchText(bool backward, bool isAutoSearch)
{
mLastSearchStr = mFindWidget->search()->text();
mLastSearchStr = mFindWidget->searchText();
mLastSearchRegExp = mFindWidget->searchRegExp();
QTextDocument::FindFlags searchOptions = mFindWidget->searchOptions();
if (backward) {
......@@ -172,7 +172,7 @@ bool TextEditFindBarBase::searchText(bool backward, bool isAutoSearch)
autoSearchMoveCursor();
} else if (mFindWidget->isRegularExpression()) {
//TODO
} else if (!mLastSearchStr.contains(mFindWidget->search()->text(), Qt::CaseSensitive)) {
} else if (!mLastSearchStr.contains(mFindWidget->searchText(), Qt::CaseSensitive)) {
clearSelections();
}
......@@ -200,7 +200,7 @@ void TextEditFindBarBase::findPrev()
void TextEditFindBarBase::slotUpdateSearchOptions()
{
const QTextDocument::FindFlags searchOptions = mFindWidget->searchOptions();
mLastSearchStr = mFindWidget->search()->text();
mLastSearchStr = mFindWidget->searchText();
mLastSearchRegExp = mFindWidget->searchRegExp();
if (mFindWidget->isRegularExpression()) {
searchInDocument(mLastSearchRegExp, searchOptions);
......@@ -251,7 +251,7 @@ bool TextEditFindBarBase::event(QEvent *e)
if (shortCutOverride) {
return true;
}
if (mFindWidget->search()->text().isEmpty()) {
if (mFindWidget->searchText().isEmpty()) {
return true;
}
......
......@@ -166,6 +166,11 @@ bool TextFindWidget::isRegularExpression() const
return mRegExpAct->isChecked();
}
QString TextFindWidget::searchText() const
{
return mSearch->text();
}
QRegExp TextFindWidget::searchRegExp() const
{
QRegExp reg;
......
......@@ -44,6 +44,8 @@ public:
QRegExp searchRegExp() const;
QString searchText() const;
private Q_SLOTS:
void slotAutoSearch(const QString &str);
......
......@@ -90,7 +90,7 @@ void PlainTextEditFindBar::autoSearchMoveCursor()
void PlainTextEditFindBar::slotReplaceText()
{
if (d->mView->textCursor().hasSelection()) {
if (d->mView->textCursor().selectedText() == mFindWidget->search()->text()) {
if (d->mView->textCursor().selectedText() == mFindWidget->searchText()) {
d->mView->textCursor().insertText(mReplaceWidget->replace()->text());
//search next after replace text.
searchText(false, false);
......@@ -106,7 +106,7 @@ void PlainTextEditFindBar::slotReplaceAllText()
if (mFindWidget->isRegularExpression()) {
newText = d->mView->toPlainText().replace(mFindWidget->searchRegExp(), mReplaceWidget->replace()->text());
} else {
newText = d->mView->toPlainText().replace(mFindWidget->search()->text(), mReplaceWidget->replace()->text());
newText = d->mView->toPlainText().replace(mFindWidget->searchText(), mReplaceWidget->replace()->text());
}
d->mView->selectAll();
d->mView->insertPlainText(newText);
......
......@@ -90,7 +90,7 @@ void RichTextEditFindBar::slotReplaceText()
{
//FIXME!
if (d->mView->textCursor().hasSelection()) {
if (d->mView->textCursor().selectedText() == mFindWidget->search()->text()) {
if (d->mView->textCursor().selectedText() == mFindWidget->searchText()) {
d->mView->textCursor().insertText(mReplaceWidget->replace()->text());
//search next after replace text.
searchText(false, false);
......@@ -106,7 +106,7 @@ void RichTextEditFindBar::slotReplaceAllText()
if (mFindWidget->isRegularExpression()) {
newText = d->mView->toPlainText().replace(mFindWidget->searchRegExp(), mReplaceWidget->replace()->text());
} else {
newText = d->mView->toPlainText().replace(mFindWidget->search()->text(), mReplaceWidget->replace()->text());
newText = d->mView->toPlainText().replace(mFindWidget->searchText(), mReplaceWidget->replace()->text());
}
d->mView->selectAll();
d->mView->insertPlainText(newText);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment