Go to the documentation of this file.
102 if(str.isEmpty() || (str.length() == 1 && !str[0].isLetter())) {
105 const int length = str.length();
106 for(
int i = 0; i < length; ++i) {
107 if(!str[i].isNumber()) {
118 QTextBoundaryFinder::BoundaryReasons boundary = finder.boundaryReasons();
119 int start = finder.position(), end = finder.position();
120 bool inWord = (boundary & QTextBoundaryFinder::StartWord) != 0;
121 while (finder.toNextBoundary() > 0) {
122 boundary = finder.boundaryReasons();
123 if ((boundary & QTextBoundaryFinder::EndWord) && inWord) {
124 end = finder.position();
125 QString str = finder.string().mid(start, end - start);
130 kDebug() <<
"Word at " << start <<
" word = '"
131 << str <<
"', len = " << str.length();
137 if ((boundary & QTextBoundaryFinder::StartWord)) {
138 start = finder.position();
147 QString &word,
int &bufferStart)
149 int oldPosition = finder.position();
151 finder.setPosition(at);
152 if (!finder.isAtBoundary() || (finder.boundaryReasons() & QTextBoundaryFinder::EndWord)) {
153 if (finder.toPreviousBoundary() <= 0) {
157 if (at > 0 && finder.string().length() > 0) {
164 finder.setPosition(oldPosition);
172 bool allUppercase =
false;
173 bool runTogether =
false;
178 allUppercase = ( foundWord == foundWord.toUpper() );
185 return Word( foundWord, start );
194 return Word( foundWord, start );
217 int oldLen = w.
word.length();
221 m_finder = QTextBoundaryFinder(QTextBoundaryFinder::Word,
231 int signedPosition =
m_finder.position();
232 bool begin = (signedPosition - len/2)<=0;
238 QString::fromLatin1(
"<b>%1</b>" ).arg( word.
word ) );
242 context = QString::fromLatin1(
"%1...")
243 .arg(
buffer.mid( 0, len ) );
245 context = QString::fromLatin1(
"...%1...")
248 context.replace( QLatin1Char(
'\n'), QLatin1Char(
' ') );
264 if ( currentChar == QLatin1Char(
':')
276 if ( currentChar == QLatin1Char(
'@')) {
288 return d->settings && d->settings->ignore( word );
292 const QString& foundWord )
const
294 bool checkUpper = ( d->settings ) ?
295 d->settings->checkUppercase () :
true;
297 bool skipRunTogether = ( d->settings ) ?
298 d->settings->skipRunTogether() :
true;
303 if ( wordWasUppercase && !checkUpper )
306 if ( wordWasRunTogether && skipRunTogether )
309 return ignore( foundWord );
bool trySkipLinks() const
virtual Word wordAtPosition(unsigned int pos) const
void setBuffer(const QString &buffer)
virtual void setCurrentPosition(int)
virtual QString context() const
Should return the sentence containing the current word.
virtual int currentPosition() const
static Filter * defaultFilter()
bool ignore(const QString &word) const
virtual void replace(const Word &w, const QString &newWord)
void setSettings(Settings *)
Sets the Settings object for this Filter.
QTextBoundaryFinder m_finder
virtual Word nextWord() const
bool shouldBeSkipped(bool wordWasUppercase, bool wordWasRunTogether, const QString &foundWord) const
Settings * settings() const
Returns currently used Settings object.
static bool finderWordAt(QTextBoundaryFinder &finder, int at, QString &word, int &bufferStart)
static bool isValidWord(const QString &str)
static bool finderNextWord(QTextBoundaryFinder &finder, QString &word, int &bufferStart)
Structure abstracts the word and its position in the parent text.
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 17 2025 00:00:00 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.