| 570 | } |
| 571 | |
| 572 | bool PlaylistTreeWidget::selectNextItem(bool wrapAround, bool callByPlayback) |
| 573 | { |
| 574 | QList<QTreeWidgetItem *> items = selectedItems(); |
| 575 | if (items.count() == 0) |
| 576 | return false; |
| 577 | |
| 578 | // Get index of current item |
| 579 | int idx = indexOfTopLevelItem(items[0]); |
| 580 | |
| 581 | // Is there a next item? |
| 582 | if (idx == topLevelItemCount() - 1) |
| 583 | { |
| 584 | if (wrapAround) |
| 585 | // The next item is 0 |
| 586 | idx = -1; |
| 587 | else |
| 588 | return false; |
| 589 | } |
| 590 | |
| 591 | if (callByPlayback) |
| 592 | { |
| 593 | // Select the next item but emit the selectionRangeChanged event with changedByPlayback=true. |
| 594 | const QScopedValueRollback<bool> back(ignoreSlotSelectionChanged, true); |
| 595 | |
| 596 | // Select the next item |
| 597 | QTreeWidgetItem *nextItem = topLevelItem(idx + 1); |
| 598 | setCurrentItem(nextItem, 0, QItemSelectionModel::ClearAndSelect); |
| 599 | assert(selectedItems().count() == 1); |
| 600 | |
| 601 | // Do what the function slotSelectionChanged usually does but this time with |
| 602 | // changedByPlayback=false. |
| 603 | auto items = getSelectedItems(); |
| 604 | emit selectionRangeChanged(items[0], items[1], true); |
| 605 | } |
| 606 | else |
| 607 | // Set next item as current and emit the selectionRangeChanged event with |
| 608 | // changedByPlayback=false. |
| 609 | setCurrentItem(topLevelItem(idx + 1)); |
| 610 | |
| 611 | // Another item was selected. The caching thread also has to be notified about this. |
| 612 | emit playlistChanged(); |
| 613 | |
| 614 | return true; |
| 615 | } |
| 616 | |
| 617 | void PlaylistTreeWidget::selectPreviousItem() |
| 618 | { |
no outgoing calls
no test coverage detected