MCPcopy Create free account
hub / github.com/Zalafina/QKeyMapper / highlightSelectExtendDown

Method highlightSelectExtendDown

QKeyMapper/qmappingsequenceedit.cpp:1638–1688  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1636}
1637
1638void QMappingSequenceEdit::highlightSelectExtendDown()
1639{
1640 MappingSequenceEditTableWidget *table = ui->mappingSequenceEditTable;
1641 if (table->rowCount() <= 0) {
1642 return;
1643 }
1644
1645 QList<QTableWidgetSelectionRange> ranges = table->selectedRanges();
1646 if (ranges.isEmpty()) {
1647 highlightSelectDown();
1648 return;
1649 }
1650
1651 QTableWidgetSelectionRange range = ranges.first();
1652 int topRow = range.topRow();
1653 int bottomRow = range.bottomRow();
1654 int currentRow = table->currentRow();
1655 if (currentRow < 0) {
1656 currentRow = bottomRow;
1657 }
1658
1659 const bool currentAtTop = (currentRow <= topRow);
1660 const bool currentAtBottom = (currentRow >= bottomRow);
1661
1662 int newTop = topRow;
1663 int newBottom = bottomRow;
1664 int newCurrent = currentRow;
1665
1666 if (currentAtBottom || (!currentAtTop && !currentAtBottom)) {
1667 if (bottomRow >= table->rowCount() - 1) {
1668 return;
1669 }
1670 newBottom = bottomRow + 1;
1671 newCurrent = newBottom;
1672 }
1673 else if (currentAtTop) {
1674 if (topRow >= bottomRow) {
1675 return;
1676 }
1677 newTop = topRow + 1;
1678 newCurrent = newTop;
1679 }
1680
1681 table->clearSelection();
1682 QTableWidgetSelectionRange sel(newTop, 0, newBottom, MAPPINGSEQUENCEEDIT_TABLE_COLUMN_COUNT - 1);
1683 table->setRangeSelected(sel, true);
1684 table->setCurrentCell(newCurrent, 0, QItemSelectionModel::NoUpdate);
1685 if (QTableWidgetItem *item = table->item(newCurrent, 0)) {
1686 table->scrollToItem(item, QAbstractItemView::EnsureVisible);
1687 }
1688}
1689
1690void QMappingSequenceEdit::highlightSelectFirst()
1691{

Callers

nothing calls this directly

Calls 1

isEmptyMethod · 0.80

Tested by

no test coverage detected