Changeset View
Changeset View
Standalone View
Standalone View
src/lib/rule.cpp
Show First 20 Lines • Show All 666 Lines • ▼ Show 20 Line(s) | 666 | if (text.midRef(offset, pattern.size()).compare(pattern, m_caseSensitivity) == 0) | |||
---|---|---|---|---|---|
667 | return offset + pattern.size(); | 667 | return offset + pattern.size(); | ||
668 | return offset; | 668 | return offset; | ||
669 | } | 669 | } | ||
670 | 670 | | |||
671 | 671 | | |||
672 | bool WordDetect::doLoad(QXmlStreamReader& reader) | 672 | bool WordDetect::doLoad(QXmlStreamReader& reader) | ||
673 | { | 673 | { | ||
674 | m_word = reader.attributes().value(QStringLiteral("String")).toString(); | 674 | m_word = reader.attributes().value(QStringLiteral("String")).toString(); | ||
675 | m_caseSensitivity = Xml::attrToBool(reader.attributes().value(QStringLiteral("insensitive"))) ? Qt::CaseInsensitive : Qt::CaseSensitive; | ||||
675 | return !m_word.isEmpty(); | 676 | return !m_word.isEmpty(); | ||
676 | } | 677 | } | ||
677 | 678 | | |||
678 | MatchResult WordDetect::doMatch(const QString& text, int offset, const QStringList &captures) | 679 | MatchResult WordDetect::doMatch(const QString& text, int offset, const QStringList &captures) | ||
679 | { | 680 | { | ||
680 | Q_UNUSED(captures); // TODO | 681 | Q_UNUSED(captures); // TODO | ||
681 | if (text.size() - offset < m_word.size()) | 682 | if (text.size() - offset < m_word.size()) | ||
682 | return offset; | 683 | return offset; | ||
683 | 684 | | |||
684 | if (offset > 0 && !isDelimiter(text.at(offset - 1))) | 685 | if (offset > 0 && !isDelimiter(text.at(offset - 1))) | ||
685 | return offset; | 686 | return offset; | ||
686 | 687 | | |||
687 | if (text.midRef(offset, m_word.size()) != m_word) | 688 | if (text.midRef(offset, m_word.size()).compare(m_word, m_caseSensitivity) != 0) | ||
688 | return offset; | 689 | return offset; | ||
689 | 690 | | |||
690 | if (text.size() == offset + m_word.size() || isDelimiter(text.at(offset + m_word.size()))) | 691 | if (text.size() == offset + m_word.size() || isDelimiter(text.at(offset + m_word.size()))) | ||
691 | return offset + m_word.size(); | 692 | return offset + m_word.size(); | ||
692 | 693 | | |||
693 | return offset; | 694 | return offset; | ||
694 | } | 695 | } |