summaryrefslogtreecommitdiffstats
path: root/scribus/search.cpp
diff options
context:
space:
mode:
authorjghali <jghali@11d20701-8431-0410-a711-e3c959e3b870>2012-06-05 21:51:22 +0000
committerjghali <jghali@11d20701-8431-0410-a711-e3c959e3b870>2012-06-05 21:51:22 +0000
commit1b786f099b838cf42237bf7b18b9615f858673b3 (patch)
tree9facffc02a3a224b1cb046552236085b956d1bb3 /scribus/search.cpp
parente81809849a4bae494032c4859467026f14be7aed (diff)
downloadscribus-1b786f099b838cf42237bf7b18b9615f858673b3.tar.gz
scribus-1b786f099b838cf42237bf7b18b9615f858673b3.tar.xz
scribus-1b786f099b838cf42237bf7b18b9615f858673b3.zip
#3730: impossible to search and replace "fl" in text area
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17540 11d20701-8431-0410-a711-e3c959e3b870
Diffstat (limited to 'scribus/search.cpp')
-rw-r--r--scribus/search.cpp63
1 files changed, 25 insertions, 38 deletions
diff --git a/scribus/search.cpp b/scribus/search.cpp
index 63d868a..3f3534f 100644
--- a/scribus/search.cpp
+++ b/scribus/search.cpp
@@ -419,25 +419,34 @@ void SearchReplace::slotDoSearch()
sSize = qRound(SSizeVal->value() * 10);
if (sText.length() > 0)
found = false;
- int inde = 0;
+
uint as = Item->itemText.cursorPosition();
ReplStart = as;
int a;
if (SMode)
{
+ Qt::CaseSensitivity cs = Qt::CaseSensitive;
+ if (CaseIgnore->isChecked())
+ cs = Qt::CaseInsensitive;
+
for (a = as; a < Item->itemText.length(); ++a)
{
+ found = true;
if (SText->isChecked())
{
- QString chstr = Item->itemText.text(a,1);
- if (CaseIgnore->isChecked())
- chstr = chstr.toLower();
- found = chstr == sText.mid(inde, 1) ? true : false;
- if ((Word->isChecked()) && (inde == 0) && (chstr[0].isSpace()))
- found = true;
+ a = Item->itemText.indexOf(sText, a, cs);
+ found = (a >= 0);
+ if (!found) break;
+
+ if (Word->isChecked() && (a > 0) && !Item->itemText.text(a - 1).isSpace())
+ found = false;
+ if (Word->isChecked())
+ {
+ int lastChar = qMin(a + sText.length(), maxChar);
+ found = ((lastChar == maxChar) || Item->itemText.text(lastChar).isSpace());
+ }
+ if (!found) continue;
}
- else
- found = true;
if (SSize->isChecked())
{
if (Item->itemText.charStyle(a).fontSize() != sSize)
@@ -487,41 +496,20 @@ void SearchReplace::slotDoSearch()
}
if (found)
{
- Item->itemText.select(a,1);
+ Item->itemText.select(a, sText.length());
Item->HasSel = true;
if (rep)
{
DoReplace->setEnabled(true);
AllReplace->setEnabled(true);
}
- Item->itemText.setCursorPosition(a+1);
- if (SText->isChecked())
- {
- if (inde == 0)
- ReplStart = a;
- inde++;
- if ((Word->isChecked()) && (inde == 1) && (Item->itemText.text(a).isSpace()))
- {
- inde--;
- Item->itemText.select(a, 1, false);
- }
- if ( Word->isChecked() && inde == sText.length() &&
- ! Item->itemText.text(qMin(a+1, maxChar)).isSpace() )
- {
- for (int xx = ReplStart; xx < a+1; ++xx)
- Item->itemText.select(qMin(xx, maxChar), 1, false);
- Item->HasSel = false;
- inde = 0;
- found = false;
- }
- else
- {
- if (inde == sText.length())
- break;
- }
- }
- else
+ Item->itemText.setCursorPosition(a + sText.length());
+
+ if (!SText->isChecked())
break;
+
+ ReplStart = a;
+ break;
}
else
{
@@ -531,7 +519,6 @@ void SearchReplace::slotDoSearch()
Item->itemText.select(qMin(xx, maxChar), 1, false);
Item->HasSel = false;
}
- inde = 0;
}
}
if ((!found) || (a == Item->itemText.length()))