From b0de855379a9242d74353dfd66677d4b1b5dbcec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20H=C3=B6ltt=C3=A4?= Date: Wed, 13 Mar 2019 13:09:48 +0100 Subject: Little fixes and cleanup, TODOs Explained some TODOs a bit better. Fixed mismatching tab titles in demo app. Removed unused predefined CursorNavigationCommands. --- DemoApplication/main.qml | 2 +- plugin/cursornavigation.cpp | 12 ++++++++---- plugin/inputtypes.cpp | 5 ----- plugin/inputtypes.h | 12 ++++-------- plugin/spatialnavigation4dir.cpp | 2 +- tests/tst_cursornavigation.cpp | 5 +++++ 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/DemoApplication/main.qml b/DemoApplication/main.qml index 2c96537..0f88400 100644 --- a/DemoApplication/main.qml +++ b/DemoApplication/main.qml @@ -112,8 +112,8 @@ ApplicationWindow { anchors.fill: parent currentIndex: tabBar.currentIndex Basics { } - FlipButtons { } Lists { } + FlipButtons { } MapView { } Redirects { } } diff --git a/plugin/cursornavigation.cpp b/plugin/cursornavigation.cpp index 00a1af0..e2b5856 100644 --- a/plugin/cursornavigation.cpp +++ b/plugin/cursornavigation.cpp @@ -134,9 +134,6 @@ CursorNavigationAttached *CursorNavigation::qmlAttachedProperties(QObject *objec QQuickItem *item = static_cast(object); - // TODO: what if an object, with an already attached object, gets reparented (say, in another window?) - // with or without a focus system. - qWarning() << "Created a new CN attachment"; return new CursorNavigationAttached(item); } @@ -227,6 +224,14 @@ void CursorNavigation::registerItem(CursorNavigationAttached* item) m_rootItem->m_children.append(item); item->m_parentNavigable=m_rootItem; } + + /* TODO reparenting from window to another kind of works, but reparenting + * within a window not so well. problems arise when reaprenting items + * contained in an item that is also navigable. for this to work, we would + * need to detect all parent changes, including items non navigable parents + * and grandparents, and reorganize the internal tree when needed. + * For now, consider reparenting as not recommended + */ } void CursorNavigation::unregisterItem(CursorNavigationAttached* item) @@ -238,7 +243,6 @@ void CursorNavigation::unregisterItem(CursorNavigationAttached* item) if (item->m_parentNavigable) item->m_parentNavigable->m_children.removeOne(item); - //TODO if the item that is being unregistered has children, they should be reassigned to the item's parent } CursorNavigationAttached *CursorNavigation::defaultItem() diff --git a/plugin/inputtypes.cpp b/plugin/inputtypes.cpp index a1b2f8d..c114ec8 100644 --- a/plugin/inputtypes.cpp +++ b/plugin/inputtypes.cpp @@ -1,11 +1,6 @@ #include "inputtypes.h" #include -const CursorNavigationCommand CursorNavigationCommand::Up(-M_PI_2, 0); -const CursorNavigationCommand CursorNavigationCommand::Down(M_PI_2, 0); -const CursorNavigationCommand CursorNavigationCommand::Left(M_PI, 0); -const CursorNavigationCommand CursorNavigationCommand::Right(0, 0); - CursorNavigationCommand::CursorNavigationCommand() :angle(-1), angleTolerance(-1), action(NoAction) {} diff --git a/plugin/inputtypes.h b/plugin/inputtypes.h index 9de40a4..53698fa 100644 --- a/plugin/inputtypes.h +++ b/plugin/inputtypes.h @@ -29,11 +29,6 @@ struct CursorNavigationCommand qreal angleTolerance; //0 to pi Action action; - static const CursorNavigationCommand Up; - static const CursorNavigationCommand Down; - static const CursorNavigationCommand Left; - static const CursorNavigationCommand Right; - //test if given angle is between given sector. sector defined clockwise from begin to end static bool angleIsBetween(qreal angle, qreal begin, qreal end); @@ -42,9 +37,10 @@ struct CursorNavigationCommand }; -/*feedback datatype returned for commands, describing command results - *this could be used for example to indicate that a end of a list has been reached, - *that might produce force feedback on certain inut devices +/* TODO feedback + * feedback datatype returned for commands, describing command results + * this could be used for example to indicate that a end of a list has been reached, + * that might produce force feedback on certain inut devices */ enum CommandResult { diff --git a/plugin/spatialnavigation4dir.cpp b/plugin/spatialnavigation4dir.cpp index 8bccd7c..69c3fc3 100644 --- a/plugin/spatialnavigation4dir.cpp +++ b/plugin/spatialnavigation4dir.cpp @@ -52,7 +52,7 @@ CursorNavigationAttached* SpatialNavigation4Dir::getNextCandidate( const QRectF currentItemSceneRect = currentItem->item()->mapRectToScene(QRectF( 0, 0, currentItem->item()->width(), currentItem->item()->height() )); - //NOTICE: overlapping candidates will be ignored for now (TODO, this needs to be changed) + //NOTICE: candidates overlapping with current item will be ignored for now (TODO, this needs to be changed) qreal right_start = -M_PI_4; qreal right_end = M_PI_4; diff --git a/tests/tst_cursornavigation.cpp b/tests/tst_cursornavigation.cpp index 60ff6ef..5d842db 100644 --- a/tests/tst_cursornavigation.cpp +++ b/tests/tst_cursornavigation.cpp @@ -328,6 +328,11 @@ void TestCursorNavigation::test_targetDeletions() void TestCursorNavigation::test_reparenting() { + /* notice, that reparenting from window to another works, but reparenting + * within a window not so well. problems there arise when reaprenting items + * contained in an item that is also navigable. reparenting2.qml covers this + */ + QQmlApplicationEngine *engine = new QQmlApplicationEngine(QFINDTESTDATA("reparenting.qml")); QQuickWindow *window0 = nullptr; -- cgit v1.2.3