KTextAddons
7#include "languagetoolgrammarerror.h"
10#include "languagetoolmanager.h"
11#include "textgrammarcheck_debug.h"
14using namespace TextGrammarCheck;
15LanguageToolGrammarError::LanguageToolGrammarError() =
default;
17LanguageToolGrammarError::~LanguageToolGrammarError() =
default;
19void LanguageToolGrammarError::parse(
const QJsonObject &obj,
int blockindex)
22 mBlockId = blockindex;
23 mError = obj[
"message"_L1].toString();
24 mStart = obj[
"offset"_L1].toInt(-1);
25 mLength = obj[
"length"_L1].toInt(-1);
26 mSuggestions = parseSuggestion(obj);
27 const QJsonObject rulesObj = obj[
"rule"_L1].toObject();
29 mRule = rulesObj[
"id"_L1].toString();
30 const QJsonArray urlArray = rulesObj[
"urls"_L1].toArray();
32 if (urlArray.
count() > 1) {
33 qCWarning(TEXTGRAMMARCHECK_LOG) <<
"LanguageToolGrammarError::parse : more than 1 url found. Perhaps need to adapt api ";
39 if (!mRule.isEmpty() && !mTesting) {
40 mColor = LanguageToolManager::self()->grammarColorForError(mRule);
46void LanguageToolGrammarError::setTesting(
bool b)
51QStringList LanguageToolGrammarError::parseSuggestion(
const QJsonObject &obj)
54 const QJsonArray array = obj[
"replacements"_L1].toArray();
55 for (
const QJsonValue ¤t : array) {
57 const QJsonObject suggestionObject = current.toObject();
char * toString(const EngineQuery &query)
QJsonValue at(qsizetype i) const const
qsizetype count() const const
bool isEmpty() const const
bool isEmpty() const const
QString toString() const const
void append(QList< T > &&value)
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:49:24 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.