Diffstat (limited to 'noncore/unsupported/mailit/textparser.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/unsupported/mailit/textparser.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/noncore/unsupported/mailit/textparser.cpp b/noncore/unsupported/mailit/textparser.cpp index f082417..3fa5f6e 100644 --- a/noncore/unsupported/mailit/textparser.cpp +++ b/noncore/unsupported/mailit/textparser.cpp @@ -41,69 +41,79 @@ TextParser::TextParser(QString in, QString lineBreak, QString sep) void TextParser::init() { lineCount = 0; linePos = 0; totalElmCount = 0; separatorPos = -1; //not initialized wordPos = -1; //not initialized sepAtLine = 0; sepAtPosElm = -1; //such that nextSep equals 0 wordAtLine = 0; wordAtPosElm = -1; //such that nextWord equals 0 atLine = 0; atPosElm = 0; } void TextParser::createSeparators() { separators = " @#,.:;<>*/(){}|'?-+=_"; } /* Returns pos of given search criteria, -1 if not found */ int TextParser::find(QString target, QChar sep, int pos, bool upperCase) { + + t_splitElm parsstr; + QString pString; + int atLine = 0, atPosElm = 0; - for (int x = 0; x < totalElmCount; x++) { - if (x >= pos) { - if (upperCase) { - if ((splitDone[atLine].elm[atPosElm].str.upper() == target) && - (splitDone[atLine].elm[atPosElm].separator == sep)) - return x; - } else { - if ((splitDone[atLine].elm[atPosElm].str == target) && - (splitDone[atLine].elm[atPosElm].separator == sep)) - return x; + getLineReference(pos,&atLine,&atPosElm); + + for (int x = pos; x < totalElmCount; x++) + { + parsstr=splitDone[atLine].elm[atPosElm++]; + + if (upperCase) + { + pString=parsstr.str.upper(); + target=target.upper(); } + else + { + pString=parsstr.str; } - atPosElm++; - if (atPosElm >= splitDone[atLine].elmCount) { //new Line + if ((pString == target) && (parsstr.separator == sep)) + { + return x; + } + if (atPosElm >= splitDone[atLine].elmCount) + { //new Line atLine++; atPosElm = 0; } } - return -1; } int TextParser::elmCount() { return totalElmCount; } QChar TextParser::separatorAt(int pos) { if (getLineReference(pos, &sepAtLine, &sepAtPosElm) == -1) return QChar::null; separatorPos = pos; return splitDone[sepAtLine].elm[sepAtPosElm].separator; } QChar TextParser::nextSeparator() { sepAtPosElm++; if (splitDone[sepAtLine].elmCount <= sepAtPosElm) { sepAtLine++; sepAtPosElm = 0; } |