diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,6 @@ add_subdirectory(akonadi) add_subdirectory(domain) add_subdirectory(presentation) -add_subdirectory(scripting) add_subdirectory(utils) add_subdirectory(widgets) diff --git a/src/scripting/CMakeLists.txt b/src/scripting/CMakeLists.txt deleted file mode 100644 --- a/src/scripting/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -set(scripting_SRCS - scripthandler.cpp - taskaction.cpp -) - -add_library(scripting STATIC ${scripting_SRCS}) -target_link_libraries(scripting - Qt5::Core - Qt5::Qml -) - diff --git a/src/scripting/scripthandler.h b/src/scripting/scripthandler.h deleted file mode 100644 --- a/src/scripting/scripthandler.h +++ /dev/null @@ -1,55 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Theo Vaucher - - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#ifndef SCRIPTING_SCRIPTHANDLER_H -#define SCRIPTING_SCRIPTHANDLER_H - -#include -#include - -#include "domain/taskrepository.h" - -namespace Scripting -{ - -class ScriptHandler : public QObject -{ - Q_OBJECT -public: - explicit ScriptHandler(const Domain::TaskRepository::Ptr &taskRepository, QObject *parent = nullptr); - - QJSValue evaluateFile(const QString &filename); - QJSValue evaluateString(const QString &string); - - QJSEngine *engine(); - -private: - Domain::TaskRepository::Ptr m_taskRepository; - - QJSEngine *m_engine; -}; - -} - -#endif // SCRIPTING_SCRIPTHANDLER_H diff --git a/src/scripting/scripthandler.cpp b/src/scripting/scripthandler.cpp deleted file mode 100644 --- a/src/scripting/scripthandler.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Theo Vaucher - - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "scripthandler.h" -#include "taskaction.h" - -#include -#include - -using namespace Scripting; - -ScriptHandler::ScriptHandler(const Domain::TaskRepository::Ptr &taskRepository, QObject *parent) - : QObject(parent), - m_taskRepository(taskRepository), - m_engine(new QJSEngine(this)) -{ - m_engine->globalObject().setProperty(QStringLiteral("task"), - m_engine->newQObject(new TaskAction(m_taskRepository, this))); -} - -QJSValue ScriptHandler::evaluateFile(const QString &filename) -{ - QFile file(filename); - file.open(QIODevice::ReadOnly); - QByteArray filecontent = file.readAll(); - file.close(); - - return m_engine->evaluate(filecontent, filename); -} - -QJSValue ScriptHandler::evaluateString(const QString &string) -{ - return m_engine->evaluate(string); -} - -QJSEngine *ScriptHandler::engine() -{ - return m_engine; -} - diff --git a/src/scripting/taskaction.h b/src/scripting/taskaction.h deleted file mode 100644 --- a/src/scripting/taskaction.h +++ /dev/null @@ -1,50 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Theo Vaucher - - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#ifndef SCRIPTING_TASKACTION_H -#define SCRIPTING_TASKACTION_H - -#include - -#include "domain/taskrepository.h" - -#include "presentation/errorhandlingmodelbase.h" - -namespace Scripting { - -class TaskAction : public QObject, public Presentation::ErrorHandlingModelBase -{ - Q_OBJECT -public: - explicit TaskAction(const Domain::TaskRepository::Ptr &taskRepository, QObject *parent = nullptr); - -public slots: - -private: - Domain::TaskRepository::Ptr m_taskRepository; -}; - -} - -#endif // SCRIPTING_TASKACTION_H diff --git a/src/scripting/taskaction.cpp b/src/scripting/taskaction.cpp deleted file mode 100644 --- a/src/scripting/taskaction.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Theo Vaucher - - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "taskaction.h" - -using namespace Scripting; - -TaskAction::TaskAction(const Domain::TaskRepository::Ptr &taskRepository, QObject *parent) - : QObject(parent), - m_taskRepository(taskRepository) -{ -} - diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -15,7 +15,6 @@ runningtaskwidget.cpp quickselectdialog.cpp quickselectdialoginterface.cpp - scripteditor.cpp ) ki18n_wrap_ui(widgets_SRCS @@ -26,7 +25,6 @@ add_library(widgets STATIC ${widgets_SRCS}) target_link_libraries(widgets - Qt5::Qml Qt5::Widgets presentation zanshinkdepimstatic diff --git a/src/widgets/scripteditor.h b/src/widgets/scripteditor.h deleted file mode 100644 --- a/src/widgets/scripteditor.h +++ /dev/null @@ -1,57 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Theo Vaucher - - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#ifndef WIDGETS_SCRIPTEDITOR_H -#define WIDGETS_SCRIPTEDITOR_H - -#include - -#include "presentation/metatypes.h" - -class ScriptHandler; -class QTextEdit; - -namespace Widgets { - -class ScriptEditor : public QMainWindow -{ - Q_OBJECT -public: - explicit ScriptEditor(QWidget *parent = nullptr); - virtual ~ScriptEditor(); - - QObjectPtr scriptHandler() const; - -public slots: - void setScriptHandler(const QObjectPtr &scriptHandler); - -private: - QObjectPtr m_scriptHandler; - - QTextEdit *m_textEdit; -}; - -} - -#endif // WIDGETS_SCRIPTEDITOR_H diff --git a/src/widgets/scripteditor.cpp b/src/widgets/scripteditor.cpp deleted file mode 100644 --- a/src/widgets/scripteditor.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Theo Vaucher - - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include "scripteditor.h" - -#include "scripting/scripthandler.h" - -#include - -#include - -using namespace Widgets; - -ScriptEditor::ScriptEditor(QWidget *parent) - : QMainWindow(parent), - m_textEdit(new QTextEdit(this)) -{ - setWindowTitle(i18n("Script Editor - Zanshin")); - resize(600, 600); - setCentralWidget(m_textEdit); -} - -ScriptEditor::~ScriptEditor() -{ -} - -QObjectPtr ScriptEditor::scriptHandler() const -{ - return m_scriptHandler; -} - -void ScriptEditor::setScriptHandler(const QObjectPtr &scriptHandler) -{ - if (m_scriptHandler == scriptHandler) - return; - - m_scriptHandler = scriptHandler; -} diff --git a/src/zanshin/app/CMakeLists.txt b/src/zanshin/app/CMakeLists.txt --- a/src/zanshin/app/CMakeLists.txt +++ b/src/zanshin/app/CMakeLists.txt @@ -12,7 +12,6 @@ akonadi domain presentation - scripting utils widgets ) diff --git a/src/zanshin/kontact/CMakeLists.txt b/src/zanshin/kontact/CMakeLists.txt --- a/src/zanshin/kontact/CMakeLists.txt +++ b/src/zanshin/kontact/CMakeLists.txt @@ -11,7 +11,6 @@ akonadi domain presentation - scripting utils widgets ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,7 +22,6 @@ akonadi domain presentation - scripting utils widgets ) @@ -49,7 +48,6 @@ akonadi domain presentation - scripting utils widgets KF5::AkonadiXml diff --git a/tests/features/zanshin/features/step_definitions/CMakeLists.txt b/tests/features/zanshin/features/step_definitions/CMakeLists.txt --- a/tests/features/zanshin/features/step_definitions/CMakeLists.txt +++ b/tests/features/zanshin/features/step_definitions/CMakeLists.txt @@ -18,11 +18,9 @@ ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} Qt5::Test - Qt5::Qml testlib akonadi domain presentation - scripting utils ) diff --git a/tests/units/CMakeLists.txt b/tests/units/CMakeLists.txt --- a/tests/units/CMakeLists.txt +++ b/tests/units/CMakeLists.txt @@ -2,7 +2,6 @@ add_subdirectory(domain) add_subdirectory(presentation) add_subdirectory(utils) -add_subdirectory(scripting) add_subdirectory(testlib) add_subdirectory(widgets) add_subdirectory(migrator) diff --git a/tests/units/scripting/CMakeLists.txt b/tests/units/scripting/CMakeLists.txt deleted file mode 100644 --- a/tests/units/scripting/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -zanshin_auto_tests( - scripthandlertest - taskactiontest -) - diff --git a/tests/units/scripting/scripthandlertest.cpp b/tests/units/scripting/scripthandlertest.cpp deleted file mode 100644 --- a/tests/units/scripting/scripthandlertest.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Theo Vaucher - - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include - -#include - -#include "scripting/scripthandler.h" - -#include "utils/mockobject.h" - -class ScriptHandlerTest : public QObject -{ - Q_OBJECT -private slots: - void shouldBindObjects() - { - // GIVEN - Utils::MockObject taskRepositoryMock; - - // WHEN - auto scripthandler = new Scripting::ScriptHandler(taskRepositoryMock.getInstance(), this); - - // THEN - QVERIFY(!scripthandler->engine()->globalObject().property(QStringLiteral("task")).isNull()); - QVERIFY(scripthandler->engine()->globalObject().property(QStringLiteral("task")).isObject()); - } - - void shouldEvaluateString() - { - // GIVEN - Utils::MockObject taskRepositoryMock; - auto scripthandler = new Scripting::ScriptHandler(taskRepositoryMock.getInstance(), this); - - auto expression = QStringLiteral("41+1"); - - // WHEN - QJSValue result = scripthandler->evaluateString(expression); - - // THEN - QVERIFY(result.isNumber()); - QCOMPARE(result.toInt(), 42); - } - - void shouldEvaluateFile() - { - // GIVEN - Utils::MockObject taskRepositoryMock; - auto scripthandler = new Scripting::ScriptHandler(taskRepositoryMock.getInstance(), this); - - auto expression = QStringLiteral("41+1"); - - QTemporaryFile scriptfile; - scriptfile.setAutoRemove(true); - scriptfile.open(); - scriptfile.write(expression.toLocal8Bit()); - scriptfile.close(); - - // WHEN - QJSValue result = scripthandler->evaluateFile(scriptfile.fileName()); - - // THEN - QVERIFY(result.isNumber()); - QCOMPARE(result.toInt(), 42); - } -}; - -ZANSHIN_TEST_MAIN(ScriptHandlerTest) - -#include "scripthandlertest.moc" diff --git a/tests/units/scripting/taskactiontest.cpp b/tests/units/scripting/taskactiontest.cpp deleted file mode 100644 --- a/tests/units/scripting/taskactiontest.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Theo Vaucher - - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - -#include - -#include "scripting/taskaction.h" - -using namespace Scripting; - -class TaskActionTest : public QObject -{ - Q_OBJECT -private slots: -}; - -ZANSHIN_TEST_MAIN(TaskActionTest) - -#include "taskactiontest.moc" diff --git a/tests/units/widgets/CMakeLists.txt b/tests/units/widgets/CMakeLists.txt --- a/tests/units/widgets/CMakeLists.txt +++ b/tests/units/widgets/CMakeLists.txt @@ -9,7 +9,6 @@ pageviewtest quickselectdialogtest runningtaskwidgettest - scripteditortest ) # These tests need a window that takes focus diff --git a/tests/units/widgets/scripteditortest.cpp b/tests/units/widgets/scripteditortest.cpp deleted file mode 100644 --- a/tests/units/widgets/scripteditortest.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* This file is part of Zanshin - - Copyright 2015 Theo Vaucher - - 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) version 3 or any later version - accepted by the membership of KDE e.V. (or its successor approved - by the membership of KDE e.V.), which shall act as a proxy - defined in Section 14 of version 3 of the license. - - 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; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. -*/ - - -#include - -#include "widgets/scripteditor.h" - -class ScriptEditorTest : public QObject -{ - Q_OBJECT -private slots: - void shouldNotHaveScriptHandler() - { - // GIVEN - Widgets::ScriptEditor scriptEditor; - - // THEN - QVERIFY(scriptEditor.scriptHandler().isNull()); - } - - void shouldHaveScriptHandler() - { - // GIVEN - Widgets::ScriptEditor scriptEditor; - auto scriptHandler = QObjectPtr::create(); - - // WHEN - scriptEditor.setScriptHandler(scriptHandler); - - // THEN - QCOMPARE(scriptEditor.scriptHandler(), scriptHandler); - } -}; - -ZANSHIN_TEST_MAIN(ScriptEditorTest) - -#include "scripteditortest.moc"