Commit 52e06ce2 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement grammalecte support

parent 76822037
......@@ -126,6 +126,9 @@ find_package(KF5MailImporterAkonadi ${MAILIMPORTER_LIB_VERSION} CONFIG REQUIRED)
find_package(KPimPkPass ${KPIMPKPASS_LIB_VERSION} CONFIG REQUIRED)
find_package(KPimItinerary ${KPIMITINERARY_LIB_VERSION} CONFIG REQUIRED)
if(BUILD_TESTING)
add_definitions(-DBUILD_TESTING)
endif(BUILD_TESTING)
if(KDEPIM_ENTERPRISE_BUILD)
set(KDEPIM_ENTERPRISE_BUILD true)
......
......@@ -7,11 +7,11 @@ macro(add_kmail_grammalecte_unittest _source _additional)
add_test(NAME ${_name} COMMAND ${_name} )
ecm_mark_as_test(kmail_grammalecte-${_name})
target_link_libraries( ${_name} Qt5::Test KF5::XmlGui KF5::IconThemes KF5::I18n)
target_link_libraries( ${_name} Qt5::Test KF5::XmlGui KF5::IconThemes KF5::I18n libkmailgrammalect)
endmacro ()
add_kmail_grammalecte_unittest(grammalecteparsertest.cpp "")
add_kmail_grammalecte_unittest(grammarresultwidgettest.cpp "")
add_kmail_grammalecte_unittest(grammalecteinfotest.cpp "")
add_kmail_grammalecte_unittest(grammarresultjobtest.cpp "")
add_kmail_grammalecte_unittest(grammarresulttextedittest.cpp "")
......@@ -27,3 +27,15 @@ GrammalecteInfoTest::GrammalecteInfoTest(QObject *parent)
{
}
void GrammalecteInfoTest::shouldHaveDefaultValue()
{
GrammalecteInfo info;
QCOMPARE(info.end(), -1);
QCOMPARE(info.begin(), -1);
QCOMPARE(info.blockId(), -1);
QVERIFY(info.error().isEmpty());
QVERIFY(info.suggestions().isEmpty());
QVERIFY(!info.color().isValid());
QVERIFY(!info.isValid());
}
......@@ -27,6 +27,8 @@ class GrammalecteInfoTest : public QObject
public:
explicit GrammalecteInfoTest(QObject *parent = nullptr);
~GrammalecteInfoTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // GRAMMALECTEINFOTEST_H
......@@ -19,6 +19,7 @@
#include "grammalecteparsertest.h"
#include "grammalecteparser.h"
#include <QTest>
QTEST_MAIN(GrammalecteParserTest)
......
......@@ -18,6 +18,7 @@
*/
#include "grammarresultjobtest.h"
#include "grammarresultjob.h"
#include <QTest>
QTEST_MAIN(GrammarResultJobTest)
GrammarResultJobTest::GrammarResultJobTest(QObject *parent)
......@@ -25,3 +26,9 @@ GrammarResultJobTest::GrammarResultJobTest(QObject *parent)
{
}
void GrammarResultJobTest::shouldHaveDefaultValue()
{
GrammarResultJob job;
QVERIFY(!job.canStart());
}
......@@ -28,6 +28,8 @@ class GrammarResultJobTest : public QObject
public:
explicit GrammarResultJobTest(QObject *parent = nullptr);
~GrammarResultJobTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // GRAMMARRESULTJOBTEST_H
/*
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 "grammarresulttextedittest.h"
#include "grammarresulttextedit.h"
#include <QTest>
QTEST_MAIN(GrammarResultTextEditTest)
GrammarResultTextEditTest::GrammarResultTextEditTest(QObject *parent)
: QObject(parent)
{
}
void GrammarResultTextEditTest::shouldHaveDefaultValue()
{
GrammarResultTextEdit w;
QVERIFY(w.isReadOnly());
QVERIFY(!w.acceptRichText());
}
/*
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 GRAMMARRESULTTEXTEDITTEST_H
#define GRAMMARRESULTTEXTEDITTEST_H
#include <QObject>
class GrammarResultTextEditTest : public QObject
{
Q_OBJECT
public:
explicit GrammarResultTextEditTest(QObject *parent = nullptr);
~GrammarResultTextEditTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // GRAMMARRESULTTEXTEDITTEST_H
......@@ -18,6 +18,9 @@
*/
#include "grammarresultwidgettest.h"
#include "grammarresultwidget.h"
#include "grammarresulttextedit.h"
#include <QHBoxLayout>
#include <QTest>
QTEST_MAIN(GrammarResultWidgetTest)
......@@ -26,3 +29,13 @@ GrammarResultWidgetTest::GrammarResultWidgetTest(QObject *parent)
{
}
void GrammarResultWidgetTest::shouldHaveDefaultValue()
{
GrammarResultWidget w;
QHBoxLayout *mainLayout = w.findChild<QHBoxLayout *>(QStringLiteral("mainlayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->margin(), 0);
GrammarResultTextEdit *mResult = w.findChild<GrammarResultTextEdit *>(QStringLiteral("grammarResult"));
QVERIFY(mResult);
}
......@@ -27,6 +27,8 @@ class GrammarResultWidgetTest : public QObject
public:
explicit GrammarResultWidgetTest(QObject *parent = nullptr);
~GrammarResultWidgetTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValue();
};
#endif // GRAMMARRESULTWIDGETTEST_H
......@@ -4,13 +4,29 @@ set(kmail_grammalecteplugin_SRCS
grammarresulttextedit.cpp
grammalecteinfo.cpp
grammarresultjob.cpp
grammalecteconfigwidget.cpp
)
ecm_qt_declare_logging_category(kmail_grammalecteplugin_SRCS HEADER grammalecteplugin_debug.h IDENTIFIER KMAIL_EDITOR_GRAMMALECTE_PLUGIN_LOG CATEGORY_NAME org.kde.pim.kmail_grammalecteplugin)
kcoreaddons_add_plugin(kmail_grammalecteplugin JSON kmail_grammalecteplugin.json SOURCES
${kmail_grammalecteplugin_SRCS} INSTALL_NAMESPACE kmail)
target_link_libraries(kmail_grammalecteplugin
KF5::IconThemes KF5::MessageComposer KF5::I18n KF5::PimCommon
add_library(libkmailgrammalect ${kmail_grammalecteplugin_SRCS})
generate_export_header(libkmailgrammalect BASE_NAME libkmailgrammalect)
target_link_libraries(libkmailgrammalect
KF5::I18n
KF5::IconThemes
)
set_target_properties(libkmailgrammalect
PROPERTIES OUTPUT_NAME libkmailgrammalect VERSION ${KDEPIMADDONS_LIB_VERSION} SOVERSION ${KDEPIMADDONS_LIB_SOVERSION}
)
install(TARGETS libkmailgrammalect ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP)
#kcoreaddons_add_plugin(kmail_grammalecteplugin JSON kmail_grammalecteplugin.json SOURCES
# ${kmail_grammalecteplugin_SRCS} INSTALL_NAMESPACE kmail)
#target_link_libraries(kmail_grammalecteplugin
# KF5::IconThemes KF5::MessageComposer KF5::I18n KF5::PimCommon libkmailgrammalect
# )
/*
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 "grammalecteconfigwidget.h"
#include <QVBoxLayout>
#include <KLocalizedString>
GrammalecteConfigWidget::GrammalecteConfigWidget(QWidget *parent)
: QWidget(parent)
{
}
GrammalecteConfigWidget::~GrammalecteConfigWidget()
{
}
/*
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 GRAMMALECTECONFIGWIDGET_H
#define GRAMMALECTECONFIGWIDGET_H
#include <QWidget>
#include "libgrammalect_private_export.h"
class LIBGRAMMALECTPRIVATE_TESTS_EXPORT GrammalecteConfigWidget : public QWidget
{
Q_OBJECT
public:
explicit GrammalecteConfigWidget(QWidget *parent = nullptr);
~GrammalecteConfigWidget();
};
#endif // GRAMMALECTECONFIGWIDGET_H
......@@ -88,3 +88,9 @@ void GrammalecteInfo::setSuggestions(const QStringList &suggestions)
{
mSuggestions = suggestions;
}
bool GrammalecteInfo::isValid() const
{
//TODO
return false;
}
......@@ -23,8 +23,8 @@
#include <QObject>
#include <QColor>
#include <QString>
class GrammalecteInfo
#include "libgrammalect_private_export.h"
class LIBGRAMMALECTPRIVATE_TESTS_EXPORT GrammalecteInfo
{
public:
GrammalecteInfo();
......@@ -47,6 +47,8 @@ public:
Q_REQUIRED_RESULT QStringList suggestions() const;
void setSuggestions(const QStringList &suggestions);
Q_REQUIRED_RESULT bool isValid() const;
private:
QStringList mSuggestions;
QString mError;
......
......@@ -22,9 +22,9 @@
#include <QVector>
#include <QJsonObject>
class GrammalecteInfo;
class GrammalecteParser
#include "libgrammalect_private_export.h"
#include "grammalecteinfo.h"
class LIBGRAMMALECTPRIVATE_TESTS_EXPORT GrammalecteParser
{
public:
GrammalecteParser();
......
......@@ -18,6 +18,7 @@
*/
#include "grammarresultjob.h"
#include "grammalecteplugin_debug.h"
GrammarResultJob::GrammarResultJob(QObject *parent)
: QObject(parent)
......@@ -35,7 +36,9 @@ void GrammarResultJob::start()
if (canStart()) {
//TODO
} else {
//TODO
qCWarning(KMAIL_EDITOR_GRAMMALECTE_PLUGIN_LOG) << "Impossible to start grammarresultjob";
Q_EMIT error();
deleteLater();
}
}
......
......@@ -21,8 +21,8 @@
#define GRAMMARRESULTJOB_H
#include <QObject>
class GrammarResultJob : public QObject
#include "libgrammalect_private_export.h"
class LIBGRAMMALECTPRIVATE_TESTS_EXPORT GrammarResultJob : public QObject
{
Q_OBJECT
public:
......@@ -30,13 +30,16 @@ public:
~GrammarResultJob();
void start();
Q_REQUIRED_RESULT bool canStart() const;
Q_REQUIRED_RESULT QString text() const;
void setText(const QString &text);
Q_SIGNALS:
void finished();
void error();
private:
QString mText;
};
......
......@@ -32,11 +32,6 @@ GrammarResultTextEdit::~GrammarResultTextEdit()
}
void GrammarResultTextEdit::setText(const QString &str)
{
//TODO
}
void GrammarResultTextEdit::checkGrammar()
{
//TODO
......
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