File indexing completed on 2024-05-12 16:16:00
0001 /* 0002 SPDX-FileCopyrightText: 2019-2023 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "grammarerror.h" 0008 0009 using namespace TextGrammarCheck; 0010 GrammarError::GrammarError() = default; 0011 0012 GrammarError::~GrammarError() = default; 0013 0014 QColor GrammarError::color() const 0015 { 0016 return mColor; 0017 } 0018 0019 void GrammarError::setColor(const QColor &color) 0020 { 0021 mColor = color; 0022 } 0023 0024 QString GrammarError::error() const 0025 { 0026 return mError; 0027 } 0028 0029 void GrammarError::setError(const QString &error) 0030 { 0031 mError = error; 0032 } 0033 0034 int GrammarError::blockId() const 0035 { 0036 return mBlockId; 0037 } 0038 0039 void GrammarError::setBlockId(int blockId) 0040 { 0041 mBlockId = blockId; 0042 } 0043 0044 int GrammarError::start() const 0045 { 0046 return mStart; 0047 } 0048 0049 void GrammarError::setStart(int begin) 0050 { 0051 mStart = begin; 0052 } 0053 0054 int GrammarError::length() const 0055 { 0056 return mLength; 0057 } 0058 0059 void GrammarError::setLength(int length) 0060 { 0061 mLength = length; 0062 } 0063 0064 QStringList GrammarError::suggestions() const 0065 { 0066 return mSuggestions; 0067 } 0068 0069 void GrammarError::setSuggestions(const QStringList &suggestions) 0070 { 0071 mSuggestions = suggestions; 0072 } 0073 0074 bool GrammarError::isValid() const 0075 { 0076 if ((mLength != -1) && (mStart != -1) && (!mError.isEmpty())) { 0077 return true; 0078 } 0079 return false; 0080 } 0081 0082 void GrammarError::parse(const QJsonObject &obj, int blockindex) 0083 { 0084 Q_UNUSED(obj) 0085 Q_UNUSED(blockindex) 0086 } 0087 0088 bool GrammarError::operator==(const GrammarError &other) const 0089 { 0090 return (mBlockId == other.blockId()) && (mLength == other.length()) && (mStart == other.start()) && (mColor == other.color()) 0091 && (mSuggestions == other.suggestions()) && (mError == other.error()) && (mOption == other.option()) && (mRule == other.rule()) 0092 && (mUrl == other.url()); 0093 } 0094 0095 QString GrammarError::url() const 0096 { 0097 return mUrl; 0098 } 0099 0100 void GrammarError::setUrl(const QString &url) 0101 { 0102 mUrl = url; 0103 } 0104 0105 QString GrammarError::rule() const 0106 { 0107 return mRule; 0108 } 0109 0110 void GrammarError::setRule(const QString &rule) 0111 { 0112 mRule = rule; 0113 } 0114 0115 QString GrammarError::option() const 0116 { 0117 return mOption; 0118 } 0119 0120 void GrammarError::setOption(const QString &option) 0121 { 0122 mOption = option; 0123 } 0124 0125 QDebug operator<<(QDebug d, const GrammarError &t) 0126 { 0127 d << "mError: " << t.error(); 0128 d << "Start: " << t.start(); 0129 d << "Length: " << t.length(); 0130 d << "BlockId: " << t.blockId(); 0131 d << "Color: " << t.color().name(); 0132 d << "Suggestion: " << t.suggestions(); 0133 d << "Option: " << t.option(); 0134 d << "Rule: " << t.rule(); 0135 d << "Url: " << t.url(); 0136 return d; 0137 }