diff --git a/CMakeLists.txt b/CMakeLists.txt index cebcbdf6..61719c7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,8 +157,6 @@ set(MALIIT_KEYBOARD_COMMON_SOURCES src/plugin/feedback.h src/plugin/gettext.cpp src/plugin/gettext.h - src/plugin/updatenotifier.cpp - src/plugin/updatenotifier.h src/plugin/inputmethod.cpp src/plugin/inputmethod.h src/plugin/inputmethod_p.h diff --git a/src/plugin/inputmethod.cpp b/src/plugin/inputmethod.cpp index a8f76741..b27da8a0 100644 --- a/src/plugin/inputmethod.cpp +++ b/src/plugin/inputmethod.cpp @@ -42,14 +42,11 @@ #include "view/setup.h" #include -#include #include #include -class MImUpdateEvent; - using namespace MaliitKeyboard; namespace { diff --git a/src/plugin/updatenotifier.cpp b/src/plugin/updatenotifier.cpp deleted file mode 100644 index 33d5420e..00000000 --- a/src/plugin/updatenotifier.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * This file is part of Maliit Plugins - * - * Copyright (C) 2012 Openismus GmbH. All rights reserved. - * - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * Neither the name of Nokia Corporation nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "updatenotifier.h" - -#include - -namespace MaliitKeyboard { - -namespace -{ - -const char* const g_surrounding_text_property("surroundingText"); -const char* const g_cursor_position_property("cursorPosition"); -const char* const g_anchor_position_property("anchorPosition"); -const char* const g_has_selection("hasSelection"); - -} // unnamed namespace - -class UpdateNotifierPrivate -{ -public: - UpdateNotifierPrivate(); - - bool has_selection; -}; - -UpdateNotifierPrivate::UpdateNotifierPrivate() - : has_selection(false) -{} - -UpdateNotifier::UpdateNotifier(QObject *parent) - : QObject(parent) - , d_ptr(new UpdateNotifierPrivate) -{} - -UpdateNotifier::~UpdateNotifier() = default; - -void UpdateNotifier::notify(MImUpdateEvent* event) -{ - Q_D(UpdateNotifier); - - const QStringList properties_changed(event->propertiesChanged()); - - if (properties_changed.contains(g_has_selection)) { - const bool has_selection(event->value(g_has_selection).toBool()); - - d->has_selection = has_selection; - } - - if (not d->has_selection and properties_changed.contains(g_cursor_position_property)) { - const int cursor_position(event->value(g_cursor_position_property).toInt()); - const QString surrounding_text(event->value(g_surrounding_text_property).toString()); - bool emit_a_signal(true); - - if (emit_a_signal and properties_changed.contains(g_anchor_position_property)) { - const int anchor_position(event->value(g_anchor_position_property).toInt()); - - emit_a_signal = (anchor_position == cursor_position); - } - - if (emit_a_signal) { - Q_EMIT cursorPositionChanged(cursor_position, surrounding_text); - } - } -} - -void UpdateNotifier::notifyOverride(const Logic::KeyOverrides &overridden_keys, - bool update /* = false */) -{ - Q_EMIT keysOverridden(overridden_keys, update); -} - -} // namespace MaliitKeyboard diff --git a/src/plugin/updatenotifier.h b/src/plugin/updatenotifier.h deleted file mode 100644 index aa1b4c1f..00000000 --- a/src/plugin/updatenotifier.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of Maliit Plugins - * - * Copyright (C) 2012 Openismus GmbH. All rights reserved. - * - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * Redistributions of source code must retain the above copyright notice, this list - * of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list - * of conditions and the following disclaimer in the documentation and/or other materials - * provided with the distribution. - * Neither the name of Nokia Corporation nor the names of its contributors may be - * used to endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef MALIIT_KEYBOARD_UPDATENOTIFIER_H -#define MALIIT_KEYBOARD_UPDATENOTIFIER_H - -#include -#include - -class MImUpdateEvent; - -namespace MaliitKeyboard { -class Key; - -namespace Logic -{ -typedef QMap KeyOverrides; -} - -class UpdateNotifierPrivate; - -class UpdateNotifier - : public QObject -{ - Q_OBJECT - Q_DISABLE_COPY(UpdateNotifier) - Q_DECLARE_PRIVATE(UpdateNotifier) - -public: - explicit UpdateNotifier(QObject *parent = nullptr); - ~UpdateNotifier() override; - - void notify(MImUpdateEvent *event); - void notifyOverride(const Logic::KeyOverrides &overridden_keys, - bool update = false); - - Q_SIGNAL void cursorPositionChanged(int cursor_position, - const QString &surrounding_text); - Q_SIGNAL void keysOverridden(const Logic::KeyOverrides &overridden_keys, - bool update); - -private: - const QScopedPointer d_ptr; -}; - -} // namespace MaliitKeyboard - -#endif // MALIIT_KEYBOARD_UPDATENOTIFIER_H diff --git a/tests/unittests/ut_preedit-string/ut_preedit-string.cpp b/tests/unittests/ut_preedit-string/ut_preedit-string.cpp index fe5b7c6e..8784372f 100644 --- a/tests/unittests/ut_preedit-string/ut_preedit-string.cpp +++ b/tests/unittests/ut_preedit-string/ut_preedit-string.cpp @@ -45,12 +45,10 @@ #include "view/setup.h" #include "plugin/editor.h" -#include "plugin/updatenotifier.h" #include "inputmethodhostprobe.h" #include "wordengineprobe.h" #include -#include #include #include @@ -147,19 +145,6 @@ bool operator==(const Maliit::PreeditTextFormat &a, const Maliit::PreeditTextFor return ((a.start == b.start) and (a.length == b.length) and (a.preeditFace == b.preeditFace)); } -MImUpdateEvent *createUpdateEvent(const QString &surrounding_text, - int cursor_position) -{ - const char *const cur_pos("cursorPosition"); - QStringList properties_changed(cur_pos); - QMap update; - - update.insert(cur_pos, cursor_position); - update.insert("surroundingText", surrounding_text); - - return new MImUpdateEvent(update, properties_changed); -} - } // unnamed namespace struct BasicSetupTest @@ -175,7 +160,6 @@ struct BasicSetupTest Editor editor; InputMethodHostProbe host; - UpdateNotifier notifier; }; class SetupTest @@ -477,10 +461,6 @@ class TestPreeditString QFETCH(bool, expected_preedit_string_sent); BasicSetupTest test_setup; - QScopedPointer update_event(createUpdateEvent(surrounding_text, - cursor_position)); - - test_setup.notifier.notify(update_event.data()); QCOMPARE(test_setup.host.preeditStringSent(), expected_preedit_string_sent); if (expected_preedit_string_sent) { @@ -602,10 +582,6 @@ class TestPreeditString QFETCH(int, expected_cursor_position); SetupTest test_setup; - QScopedPointer update_event(createUpdateEvent(surrounding_text, - cursor_position)); - - test_setup.notifier.notify(update_event.data()); Q_FOREACH (const QString &k, keys) { test_setup.event_handler.onPressed(lookup(k));