r19794 by jghali - #12893: fix counting of words in story editor
scribus-commit
scribus-commit at lists.scribus.net
Thu Feb 5 22:16:24 UTC 2015
Author: jghali
Date: Thu Feb 5 22:16:24 2015
New Revision: 19794
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19794
Log:
#12893: fix counting of words in story editor
Modified:
branches/Version14x/Scribus/scribus/storyeditor.cpp
Modified: branches/Version14x/Scribus/scribus/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19794&path=/branches/Version14x/Scribus/scribus/storyeditor.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/storyeditor.cpp (original)
+++ branches/Version14x/Scribus/scribus/storyeditor.cpp Thu Feb 5 22:16:24 2015
@@ -2654,24 +2654,22 @@
ParC->setText(tmp.setNum(Editor->StyledText.nrOfParagraphs()));
CharC2->setText(tmp.setNum(Editor->StyledText.length()));
-
CharC->setText(tmp.setNum(end - start));
+
QRegExp rx( "(\\w+)\\b" );
const QString& txt(Editor->StyledText.text(0, Editor->StyledText.length()));
- int pos = 1;
- int counter = end > start? 1 : 0;
- int counter2 = Editor->StyledText.length() > 0? 1 : 0;
- while ( pos >= 0 )
- {
- pos = rx.indexIn( txt, pos );
- if ( pos > -1 )
- {
- if (pos > start && pos < end)
- counter++;
-
- counter2++;
- pos += rx.matchedLength();
- }
+ int counter = 0;
+ int counter2 = 0;
+
+ int pos = rx.indexIn(txt, 0);
+ while (pos >= 0)
+ {
+ if (pos >= start && pos < end)
+ counter++;
+
+ counter2++;
+ pos += rx.matchedLength();
+ pos = rx.indexIn(txt, pos);
}
WordC->setText(tmp.setNum(counter));
More information about the scribus-commit
mailing list