From 00fa5d9215d32124292fe3e45372acebac7b9d31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20H=C3=B6ltt=C3=A4?= Date: Tue, 30 Oct 2018 15:40:04 +0100 Subject: Refactor item registration with scopes in mind ItemRegister class removed and items now keep track of their own cursor navigable child items. Navigation happens now only between siblings. --- plugin/cursornavigationattached.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'plugin/cursornavigationattached.h') diff --git a/plugin/cursornavigationattached.h b/plugin/cursornavigationattached.h index 2be0f72..1a8314c 100644 --- a/plugin/cursornavigationattached.h +++ b/plugin/cursornavigationattached.h @@ -3,6 +3,7 @@ //#include #include +#include class CursorNavigation; class QQuickItem; @@ -13,15 +14,17 @@ class CursorNavigationAttached : public QObject Q_OBJECT //is available for cursor navigation Q_PROPERTY(bool acceptsCursor READ acceptsCursor WRITE setAcceptsCursor NOTIFY acceptsCursorChanged) - //is available for cursor navigation + //indicates if item is currently selected, indicated also by activeFocus property Q_PROPERTY(bool hasCursor READ hasCursor NOTIFY hasCursorChanged) - //traps cursor. a trapped cursor can not be traversed outside of the item that traps it + //indicates if one of children is currently selected + Q_PROPERTY(bool childHasCursor READ hasCursor NOTIFY hasCursorChanged) + //traps cursor. a trapped cursor can not be traversed outside of the item that traps it until the escape input is given Q_PROPERTY(bool trapsCursor READ trapsCursor WRITE setTrapsCursor NOTIFY trapsCursorChanged) - //proxy cursor to other items - //Q_PROPERTY(QQmlListProperty preferredCursorTargets READ preferredCursorTargetsQML) + public: CursorNavigationAttached(QQuickItem *parent); + ~CursorNavigationAttached(); bool acceptsCursor() const; void setAcceptsCursor(bool acceptsCursor); @@ -31,6 +34,8 @@ public: bool trapsCursor() const; void setTrapsCursor(bool trapsCursor); + QQuickItem *item() const; + signals: void acceptsCursorChanged(bool acceptsCursor); void hasCursorChanged(bool hasCursor); @@ -40,10 +45,13 @@ private slots: void onWindowChanged(QQuickWindow *window); private: - QQuickItem *item() const; void setHasCursor(bool hasCursor); + QList &siblings(); CursorNavigation *m_cursorNavigation; + CursorNavigationAttached *m_parentNavigable; + QList m_children; + bool m_acceptsCursor; bool m_hasCursor; bool m_trapsCursor; -- cgit v1.2.3