Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit cdacc0f1 authored by Laurent Montel's avatar Laurent Montel 😁

Start to create grammarerror base class

parent d47aecaf
......@@ -6,6 +6,7 @@ set(kmailgrammalecte_SRCS
grammalecteconfigdialog.cpp
grammalectemanager.cpp
grammarresultwidget.cpp
grammalectegrammarerror.cpp
)
ecm_qt_declare_logging_category(kmailgrammalecte_SRCS HEADER libgrammalecte_debug.h IDENTIFIER LIBGRAMMALECTE_PLUGIN_LOG CATEGORY_NAME org.kde.pim.libgrammalecteplugin)
......
/*
Copyright (C) 2019 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "grammalectegrammarerror.h"
GrammalecteGrammarError::GrammalecteGrammarError()
{
}
void GrammalecteGrammarError::parse(const QJsonObject &obj, int blockindex)
{
mEnd = obj[QStringLiteral("nEnd")].toInt(-1);
mStart = obj[QStringLiteral("nStart")].toInt(-1);
mError = obj[QStringLiteral("sMessage")].toString();
if (mEnd != -1) {
mBlockId = blockindex;
mColor = parseColor(obj);
mSuggestions = parseSuggestion(obj);
}
mRule = obj[QStringLiteral("sRuleId")].toString();
mOption = obj[QStringLiteral("sType")].toString();
mUrl = obj[QStringLiteral("URL")].toString();
}
/*
Copyright (C) 2019 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef GRAMMALECTEGRAMMARERROR_H
#define GRAMMALECTEGRAMMARERROR_H
#include "grammarerror.h"
class GrammalecteGrammarError : public GrammarError
{
public:
GrammalecteGrammarError();
void parse(const QJsonObject &obj, int blockindex);
};
#endif // GRAMMALECTEGRAMMARERROR_H
......@@ -99,6 +99,7 @@ bool GrammarError::isValid() const
return false;
}
//Make as virtual
void GrammarError::parse(const QJsonObject &obj, int blockindex)
{
mEnd = obj[QStringLiteral("nEnd")].toInt(-1);
......
......@@ -17,8 +17,8 @@
Boston, MA 02110-1301, USA.
*/
#ifndef GRAMMALECTEINFO_H
#define GRAMMALECTEINFO_H
#ifndef GRAMMARERROR_H
#define GRAMMARERROR_H
#include <QObject>
#include <QColor>
......@@ -64,7 +64,7 @@ public:
Q_REQUIRED_RESULT QString url() const;
void setUrl(const QString &url);
private:
protected:
static QColor parseColor(const QJsonObject &obj);
static QStringList parseSuggestion(const QJsonObject &obj);
QStringList mSuggestions;
......@@ -80,4 +80,4 @@ private:
Q_DECLARE_METATYPE(GrammarError)
Q_DECLARE_TYPEINFO(GrammarError, Q_MOVABLE_TYPE);
GRAMMARCOMMON_EXPORT QDebug operator <<(QDebug d, const GrammarError &t);
#endif // GRAMMALECTEINFO_H
#endif // GRAMMARERROR_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment