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

Method mappingSequenceTableCellChanged

QKeyMapper/qmappingsequenceedit.cpp:1264–1323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1262}
1263
1264void QMappingSequenceEdit::mappingSequenceTableCellChanged(int row, int column)
1265{
1266 if (column != MAPPINGSEQUENCEEDIT_MAPPINGKEY_COLUMN) {
1267 return;
1268 }
1269
1270 MappingSequenceEditTableWidget *table = ui->mappingSequenceEditTable;
1271
1272 if (row < 0 || row >= table->rowCount()) {
1273 return;
1274 }
1275
1276 QTableWidgetItem *item = table->item(row, column);
1277 if (!item) {
1278 return;
1279 }
1280
1281 QString newText = item->text();
1282 QString trimmed = newText;
1283
1284 QString popupMessage;
1285 if (!validateOrAllowEmptyMappingKey(&trimmed, &popupMessage)) {
1286 // Roll back UI from the source-of-truth list.
1287 const QString oldText = (row >= 0 && row < m_MappingSequenceList.size()) ? m_MappingSequenceList.at(row) : QString();
1288 QSignalBlocker blocker(table);
1289 item->setText(oldText);
1290 // item->setToolTip(oldText);
1291 emitValidationFailurePopup(popupMessage);
1292 return;
1293 }
1294
1295 // Commit into the source-of-truth list (only after validation).
1296 const QString oldCommitted = (row >= 0 && row < m_MappingSequenceList.size()) ? m_MappingSequenceList.at(row) : QString();
1297 const bool listWillChange = (row >= m_MappingSequenceList.size()) || (oldCommitted != trimmed);
1298
1299 if (listWillChange) {
1300 ensureBaseSnapshotBeforeListChange();
1301 }
1302
1303 if (row >= m_MappingSequenceList.size()) {
1304 QKeyMapperQtCompat::resizeQList(m_MappingSequenceList, row + 1);
1305 }
1306 m_MappingSequenceList[row] = trimmed;
1307
1308 // Keep tooltip in sync for better UX.
1309 // if (item->toolTip() != trimmed) {
1310 // item->setToolTip(trimmed);
1311 // }
1312
1313 // Normalize UI text (e.g., remove spaces) without re-triggering cellChanged.
1314 if (newText != trimmed) {
1315 QSignalBlocker blocker(table);
1316 item->setText(trimmed);
1317 // item->setToolTip(trimmed);
1318 }
1319
1320 if (listWillChange) {
1321 commitHistorySnapshotIfNeeded();

Callers

nothing calls this directly

Calls 2

resizeQListFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected