Tidy the model using const

This commit is contained in:
G.K.MacGregor
2021-06-25 17:48:52 +01:00
parent a54385b8f5
commit cd531bd0a5

View File

@@ -49,17 +49,17 @@ int X26Model::columnCount(const QModelIndex & /*parent*/) const
QVariant X26Model::data(const QModelIndex &index, int role) const QVariant X26Model::data(const QModelIndex &index, int role) const
{ {
int mode = m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).mode(); const X26Triplet triplet = m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row());
// Qt::UserRole will always return the raw values // Qt::UserRole will always return the raw values
if (role == Qt::UserRole) if (role == Qt::UserRole)
switch (index.column()) { switch (index.column()) {
case 0: case 0:
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address(); return triplet.address();
case 1: case 1:
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).mode(); return triplet.mode();
case 2: case 2:
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data(); return triplet.data();
default: default:
return QVariant(); return QVariant();
} }
@@ -69,49 +69,44 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
case 0: case 0:
// Show row number only if address part of triplet actually represents a row // Show row number only if address part of triplet actually represents a row
// i.e. Full row colour, Set Active Position and Origin Modifier // i.e. Full row colour, Set Active Position and Origin Modifier
if (!m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).isRowTriplet())
return QVariant();
// For Origin Modifier address of 40 refers to same row, so show it as 0 // For Origin Modifier address of 40 refers to same row, so show it as 0
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).mode() == 0x10) { if (triplet.modeExt() == 0x10) {
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() == 40) if (triplet.address() == 40)
return 0; return 0;
else else
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).addressRow(); return triplet.addressRow();
} }
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).mode() == 0x01 || m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).mode() == 0x04) if (triplet.modeExt() == 0x01 || triplet.modeExt() == 0x04)
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).addressRow(); return triplet.addressRow();
else else
return QVariant(); return QVariant();
case 1: case 1:
if (!m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).isRowTriplet()) if (!triplet.isRowTriplet())
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).addressColumn(); return triplet.addressColumn();
// For Set Active Position and Origin Modifier, data is the column // For Set Active Position and Origin Modifier, data is the column
else if (mode == 0x04 || mode == 0x10) else if (triplet.modeExt() == 0x04 || triplet.modeExt() == 0x10)
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data(); return triplet.data();
else else
return QVariant(); return QVariant();
} }
if (!m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).isRowTriplet())
mode |= 0x20;
QString result; QString result;
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
if (index.column() == 2) if (index.column() == 2)
return (modeTripletName[mode]); return (modeTripletName[triplet.modeExt()]);
// Column 3 - describe effects of data/address triplet parameters in plain English // Column 3 - describe effects of data/address triplet parameters in plain English
switch (mode) { switch (triplet.modeExt()) {
case 0x01: // Full row colour case 0x01: // Full row colour
case 0x07: // Address row 0 case 0x07: // Address row 0
if ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x60) == 0x60) if ((triplet.data() & 0x60) == 0x60)
result = ", down to bottom"; result = ", down to bottom";
else if ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x60) == 0x00) else if ((triplet.data() & 0x60) == 0x00)
result = ", this row only"; result = ", this row only";
// fall-through // fall-through
case 0x00: // Full screen colour case 0x00: // Full screen colour
if (!(result.isEmpty()) || (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x60) == 0x00) { if (!(result.isEmpty()) || (triplet.data() & 0x60) == 0x00) {
result.prepend(QString("CLUT %1:%2").arg((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x18) >> 3).arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x07)); result.prepend(QString("CLUT %1:%2").arg((triplet.data() & 0x18) >> 3).arg(triplet.data() & 0x07));
return result; return result;
} }
break; break;
@@ -120,9 +115,9 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
// For Set Active Position and Origin Modifier, data is the column, so return blank // For Set Active Position and Origin Modifier, data is the column, so return blank
return QVariant(); return QVariant();
case 0x11 ... 0x13: // Invoke object case 0x11 ... 0x13: // Invoke object
switch (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x18) { switch (triplet.address() & 0x18) {
case 0x08: case 0x08:
return QString("Local: d%1 t%2").arg((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >> 4) | ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x01) << 3)).arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x0f); return QString("Local: d%1 t%2").arg((triplet.data() >> 4) | ((triplet.address() & 0x01) << 3)).arg(triplet.data() & 0x0f);
case 0x10: case 0x10:
result = "POP"; result = "POP";
break; break;
@@ -131,15 +126,15 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
break; break;
// case 0x00: shouldn't happen since that would make a column triplet, not a row triplet // case 0x00: shouldn't happen since that would make a column triplet, not a row triplet
} }
result.append(QString(": subpage %1 pkt %2 trplt %3 bits ").arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x0f).arg((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x03) + 1).arg(((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x60) >> 5) * 3 + (mode & 0x03))); result.append(QString(": subpage %1 pkt %2 trplt %3 bits ").arg(triplet.data() & 0x0f).arg((triplet.address() & 0x03) + 1).arg(((triplet.data() & 0x60) >> 5) * 3 + (triplet.modeExt() & 0x03)));
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x10) if (triplet.data() & 0x10)
result.append("10-18"); result.append("10-18");
else else
result.append("1-9"); result.append("1-9");
return result; return result;
case 0x15 ... 0x17: // Define object case 0x15 ... 0x17: // Define object
result = (QString("Local: d%1 t%2, ").arg((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >> 4) | ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 1) << 3)).arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x0f)); result = (QString("Local: d%1 t%2, ").arg((triplet.data() >> 4) | ((triplet.address() & 1) << 3)).arg(triplet.data() & 0x0f));
switch (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x18) { switch (triplet.address() & 0x18) {
case 0x08: case 0x08:
result.append("L2.5 only"); result.append("L2.5 only");
break; break;
@@ -153,9 +148,9 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
} }
return result; return result;
case 0x18: // DRCS mode case 0x18: // DRCS mode
result = (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x40) == 0x40 ? "Normal" : "Global"; result = (triplet.data() & 0x40) == 0x40 ? "Normal" : "Global";
result.append(QString(": subpage %1, ").arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x0f)); result.append(QString(": subpage %1, ").arg(triplet.data() & 0x0f));
switch (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x30) { switch (triplet.data() & 0x30) {
case 0x10: case 0x10:
result.append("L2.5 only"); result.append("L2.5 only");
break; break;
@@ -171,7 +166,7 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
} }
return result; return result;
case 0x1f: // Termination case 0x1f: // Termination
switch (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x07) { switch (triplet.data() & 0x07) {
case 0x00: case 0x00:
return "Intermed (G)POP subpage. End of object, more follows"; return "Intermed (G)POP subpage. End of object, more follows";
break; break;
@@ -199,23 +194,23 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
} }
break; break;
case 0x08 ... 0x0d: // PDC case 0x08 ... 0x0d: // PDC
return QString("0x%1").arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data(), 2, 16, QChar('0')); return QString("0x%1").arg(triplet.data(), 2, 16, QChar('0'));
case 0x20: // Foreground colour case 0x20: // Foreground colour
case 0x23: // Background colour case 0x23: // Background colour
if (!(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x60)) if (!(triplet.data() & 0x60))
return QString("CLUT %1:%2").arg((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x18) >> 3).arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x07); return QString("CLUT %1:%2").arg((triplet.data() & 0x18) >> 3).arg(triplet.data() & 0x07);
break; break;
case 0x21: // G1 mosaic character case 0x21: // G1 mosaic character
case 0x22: // G3 mosaic character at level 1.5 case 0x22: // G3 mosaic character at level 1.5
case 0x29: // G0 character case 0x29: // G0 character
case 0x2b: // G3 mosaic character at level >=2.5 case 0x2b: // G3 mosaic character at level >=2.5
case 0x2f ... 0x3f: // G2 character or G0 diacritical mark case 0x2f ... 0x3f: // G2 character or G0 diacritical mark
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >= 0x20) if (triplet.data() >= 0x20)
return QString("0x%1").arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data(), 2, 16); return QString("0x%1").arg(triplet.data(), 2, 16);
break; break;
case 0x27: // Flash functions case 0x27: // Flash functions
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() < 0x18) { if (triplet.data() < 0x18) {
switch (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x03) { switch (triplet.data() & 0x03) {
case 0x00: case 0x00:
result = "Steady"; result = "Steady";
break; break;
@@ -229,7 +224,7 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
result = "Adj CLUT"; result = "Adj CLUT";
break; break;
} }
switch (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x1c) { switch (triplet.data() & 0x1c) {
case 0x00: case 0x00:
result.append(", 1Hz"); result.append(", 1Hz");
break; break;
@@ -254,20 +249,20 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
break; break;
//TODO case 0x28: // G0 and G2 designation //TODO case 0x28: // G0 and G2 designation
case 0x2c: // Display attributes case 0x2c: // Display attributes
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x02) if (triplet.data() & 0x02)
result.append("Boxing "); result.append("Boxing ");
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x04) if (triplet.data() & 0x04)
result.append("Conceal "); result.append("Conceal ");
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x10) if (triplet.data() & 0x10)
result.append("Invert "); result.append("Invert ");
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x20) if (triplet.data() & 0x20)
result.append("Underline "); result.append("Underline ");
if (result.isEmpty()) if (result.isEmpty())
result = "None"; result = "None";
else else
// Chop off the last space // Chop off the last space
result.chop(1); result.chop(1);
switch (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x41) { switch (triplet.data() & 0x41) {
case 0x00: case 0x00:
result.append(", normal size"); result.append(", normal size");
break; break;
@@ -283,188 +278,185 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
} }
return result; return result;
case 0x2d: // DRCS character case 0x2d: // DRCS character
result = (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x40) == 0x40 ? "Normal" : "Global"; result = (triplet.data() & 0x40) == 0x40 ? "Normal" : "Global";
result.append(QString(": %1").arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x3f)); result.append(QString(": %1").arg(triplet.data() & 0x3f));
return result; return result;
case 0x2e: // Font style case 0x2e: // Font style
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x01) if (triplet.data() & 0x01)
result.append("Proportional "); result.append("Proportional ");
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x02) if (triplet.data() & 0x02)
result.append("Bold "); result.append("Bold ");
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x04) if (triplet.data() & 0x04)
result.append("Italic "); result.append("Italic ");
if (result.isEmpty()) if (result.isEmpty())
result = "None"; result = "None";
else else
// Chop off the last space // Chop off the last space
result.chop(1); result.chop(1);
result.append(QString(", %1 row(s)").arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >> 4)); result.append(QString(", %1 row(s)").arg(triplet.data() >> 4));
return result; return result;
case 0x28: // Modified G0 and G2 character set case 0x28: // Modified G0 and G2 character set
case 0x26: // PDC case 0x26: // PDC
return QString("0x%1").arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data(), 2, 16, QChar('0')); return QString("0x%1").arg(triplet.data(), 2, 16, QChar('0'));
default: // Reserved default: // Reserved
return QString("Reserved 0x%1").arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data(), 2, 16, QChar('0')); return QString("Reserved 0x%1").arg(triplet.data(), 2, 16, QChar('0'));
} }
// Reserved mode or data // Reserved mode or data
return QString("Reserved 0x%1").arg(m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data(), 2, 16, QChar('0')); return QString("Reserved 0x%1").arg(triplet.data(), 2, 16, QChar('0'));
} }
if (role == Qt::DecorationRole && index.column() == 3) if (role == Qt::DecorationRole && index.column() == 3)
switch (mode) { switch (triplet.modeExt()) {
case 0x21: // G1 mosaic character case 0x21: // G1 mosaic character
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x20) if (triplet.data() & 0x20)
return m_fontBitmap.rawBitmap()->copy((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data()-32)*12, 24*10, 12, 10); return m_fontBitmap.rawBitmap()->copy((triplet.data()-32)*12, 24*10, 12, 10);
break; break;
case 0x22: // G3 mosaic character at level 1.5 case 0x22: // G3 mosaic character at level 1.5
case 0x2b: // G3 mosaic character at level >=2.5 case 0x2b: // G3 mosaic character at level >=2.5
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >= 0x20) if (triplet.data() >= 0x20)
return m_fontBitmap.rawBitmap()->copy((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data()-32)*12, 26*10, 12, 10); return m_fontBitmap.rawBitmap()->copy((triplet.data()-32)*12, 26*10, 12, 10);
break; break;
case 0x2f: // G2 character case 0x2f: // G2 character
// TODO non-Latin G2 character sets // TODO non-Latin G2 character sets
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >= 0x20) if (triplet.data() >= 0x20)
return m_fontBitmap.rawBitmap()->copy((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data()-32)*12, 7*10, 12, 10); return m_fontBitmap.rawBitmap()->copy((triplet.data()-32)*12, 7*10, 12, 10);
break; break;
case 0x29: // G0 character case 0x29: // G0 character
case 0x30 ... 0x3f: // G0 diacritical mark case 0x30 ... 0x3f: // G0 diacritical mark
// TODO non-Latin G0 character sets // TODO non-Latin G0 character sets
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >= 0x20) if (triplet.data() >= 0x20)
return m_fontBitmap.rawBitmap()->copy((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data()-32)*12, 0, 12, 10); return m_fontBitmap.rawBitmap()->copy((triplet.data()-32)*12, 0, 12, 10);
break; break;
}; };
if (role == Qt::EditRole && index.column() == 2) { if (role == Qt::EditRole && index.column() == 2)
if (!m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).isRowTriplet()) return triplet.modeExt();
mode |= 0x20;
return mode;
}
switch (role) { switch (role) {
case Qt::UserRole+1: case Qt::UserRole+1:
switch (mode) { switch (triplet.modeExt()) {
case 0x00: // Full screen colour case 0x00: // Full screen colour
case 0x01: // Full row colour case 0x01: // Full row colour
case 0x07: // Address row 0 case 0x07: // Address row 0
case 0x20: // Foreground colour case 0x20: // Foreground colour
case 0x23: // Background colour case 0x23: // Background colour
// Colour index // Colour index
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x1f; return triplet.data() & 0x1f;
case 0x11 ... 0x13: // Invoke object case 0x11 ... 0x13: // Invoke object
// Object source: Local, POP or GPOP // Object source: Local, POP or GPOP
return ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x18) >> 3) - 1; return ((triplet.address() & 0x18) >> 3) - 1;
break; break;
case 0x15 ... 0x17: // Define object case 0x15 ... 0x17: // Define object
// Required at which levels // Required at which levels
return ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x18) >> 3) - 1; return ((triplet.address() & 0x18) >> 3) - 1;
case 0x18: // DRCS mode case 0x18: // DRCS mode
// Required at which levels // Required at which levels
return ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x30) >> 4) - 1; return ((triplet.data() & 0x30) >> 4) - 1;
case 0x1f: // Termination case 0x1f: // Termination
// Intermed POP subpage|Last POP subpage|Local Object|Local enhance // Intermed POP subpage|Last POP subpage|Local Object|Local enhance
return ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x06) >> 1); return ((triplet.data() & 0x06) >> 1);
case 0x27: // Flash functions case 0x27: // Flash functions
// Flash mode // Flash mode
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x03; return triplet.data() & 0x03;
case 0x2c: // Display attributes case 0x2c: // Display attributes
// Text size // Text size
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x01) | ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x40) >> 5); return (triplet.data() & 0x01) | ((triplet.data() & 0x40) >> 5);
case 0x2d: // DRCS character case 0x2d: // DRCS character
// Normal or Global // Normal or Global
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x40) == 0x40; return (triplet.data() & 0x40) == 0x40;
case 0x2e: // Font style case 0x2e: // Font style
// Proportional // Proportional
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x01) == 0x01; return (triplet.data() & 0x01) == 0x01;
default: default:
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data(); return triplet.data();
} }
break; break;
case Qt::UserRole+2: case Qt::UserRole+2:
switch (mode) { switch (triplet.modeExt()) {
case 0x01: // Full row colour case 0x01: // Full row colour
case 0x07: // Address row 0 case 0x07: // Address row 0
// "this row only" or "down to bottom" // "this row only" or "down to bottom"
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x60) == 0x60; return (triplet.data() & 0x60) == 0x60;
case 0x11 ... 0x13: // Invoke object case 0x11 ... 0x13: // Invoke object
if ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x08) == 0x08) if ((triplet.address() & 0x08) == 0x08)
// Local object: Designation code // Local object: Designation code
return ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x01) << 3) | ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x70) >> 4); return ((triplet.address() & 0x01) << 3) | ((triplet.data() & 0x70) >> 4);
else else
// (G)POP object: Subpage // (G)POP object: Subpage
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x0f; return triplet.data() & 0x0f;
break; break;
case 0x15 ... 0x17: // Define object case 0x15 ... 0x17: // Define object
// Local object: Designation code // Local object: Designation code
return ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x01) << 3) | ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x70) >> 4); return ((triplet.address() & 0x01) << 3) | ((triplet.data() & 0x70) >> 4);
case 0x1f: // Termination case 0x1f: // Termination
// More follows/Last // More follows/Last
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x01) == 0x01; return (triplet.data() & 0x01) == 0x01;
case 0x27: // Flash functions case 0x27: // Flash functions
// Flash rate and phase // Flash rate and phase
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >> 2; return triplet.data() >> 2;
case 0x2c: // Display attributes case 0x2c: // Display attributes
// Boxing/window // Boxing/window
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x02) == 0x02; return (triplet.data() & 0x02) == 0x02;
case 0x2d: // DRCS character case 0x2d: // DRCS character
// Character number // Character number
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x3f; return triplet.data() & 0x3f;
case 0x2e: // Font style case 0x2e: // Font style
// Bold // Bold
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x02) == 0x02; return (triplet.data() & 0x02) == 0x02;
} }
break; break;
case Qt::UserRole+3: case Qt::UserRole+3:
switch (mode) { switch (triplet.modeExt()) {
case 0x11 ... 0x13: // Invoke object case 0x11 ... 0x13: // Invoke object
if ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x08) == 0x08) if ((triplet.address() & 0x08) == 0x08)
// Local object: Triplet number // Local object: Triplet number
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x0f; return triplet.data() & 0x0f;
else else
// (G)POP object: Pointer location // (G)POP object: Pointer location
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x03) + 1; return (triplet.address() & 0x03) + 1;
break; break;
case 0x15 ... 0x17: // Define object case 0x15 ... 0x17: // Define object
// Local object: Triplet number // Local object: Triplet number
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x0f; return triplet.data() & 0x0f;
case 0x18: // DRCS mode case 0x18: // DRCS mode
// Normal or Global // Normal or Global
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x40) == 0x40; return (triplet.data() & 0x40) == 0x40;
case 0x2c: // Display attributes case 0x2c: // Display attributes
// Conceal // Conceal
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x04) == 0x04; return (triplet.data() & 0x04) == 0x04;
case 0x2e: // Font style case 0x2e: // Font style
// Italics // Italics
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x04) == 0x04; return (triplet.data() & 0x04) == 0x04;
} }
break; break;
case Qt::UserRole+4: case Qt::UserRole+4:
switch (mode) { switch (triplet.modeExt()) {
case 0x11 ... 0x13: // Invoke object case 0x11 ... 0x13: // Invoke object
// (G)POP object: Triplet number // (G)POP object: Triplet number
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >> 5; return triplet.data() >> 5;
case 0x18: // DRCS mode case 0x18: // DRCS mode
// Subpage // Subpage
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x0f; return triplet.data() & 0x0f;
case 0x2c: // Display attributes case 0x2c: // Display attributes
// Invert // Invert
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x10) == 0x10; return (triplet.data() & 0x10) == 0x10;
case 0x2e: // Font style case 0x2e: // Font style
// Number of rows // Number of rows
return m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >> 4; return triplet.data() >> 4;
} }
break; break;
case Qt::UserRole+5: case Qt::UserRole+5:
switch (mode) { switch (triplet.modeExt()) {
case 0x11 ... 0x13: // Invoke object case 0x11 ... 0x13: // Invoke object
// (G)POP object: Pointer position // (G)POP object: Pointer position
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x10) >> 4; return (triplet.data() & 0x10) >> 4;
case 0x2c: // Display attributes case 0x2c: // Display attributes
// Underline/Separated // Underline/Separated
return (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x20) == 0x20; return (triplet.data() & 0x20) == 0x20;
} }
break; break;
} }
@@ -477,31 +469,35 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
if (!index.isValid()) if (!index.isValid())
return false; return false;
if (!value.canConvert<int>())
return false;
const int intValue = value.toInt();
if (intValue < 0)
return false;
// Raw address, mode and data values // Raw address, mode and data values
if (role == Qt::UserRole && value.canConvert<int>() && index.column() <= 2) { if (role == Qt::UserRole && index.column() <= 2) {
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), index.column(), 0x00, value.toInt(), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), index.column(), 0x00, intValue, role));
return true; return true;
} }
int mode = m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).modeExt(); const X26Triplet triplet = m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row());
// Cooked row, column and triplet mode // Cooked row, column and triplet mode
if (role == Qt::EditRole && value.canConvert<int>()) { if (role == Qt::EditRole) {
int intValue = value.toInt();
if (intValue < 0)
return false;
switch (index.column()) { switch (index.column()) {
case 0: // Cooked row case 0: // Cooked row
// Maximum row is 24 // Maximum row is 24
if (intValue > 24) if (intValue > 24)
return false; return false;
// Set Active Position and Full Row Colour can't select row 0 // Set Active Position and Full Row Colour can't select row 0
if (((mode == 0x04) || (mode == 0x01)) && intValue == 0) if (((triplet.modeExt() == 0x04) || (triplet.modeExt() == 0x01)) && intValue == 0)
return false; return false;
// For Origin Modifier address of 40 refers to same row // For Origin Modifier address of 40 refers to same row
if (mode == 0x10 && intValue == 24) { if (triplet.modeExt() == 0x10 && intValue == 24) {
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, 40, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, 40, role));
return true; return true;
} }
@@ -511,22 +507,22 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
case 1: // Cooked column case 1: // Cooked column
// Origin modifier allows columns up to 71 // Origin modifier allows columns up to 71
if (intValue > (mode == 0x10 ? 71 : 39)) if (intValue > (triplet.modeExt() == 0x10 ? 71 : 39))
return false; return false;
// For Set Active Position and Origin Modifier, data is the column // For Set Active Position and Origin Modifier, data is the column
if (mode == 0x04 || mode == 0x10) if (triplet.modeExt() == 0x04 || triplet.modeExt() == 0x10)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, intValue, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, intValue, role));
else else
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, intValue, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, intValue, role));
return true; return true;
case 2: // Cooked triplet mode case 2: // Cooked triplet mode
if (intValue < 0x20 && !m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).isRowTriplet()) { if (intValue < 0x20 && !triplet.isRowTriplet()) {
// Changing mode from column triplet to row triplet // Changing mode from column triplet to row triplet
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, 41, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, 41, role));
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0, role));
} }
if (intValue >= 0x20 && m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).isRowTriplet()) { if (intValue >= 0x20 && triplet.isRowTriplet()) {
// Changing mode from row triplet to column triplet // Changing mode from row triplet to column triplet
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, 0, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, 0, role));
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0, role));
@@ -542,27 +538,27 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
case 0x20: // Foreground colour case 0x20: // Foreground colour
case 0x23: // Background colour case 0x23: // Background colour
// Both S1 and S0 reserved bits must be clear // Both S1 and S0 reserved bits must be clear
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x60) if (triplet.data() & 0x60)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1f, 0x00, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1f, 0x00, role));
break; break;
case 0x07: // Address row 0 case 0x07: // Address row 0
// Address locked to 63 // Address locked to 63
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() != 63) if (triplet.address() != 63)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, 63, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, 63, role));
// fall-through // fall-through
case 0x01: // Full row colour case 0x01: // Full row colour
// S1 and S0 bits need to be the same // S1 and S0 bits need to be the same
if ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x60) != 0x00 && (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x60) != 0x60) if ((triplet.data() & 0x60) != 0x00 && (triplet.data() & 0x60) != 0x60)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1f, 0x00, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1f, 0x00, role));
break; break;
case 0x04: // Set Active Position case 0x04: // Set Active Position
// Data range 0-39 // Data range 0-39
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >= 40) if (triplet.data() >= 40)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0, role));
break; break;
case 0x10: // Origin modifier case 0x10: // Origin modifier
// Data range 0-71 // Data range 0-71
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >= 72) if (triplet.data() >= 72)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0, role));
break; break;
case 0x11: // Invoke Active Object case 0x11: // Invoke Active Object
@@ -572,24 +568,24 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
case 0x16: // Define Adaptive Object case 0x16: // Define Adaptive Object
case 0x17: // Define Passive Object case 0x17: // Define Passive Object
// Bit 3 of Address is reserved // Bit 3 of Address is reserved
if ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x04) == 0x04) if ((triplet.address() & 0x04) == 0x04)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x7b, 0x00, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x7b, 0x00, role));
// BUG we're only dealing with Local Object Definitions at the moment! // BUG we're only dealing with Local Object Definitions at the moment!
// If source is Local, triplet number must be in range 0-12 // If source is Local, triplet number must be in range 0-12
if (((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x18) == 0x08) && ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x0f) >= 12)) if (((triplet.address() & 0x18) == 0x08) && ((triplet.data() & 0x0f) >= 12))
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x70, 0x00, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x70, 0x00, role));
break; break;
case 0x18: // DRCS mode case 0x18: // DRCS mode
// At least one of the L1 and L0 bits must be set // At least one of the L1 and L0 bits must be set
if ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x30) == 0x00) if ((triplet.data() & 0x30) == 0x00)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x4f, 0x30, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x4f, 0x30, role));
break; break;
case 0x1f: // Termination marker case 0x1f: // Termination marker
// Address locked to 63 // Address locked to 63
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() != 63) if (triplet.address() != 63)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, 63, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x00, 63, role));
// Clear reserved bits D6-D3 // Clear reserved bits D6-D3
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x78) if (triplet.data() & 0x78)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x07, 0x00, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x07, 0x00, role));
break; break;
case 0x21: // G1 mosaic character case 0x21: // G1 mosaic character
@@ -598,23 +594,23 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
case 0x2b: // G3 mosaic character at level >=2.5 case 0x2b: // G3 mosaic character at level >=2.5
case 0x2f ... 0x3f: // G2 character or G0 diacritical mark case 0x2f ... 0x3f: // G2 character or G0 diacritical mark
// Data range 0x20-0x7f // Data range 0x20-0x7f
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() < 0x20) if (triplet.data() < 0x20)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0x20, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0x20, role));
break; break;
case 0x27: // Additional flash functions case 0x27: // Additional flash functions
// D6 and D5 must be clear, D4 and D3 set is reserved phase // D6 and D5 must be clear, D4 and D3 set is reserved phase
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() >= 0x18) if (triplet.data() >= 0x18)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, 0, role));
break; break;
case 0x28: // Display attributes case 0x28: // Display attributes
case 0x2e: // Font style case 0x2e: // Font style
// Clear reserved bit D3 // Clear reserved bit D3
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x08) if (triplet.data() & 0x08)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x77, 0x00, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x77, 0x00, role));
break; break;
case 0x2d: // DRCS character case 0x2d: // DRCS character
// D5-D0 range 0-47 // D5-D0 range 0-47
if ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).data() & 0x3f) >= 48) if ((triplet.data() & 0x3f) >= 48)
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x40, 0x77, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x40, 0x77, role));
break; break;
}; };
@@ -623,169 +619,162 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
return false; return false;
} }
if (role <= Qt::UserRole || !value.canConvert<int>())
return false;
int intValue = value.toInt();
if (intValue < 0)
return false;
// Triplet data // Triplet data
switch (role) { switch (role) {
case Qt::UserRole+1: case Qt::UserRole+1:
switch (mode) { switch (triplet.modeExt()) {
case 0x01: // Full row colour case 0x01: // Full row colour
case 0x07: // Address row 0 case 0x07: // Address row 0
// Colour index // Colour index
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x60, value.toInt(), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x60, intValue, role));
break; break;
case 0x11 ... 0x13: // Invoke object case 0x11 ... 0x13: // Invoke object
// Object source: Local, POP or GPOP // Object source: Local, POP or GPOP
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x27, (value.toInt()+1) << 3, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x27, (intValue+1) << 3, role));
break; break;
case 0x15 ... 0x17: // Define object case 0x15 ... 0x17: // Define object
// Required at which levels // Required at which levels
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x27, (value.toInt()+1) << 3, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x27, (intValue+1) << 3, role));
break; break;
case 0x18: // DRCS Mode case 0x18: // DRCS Mode
// Required at which levels // Required at which levels
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x4f, (value.toInt()+1) << 4, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x4f, (intValue+1) << 4, role));
break; break;
case 0x1f: // Termination case 0x1f: // Termination
// Intermed POP subpage|Last POP subpage|Local Object|Local enhance // Intermed POP subpage|Last POP subpage|Local Object|Local enhance
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x01, value.toInt() << 1, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x01, intValue << 1, role));
break; break;
case 0x27: // Flash functions case 0x27: // Flash functions
// Flash mode // Flash mode
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1c, value.toInt(), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1c, intValue, role));
break; break;
case 0x2c: // Display attributes case 0x2c: // Display attributes
// Text size // Text size
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x36, ((value.toInt() & 0x02) << 5) | (value.toInt() & 0x01), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x36, ((intValue & 0x02) << 5) | (intValue & 0x01), role));
break; break;
case 0x2d: // DRCS character case 0x2d: // DRCS character
// Normal or Global // Normal or Global
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x3f, value.toInt() << 6, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x3f, intValue << 6, role));
break; break;
case 0x2e: // Font style case 0x2e: // Font style
// Proportional // Proportional
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7e, value.toInt(), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7e, intValue, role));
break; break;
default: // Others set the complete data value default: // Others set the complete data value
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, value.toInt(), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, intValue, role));
} }
break; break;
case Qt::UserRole+2: case Qt::UserRole+2:
switch (mode) { switch (triplet.modeExt()) {
case 0x00: // Full screen colour case 0x00: // Full screen colour
case 0x01: // Full row colour case 0x01: // Full row colour
case 0x07: // Address row 0 case 0x07: // Address row 0
// "this row only" or "down to bottom" // "this row only" or "down to bottom"
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1f, value.toInt() * 0x60, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1f, intValue * 0x60, role));
break; break;
case 0x11 ... 0x13: // Invoke object case 0x11 ... 0x13: // Invoke object
if ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x08) == 0x08) { if ((triplet.address() & 0x08) == 0x08) {
// Local object: Designation code // Local object: Designation code
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x0f, (value.toInt() & 0x07) << 4, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x0f, (intValue & 0x07) << 4, role));
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x38, value.toInt() >> 3, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x38, intValue >> 3, role));
} else } else
// (G)POP object: Subpage // (G)POP object: Subpage
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x30, value.toInt(), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x30, intValue, role));
break; break;
case 0x15 ... 0x17: // Define object case 0x15 ... 0x17: // Define object
// Local object: Designation code // Local object: Designation code
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x0f, (value.toInt() & 0x07) << 4, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x0f, (intValue & 0x07) << 4, role));
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x38, value.toInt() >> 3, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x38, intValue >> 3, role));
break; break;
case 0x1f: // Termination case 0x1f: // Termination
// More follows/Last // More follows/Last
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x06, value.toInt(), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x06, intValue, role));
break; break;
case 0x27: // Flash functions case 0x27: // Flash functions
// Flash rate and phase // Flash rate and phase
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x03, value.toInt() << 2, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x03, intValue << 2, role));
break; break;
case 0x2c: // Display attributes case 0x2c: // Display attributes
// Boxing/window // Boxing/window
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7d, value.toInt() << 1, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7d, intValue << 1, role));
break; break;
case 0x2d: // DRCS character case 0x2d: // DRCS character
// Character number // Character number
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x40, value.toInt(), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x40, intValue, role));
break; break;
case 0x2e: // Font style case 0x2e: // Font style
// Bold // Bold
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7d, value.toInt() << 1, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7d, intValue << 1, role));
break; break;
} }
break; break;
case Qt::UserRole+3: case Qt::UserRole+3:
switch (mode) { switch (triplet.modeExt()) {
case 0x11 ... 0x13: // Invoke object case 0x11 ... 0x13: // Invoke object
if ((m_parentMainWidget->document()->currentSubPage()->enhancements()->at(index.row()).address() & 0x08) == 0x08) if ((triplet.address() & 0x08) == 0x08)
// Local object: triplet number // Local object: triplet number
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x70, value.toInt(), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x70, intValue, role));
else else
// (G)POP object: Pointer location // (G)POP object: Pointer location
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x7c, value.toInt() - 1, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x7c, intValue - 1, role));
break; break;
case 0x15 ... 0x17: // Define object case 0x15 ... 0x17: // Define object
// Local object: triplet number // Local object: triplet number
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x70, value.toInt(), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x70, intValue, role));
break; break;
case 0x18: // DRCS Mode case 0x18: // DRCS Mode
// Normal or Global // Normal or Global
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x3f, value.toInt() << 6, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x3f, intValue << 6, role));
break; break;
case 0x2c: // Display attributes case 0x2c: // Display attributes
// Conceal // Conceal
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7b, value.toInt() << 2, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7b, intValue << 2, role));
break; break;
case 0x2e: // Font style case 0x2e: // Font style
// Italics // Italics
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7b, value.toInt() << 2, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7b, intValue << 2, role));
break; break;
} }
break; break;
case Qt::UserRole+4: case Qt::UserRole+4:
switch (mode) { switch (triplet.modeExt()) {
case 0x11 ... 0x13: // Invoke object case 0x11 ... 0x13: // Invoke object
// (G)POP object: Triplet number // (G)POP object: Triplet number
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1f, value.toInt() << 5, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1f, intValue << 5, role));
break; break;
case 0x18: // DRCS Mode case 0x18: // DRCS Mode
// Subpage // Subpage
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x70, value.toInt(), role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x70, intValue, role));
break; break;
case 0x2c: // Display attributes case 0x2c: // Display attributes
// Invert // Invert
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x6f, value.toInt() << 4, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x6f, intValue << 4, role));
break; break;
case 0x2e: // Font style case 0x2e: // Font style
// Number of rows // Number of rows
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x07, value.toInt() << 4, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x07, intValue << 4, role));
break; break;
} }
break; break;
case Qt::UserRole+5: case Qt::UserRole+5:
switch (mode) { switch (triplet.modeExt()) {
case 0x11 ... 0x13: // Invoke object case 0x11 ... 0x13: // Invoke object
// (G)POP object: Pointer position // (G)POP object: Pointer position
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x6f, value.toInt() << 4, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x6f, intValue << 4, role));
break; break;
case 0x2c: // Display attributes case 0x2c: // Display attributes
// Underline/Separated // Underline/Separated
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x5f, value.toInt() << 5, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x5f, intValue << 5, role));
break; break;
} }
break; break;
} }
return true; return false;
} }
QVariant X26Model::headerData(int section, Qt::Orientation orientation, int role) const QVariant X26Model::headerData(int section, Qt::Orientation orientation, int role) const