diff options
author | Antti Hölttä <AHoelttae@luxoft.com> | 2018-12-04 14:48:36 +0100 |
---|---|---|
committer | Antti Hölttä <AHoelttae@luxoft.com> | 2019-03-18 16:33:53 +0100 |
commit | c58955328688a73bea53f65cd38dd3f07229b3e9 (patch) | |
tree | 33ae5c8968d40c18cc9a7ddfd3e1a19efd579be5 /plugin/cursornavigation.cpp | |
parent | 7a99a87e91f316e312bef8260534748d8b0df12c (diff) |
cursor trapping and navigation out of a scope works now as intended
done by precopying the list of candidates. Could avoid extra list
copies if the algorithm traversed the tree, but this is simpler and
works for now
Diffstat (limited to 'plugin/cursornavigation.cpp')
-rw-r--r-- | plugin/cursornavigation.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/plugin/cursornavigation.cpp b/plugin/cursornavigation.cpp index 7cdd80a..155a158 100644 --- a/plugin/cursornavigation.cpp +++ b/plugin/cursornavigation.cpp @@ -214,13 +214,29 @@ void CursorNavigation::_move(qreal angle, qreal tolerance, bool discrete) CursorNavigationAttached *CursorNavigation::_find(qreal angle, qreal tolerance, bool discrete) { CursorNavigationAttached *nextItem = nullptr; + CursorNavigationAttached *parent = m_currentItem ? + m_currentItem->m_parentNavigable : + m_rootItem; + + if (!m_currentItem) + return defaultItem(); qWarning() << "find next item, angle = " << angle << " tolerance = " << tolerance << " discrete = " << discrete; - CursorNavigationCommand cmd(angle, tolerance); - QList<CursorNavigationAttached*> &candidates = m_currentItem ? - m_currentItem->m_parentNavigable->m_children : - m_rootItem->m_children; + QList<CursorNavigationAttached*> candidates; + + do { + candidates.append(parent->m_children); + + if (parent->trapsCursor()) + break; + parent = parent->m_parentNavigable; + } while (parent); + + if (candidates.isEmpty()) + return nullptr; + + CursorNavigationCommand cmd(angle, tolerance); if (discrete) { nextItem = m_navigation4Dir.getNextCandidate(candidates, m_currentItem, cmd); @@ -230,3 +246,10 @@ CursorNavigationAttached *CursorNavigation::_find(qreal angle, qreal tolerance, return nextItem; } + +CursorNavigationAttached *CursorNavigation::defaultItem() +{ + if (m_rootItem->m_children.size()) + return m_rootItem->m_children.first(); + return nullptr; +} |