| 582 | } |
| 583 | |
| 584 | Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { |
| 585 | if ( event.getMod() & KEYMOD_CTRL_SHIFT_ALT_META ) |
| 586 | return UIAbstractTableView::onKeyDown( event ); |
| 587 | auto curIndex = getSelection().first(); |
| 588 | |
| 589 | if ( nullptr == getModel() || !getModel()->hasChildren() ) |
| 590 | return UIAbstractTableView::onKeyDown( event ); |
| 591 | |
| 592 | switch ( event.getKeyCode() ) { |
| 593 | case KEY_PAGEUP: { |
| 594 | int pageSize = eefloor( getVisibleArea().getHeight() / getRowHeight() ) - 1; |
| 595 | std::deque<std::pair<ModelIndex, Float>> deque; |
| 596 | Float curY; |
| 597 | traverseTree( |
| 598 | [&]( const int&, const ModelIndex& index, const size_t&, const Float& offsetY ) { |
| 599 | deque.push_back( { index, offsetY } ); |
| 600 | if ( (int)deque.size() > pageSize ) |
| 601 | deque.pop_front(); |
| 602 | if ( index == curIndex ) |
| 603 | return IterationDecision::Break; |
| 604 | return IterationDecision::Continue; |
| 605 | } ); |
| 606 | curY = deque.front().second - getHeaderHeight(); |
| 607 | getSelection().set( deque.front().first ); |
| 608 | scrollToPosition( |
| 609 | { { mScrollOffset.x, curY }, |
| 610 | { columnData( deque.front().first.column() ).width, getRowHeight() } } ); |
| 611 | return 1; |
| 612 | } |
| 613 | case KEY_PAGEDOWN: { |
| 614 | int pageSize = eefloor( getVisibleArea().getHeight() / getRowHeight() ) - 1; |
| 615 | int counted = 0; |
| 616 | bool foundStart = false; |
| 617 | bool resultFound = false; |
| 618 | ModelIndex foundIndex; |
| 619 | Float curY = 0; |
| 620 | Float lastOffsetY = 0; |
| 621 | ModelIndex lastIndex; |
| 622 | traverseTree( |
| 623 | [&]( const int&, const ModelIndex& index, const size_t&, const Float& offsetY ) { |
| 624 | if ( index == curIndex ) { |
| 625 | foundStart = true; |
| 626 | } else if ( foundStart ) { |
| 627 | counted++; |
| 628 | if ( counted == pageSize ) { |
| 629 | foundIndex = index; |
| 630 | curY = offsetY; |
| 631 | resultFound = true; |
| 632 | return IterationDecision::Break; |
| 633 | } |
| 634 | } |
| 635 | lastOffsetY = offsetY; |
| 636 | lastIndex = index; |
| 637 | return IterationDecision::Continue; |
| 638 | } ); |
| 639 | if ( !resultFound ) { |
| 640 | foundIndex = lastIndex; |
| 641 | curY = lastOffsetY; |
nothing calls this directly
no test coverage detected