| 1584 | } |
| 1585 | |
| 1586 | void QMappingSequenceEdit::highlightSelectExtendUp() |
| 1587 | { |
| 1588 | MappingSequenceEditTableWidget *table = ui->mappingSequenceEditTable; |
| 1589 | if (table->rowCount() <= 0) { |
| 1590 | return; |
| 1591 | } |
| 1592 | |
| 1593 | QList<QTableWidgetSelectionRange> ranges = table->selectedRanges(); |
| 1594 | if (ranges.isEmpty()) { |
| 1595 | highlightSelectUp(); |
| 1596 | return; |
| 1597 | } |
| 1598 | |
| 1599 | QTableWidgetSelectionRange range = ranges.first(); |
| 1600 | int topRow = range.topRow(); |
| 1601 | int bottomRow = range.bottomRow(); |
| 1602 | int currentRow = table->currentRow(); |
| 1603 | if (currentRow < 0) { |
| 1604 | currentRow = topRow; |
| 1605 | } |
| 1606 | |
| 1607 | const bool currentAtTop = (currentRow <= topRow); |
| 1608 | const bool currentAtBottom = (currentRow >= bottomRow); |
| 1609 | |
| 1610 | int newTop = topRow; |
| 1611 | int newBottom = bottomRow; |
| 1612 | int newCurrent = currentRow; |
| 1613 | |
| 1614 | if (currentAtTop || (!currentAtTop && !currentAtBottom)) { |
| 1615 | if (topRow <= 0) { |
| 1616 | return; |
| 1617 | } |
| 1618 | newTop = topRow - 1; |
| 1619 | newCurrent = newTop; |
| 1620 | } |
| 1621 | else if (currentAtBottom) { |
| 1622 | if (topRow >= bottomRow) { |
| 1623 | return; |
| 1624 | } |
| 1625 | newBottom = bottomRow - 1; |
| 1626 | newCurrent = newBottom; |
| 1627 | } |
| 1628 | |
| 1629 | table->clearSelection(); |
| 1630 | QTableWidgetSelectionRange sel(newTop, 0, newBottom, MAPPINGSEQUENCEEDIT_TABLE_COLUMN_COUNT - 1); |
| 1631 | table->setRangeSelected(sel, true); |
| 1632 | table->setCurrentCell(newCurrent, 0, QItemSelectionModel::NoUpdate); |
| 1633 | if (QTableWidgetItem *item = table->item(newCurrent, 0)) { |
| 1634 | table->scrollToItem(item, QAbstractItemView::EnsureVisible); |
| 1635 | } |
| 1636 | } |
| 1637 | |
| 1638 | void QMappingSequenceEdit::highlightSelectExtendDown() |
| 1639 | { |