| 368 | } |
| 369 | |
| 370 | void QMappingSequenceEdit::restoreHistorySnapshot(const MappingSequenceHistorySnapshot &snapshot) |
| 371 | { |
| 372 | MappingSequenceEditTableWidget *table = ui->mappingSequenceEditTable; |
| 373 | |
| 374 | m_IsRestoringHistory = true; |
| 375 | QSignalBlocker blocker(table); |
| 376 | |
| 377 | m_MappingSequenceList = snapshot.mappingSequenceList; |
| 378 | refreshMappingSequenceEditTableWidget(table, m_MappingSequenceList); |
| 379 | |
| 380 | table->clearSelection(); |
| 381 | |
| 382 | const int lastRow = table->rowCount() - 1; |
| 383 | if (lastRow >= 0 && snapshot.selectionTopRow >= 0 && snapshot.selectionBottomRow >= 0) { |
| 384 | const int top = qBound(0, snapshot.selectionTopRow, lastRow); |
| 385 | const int bottom = qBound(top, snapshot.selectionBottomRow, lastRow); |
| 386 | QTableWidgetSelectionRange range(top, 0, bottom, 0); |
| 387 | table->setRangeSelected(range, true); |
| 388 | } |
| 389 | |
| 390 | if (lastRow >= 0 && snapshot.currentRow >= 0) { |
| 391 | const int r = qBound(0, snapshot.currentRow, lastRow); |
| 392 | const int c = qBound(0, snapshot.currentColumn, table->columnCount() - 1); |
| 393 | table->setCurrentCell(r, c, QItemSelectionModel::NoUpdate); |
| 394 | } |
| 395 | else { |
| 396 | table->setCurrentCell(-1, -1); |
| 397 | } |
| 398 | |
| 399 | // Restore scroll after selection/current to avoid scrollToItem overriding it. |
| 400 | if (QScrollBar *sb = table->verticalScrollBar()) { |
| 401 | sb->setValue(snapshot.verticalScrollValue); |
| 402 | } |
| 403 | |
| 404 | m_IsRestoringHistory = false; |
| 405 | |
| 406 | updateUndoRedoButtonsEnabled(); |
| 407 | } |
| 408 | |
| 409 | void QMappingSequenceEdit::commitHistorySnapshotIfNeeded() |
| 410 | { |
nothing calls this directly
no outgoing calls
no test coverage detected