KTextAddons

grammarerror.cpp
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "grammarerror.h"
8
9using namespace TextGrammarCheck;
10GrammarError::GrammarError() = default;
11
12GrammarError::~GrammarError() = default;
13
14QColor GrammarError::color() const
15{
16 return mColor;
17}
18
19void GrammarError::setColor(const QColor &color)
20{
21 mColor = color;
22}
23
24QString GrammarError::error() const
25{
26 return mError;
27}
28
29void GrammarError::setError(const QString &error)
30{
31 mError = error;
32}
33
34int GrammarError::blockId() const
35{
36 return mBlockId;
37}
38
39void GrammarError::setBlockId(int blockId)
40{
41 mBlockId = blockId;
42}
43
44int GrammarError::start() const
45{
46 return mStart;
47}
48
49void GrammarError::setStart(int begin)
50{
51 mStart = begin;
52}
53
54int GrammarError::length() const
55{
56 return mLength;
57}
58
59void GrammarError::setLength(int length)
60{
61 mLength = length;
62}
63
64QStringList GrammarError::suggestions() const
65{
66 return mSuggestions;
67}
68
69void GrammarError::setSuggestions(const QStringList &suggestions)
70{
71 mSuggestions = suggestions;
72}
73
74bool GrammarError::isValid() const
75{
76 if ((mLength != -1) && (mStart != -1) && (!mError.isEmpty())) {
77 return true;
78 }
79 return false;
80}
81
82void GrammarError::parse(const QJsonObject &obj, int blockindex)
83{
84 Q_UNUSED(obj)
85 Q_UNUSED(blockindex)
86}
87
88bool GrammarError::operator==(const GrammarError &other) const
89{
90 return (mBlockId == other.blockId()) && (mLength == other.length()) && (mStart == other.start()) && (mColor == other.color())
91 && (mSuggestions == other.suggestions()) && (mError == other.error()) && (mOption == other.option()) && (mRule == other.rule())
92 && (mUrl == other.url());
93}
94
95QString GrammarError::url() const
96{
97 return mUrl;
98}
99
100void GrammarError::setUrl(const QString &url)
101{
102 mUrl = url;
103}
104
105QString GrammarError::rule() const
106{
107 return mRule;
108}
109
110void GrammarError::setRule(const QString &rule)
111{
112 mRule = rule;
113}
114
115QString GrammarError::option() const
116{
117 return mOption;
118}
119
120void GrammarError::setOption(const QString &option)
121{
122 mOption = option;
123}
124
125QDebug operator<<(QDebug d, const GrammarError &t)
126{
127 d << "mError: " << t.error();
128 d << "Start: " << t.start();
129 d << "Length: " << t.length();
130 d << "BlockId: " << t.blockId();
131 d << "Color: " << t.color().name();
132 d << "Suggestion: " << t.suggestions();
133 d << "Option: " << t.option();
134 d << "Rule: " << t.rule();
135 d << "Url: " << t.url();
136 return d;
137}
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
const QList< QKeySequence > & begin()
KTEXTEDITOR_EXPORT QDebug operator<<(QDebug s, const MovingCursor &cursor)
QString name(NameFormat format) const const
bool isEmpty() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:44 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.