Auto-set row when inserting a Set Active Position triplet

This commit is contained in:
G.K.MacGregor
2022-12-13 21:34:14 +00:00
parent 72a2ef9660
commit eb752835fd

View File

@@ -1036,9 +1036,11 @@ void X26DockWidget::insertTriplet(int modeExt, bool after)
{ {
QModelIndex index = m_x26View->currentIndex(); QModelIndex index = m_x26View->currentIndex();
X26Triplet newTriplet(modeExt < 0x20 ? 41 : 0, modeExt & 0x1f, 0); X26Triplet newTriplet(modeExt < 0x20 ? 41 : 0, modeExt & 0x1f, 0);
int row; int newListRow;
if (index.isValid()) { if (index.isValid()) {
newListRow = index.row()+after;
// If we're inserting a column triplet next to another column triplet, // If we're inserting a column triplet next to another column triplet,
// duplicate the column number // duplicate the column number
// Avoid the PDC and reserved mode triplets // Avoid the PDC and reserved mode triplets
@@ -1048,9 +1050,26 @@ void X26DockWidget::insertTriplet(int modeExt, bool after)
if (existingTripletModeExt >= 0x20 && existingTripletModeExt != 0x24 && existingTripletModeExt != 0x25 && existingTripletModeExt != 0x26 && existingTripletModeExt != 0x2a) if (existingTripletModeExt >= 0x20 && existingTripletModeExt != 0x24 && existingTripletModeExt != 0x25 && existingTripletModeExt != 0x26 && existingTripletModeExt != 0x2a)
newTriplet.setAddress(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole).toInt()); newTriplet.setAddress(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole).toInt());
} }
row = index.row()+after; // If we're inserting a Set Active Position or Full Row Colour triplet,
// look for a previous row setting triplet and set this one to the row after
if (modeExt == 0x04 || modeExt == 0x01) {
for (int i=newListRow-1; i>=0; i--) {
const int scanTripletModeExt = index.model()->data(index.model()->index(i, 2), Qt::EditRole).toInt();
if (scanTripletModeExt == 0x04 || scanTripletModeExt == 0x01) {
const int scanActivePositionRow = index.model()->data(index.model()->index(i, 0), Qt::EditRole).toInt()+1;
if (scanActivePositionRow < 25)
newTriplet.setAddressRow(scanActivePositionRow);
else
newTriplet.setAddressRow(24);
break;
}
}
}
} else } else
row = 0; newListRow = 0;
// For character triplets, ensure Data is not reserved // For character triplets, ensure Data is not reserved
if (modeExt == 0x21 || modeExt == 0x22 || modeExt == 0x29 || modeExt == 0x2b || modeExt >= 0x2f) if (modeExt == 0x21 || modeExt == 0x22 || modeExt == 0x29 || modeExt == 0x2b || modeExt >= 0x2f)
@@ -1061,7 +1080,7 @@ void X26DockWidget::insertTriplet(int modeExt, bool after)
newTriplet.setData(7); newTriplet.setData(7);
} }
m_x26Model->insertRows(row, 1, QModelIndex(), newTriplet); m_x26Model->insertRows(newListRow, 1, QModelIndex(), newTriplet);
} }
void X26DockWidget::insertTripletCopy() void X26DockWidget::insertTripletCopy()