Refactor the model

This commit is contained in:
G.K.MacGregor
2021-07-04 16:03:51 +01:00
parent 69b6ad1976
commit 2ec4039393

View File

@@ -343,134 +343,120 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
if (role == Qt::EditRole && index.column() == 2) if (role == Qt::EditRole && index.column() == 2)
return triplet.modeExt(); return triplet.modeExt();
switch (role) { if (role < Qt::UserRole)
case Qt::UserRole+1: return QVariant();
switch (triplet.modeExt()) {
case 0x00: // Full screen colour
case 0x01: // Full row colour
case 0x07: // Address row 0
case 0x20: // Foreground colour
case 0x23: // Background colour
// Colour index
return triplet.data() & 0x1f;
case 0x11 ... 0x13: // Invoke object
// Object source: Local, POP or GPOP
return ((triplet.address() & 0x18) >> 3) - 1;
break;
case 0x15 ... 0x17: // Define object
// Required at which levels
return ((triplet.address() & 0x18) >> 3) - 1;
case 0x18: // DRCS mode
// Required at which levels
return ((triplet.data() & 0x30) >> 4) - 1;
case 0x1f: // Termination
// Intermed POP subpage|Last POP subpage|Local Object|Local enhance
return ((triplet.data() & 0x06) >> 1);
case 0x27: // Flash functions
// Flash mode
return triplet.data() & 0x03;
case 0x2c: // Display attributes
// Text size
return (triplet.data() & 0x01) | ((triplet.data() & 0x40) >> 5);
case 0x2d: // DRCS character
// Normal or Global
return (triplet.data() & 0x40) == 0x40;
case 0x2e: // Font style
// Proportional
return (triplet.data() & 0x01) == 0x01;
default:
return triplet.data();
}
break;
case Qt::UserRole+2: switch (triplet.modeExt()) {
switch (triplet.modeExt()) { case 0x01: // Full row colour
case 0x01: // Full row colour case 0x07: // Address row 0
case 0x07: // Address row 0 if (role == Qt::UserRole+2) // "this row only" or "down to bottom"
// "this row only" or "down to bottom" return (triplet.data() & 0x60) == 0x60;
return (triplet.data() & 0x60) == 0x60; // fall-through
case 0x11 ... 0x13: // Invoke object case 0x00: // Full screen colour
if ((triplet.address() & 0x08) == 0x08) case 0x20: // Foreground colour
case 0x23: // Background colour
if (role == Qt::UserRole+1) // Colour index
return triplet.data() & 0x1f;
break;
case 0x11 ... 0x13: // Invoke object
switch (role) {
case Qt::UserRole+1: // Object source: Local, POP or GPOP
return ((triplet.address() & 0x18) >> 3) - 1;
case Qt::UserRole+2:
if ((triplet.address() & 0x18) == 0x08)
// Local object: Designation code // Local object: Designation code
return ((triplet.address() & 0x01) << 3) | ((triplet.data() & 0x70) >> 4); return ((triplet.address() & 0x01) << 3) | ((triplet.data() & 0x70) >> 4);
else else
// (G)POP object: Subpage // (G)POP object: Subpage
return triplet.data() & 0x0f; return triplet.data() & 0x0f;
break; case Qt::UserRole+3:
case 0x15 ... 0x17: // Define object
// Local object: Designation code
return ((triplet.address() & 0x01) << 3) | ((triplet.data() & 0x70) >> 4);
case 0x1f: // Termination
// More follows/Last
return (triplet.data() & 0x01) == 0x01;
case 0x27: // Flash functions
// Flash rate and phase
return triplet.data() >> 2;
case 0x2c: // Display attributes
// Boxing/window
return (triplet.data() & 0x02) == 0x02;
case 0x2d: // DRCS character
// Character number
return triplet.data() & 0x3f;
case 0x2e: // Font style
// Bold
return (triplet.data() & 0x02) == 0x02;
}
break;
case Qt::UserRole+3:
switch (triplet.modeExt()) {
case 0x11 ... 0x13: // Invoke object
if ((triplet.address() & 0x08) == 0x08) if ((triplet.address() & 0x08) == 0x08)
// Local object: Triplet number // Local object: Triplet number
return triplet.data() & 0x0f; return triplet.data() & 0x0f;
else else
// (G)POP object: Pointer location // (G)POP object: Pointer location
return (triplet.address() & 0x03) + 1; return (triplet.address() & 0x03) + 1;
break; case Qt::UserRole+4: // (G)POP object: Triplet number
case 0x15 ... 0x17: // Define object
// Local object: Triplet number
return triplet.data() & 0x0f;
case 0x18: // DRCS mode
// Normal or Global
return (triplet.data() & 0x40) == 0x40;
case 0x2c: // Display attributes
// Conceal
return (triplet.data() & 0x04) == 0x04;
case 0x2e: // Font style
// Italics
return (triplet.data() & 0x04) == 0x04;
}
break;
case Qt::UserRole+4:
switch (triplet.modeExt()) {
case 0x11 ... 0x13: // Invoke object
// (G)POP object: Triplet number
return triplet.data() >> 5; return triplet.data() >> 5;
case 0x18: // DRCS mode case Qt::UserRole+5: // (G)POP object: Pointer position
// Subpage return (triplet.data() & 0x10) >> 4;
return triplet.data() & 0x0f;
case 0x2c: // Display attributes
// Invert
return (triplet.data() & 0x10) == 0x10;
case 0x2e: // Font style
// Number of rows
return triplet.data() >> 4;
} }
break; break;
case 0x15 ... 0x17: // Define object
case Qt::UserRole+5: switch (role) {
switch (triplet.modeExt()) { case Qt::UserRole+1: // Required at which levels
case 0x11 ... 0x13: // Invoke object return ((triplet.address() & 0x18) >> 3) - 1;
// (G)POP object: Pointer position case Qt::UserRole+2: // Local object: Designation code
return (triplet.data() & 0x10) >> 4; return ((triplet.address() & 0x01) << 3) | ((triplet.data() & 0x70) >> 4);
case 0x2c: // Display attributes case Qt::UserRole+3: // Local object: Triplet number
// Underline/Separated return triplet.data() & 0x0f;
}
break;
case 0x18: // DRCS mode
switch (role) {
case Qt::UserRole+1: // Required at which levels
return ((triplet.data() & 0x30) >> 4) - 1;
case Qt::UserRole+3: // Normal or Global
return (triplet.data() & 0x40) == 0x40;
case Qt::UserRole+4: // Subpage
return triplet.data() & 0x0f;
}
break;
case 0x1f: // Termination
switch (role) {
case Qt::UserRole+1: // Intermed POP subpage|Last POP subpage|Local Object|Local enhance
return ((triplet.data() & 0x06) >> 1);
case Qt::UserRole+2: // More follows/Last
return (triplet.data() & 0x01) == 0x01;
}
break;
case 0x27: // Flash functions
switch (role) {
case Qt::UserRole+1: // Flash mode
return triplet.data() & 0x03;
case Qt::UserRole+2: // Flash rate and phase
return triplet.data() >> 2;
}
break;
case 0x2c: // Display attributes
switch (role) {
case Qt::UserRole+1: // Text size
return (triplet.data() & 0x01) | ((triplet.data() & 0x40) >> 5);
case Qt::UserRole+2: // Boxing/window
return (triplet.data() & 0x02) == 0x02;
case Qt::UserRole+3: // Conceal
return (triplet.data() & 0x04) == 0x04;
case Qt::UserRole+4: // Invert
return (triplet.data() & 0x10) == 0x10;
case Qt::UserRole+5: // Underline/Separated
return (triplet.data() & 0x20) == 0x20; return (triplet.data() & 0x20) == 0x20;
} }
break; break;
} case 0x2d: // DRCS character
switch (role) {
case Qt::UserRole+1: // Normal or Global
return (triplet.data() & 0x40) == 0x40;
case Qt::UserRole+2: // Character number
return triplet.data() & 0x3f;
}
break;
case 0x2e: // Font style
switch (role) {
case Qt::UserRole+1: // Proportional
return (triplet.data() & 0x01) == 0x01;
case Qt::UserRole+2: // Bold
return (triplet.data() & 0x02) == 0x02;
case Qt::UserRole+3: // Italic
return (triplet.data() & 0x04) == 0x04;
case Qt::UserRole+4: // Number of rows
return triplet.data() >> 4;
}
break;
};
// Fpr other triplet modes, return the complete data value
if (role == Qt::UserRole+1)
return triplet.data();
return QVariant(); return QVariant();
} }
@@ -624,167 +610,157 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
if ((triplet.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;
}; }
return true; return true;
} }
return false; return false;
} }
// Triplet data if (role < Qt::UserRole)
switch (role) { return false;
case Qt::UserRole+1:
switch (triplet.modeExt()) {
case 0x01: // Full row colour
case 0x07: // Address row 0
// Colour index
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x60, intValue, role));
break;
case 0x11 ... 0x13: // Invoke object
// Object source: Local, POP or GPOP
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x27, (intValue+1) << 3, role));
break;
case 0x15 ... 0x17: // Define object
// Required at which levels
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x27, (intValue+1) << 3, role));
break;
case 0x18: // DRCS Mode
// Required at which levels
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x4f, (intValue+1) << 4, role));
break;
case 0x1f: // Termination
// 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, intValue << 1, role));
break;
case 0x27: // Flash functions
// Flash mode
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1c, intValue, role));
break;
case 0x2c: // Display attributes
// Text size
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x36, ((intValue & 0x02) << 5) | (intValue & 0x01), role));
break;
case 0x2d: // DRCS character
// Normal or Global
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x3f, intValue << 6, role));
break;
case 0x2e: // Font style
// Proportional
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7e, intValue, role));
break;
default: // Others set the complete data value
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, intValue, role));
}
break;
case Qt::UserRole+2: switch (triplet.modeExt()) {
switch (triplet.modeExt()) { case 0x01: // Full row colour
case 0x00: // Full screen colour case 0x07: // Address row 0
case 0x01: // Full row colour switch (role) {
case 0x07: // Address row 0 case Qt::UserRole+1: // Colour index
// "this row only" or "down to bottom" m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x60, intValue, role));
return true;
case Qt::UserRole+2: // "this row only" or "down to bottom"
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1f, intValue * 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 }
if ((triplet.address() & 0x08) == 0x08) { break;
case 0x11 ... 0x13: // Invoke object
switch (role) {
case Qt::UserRole+1: // Object source: Local, POP or GPOP
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x27, (intValue+1) << 3, role));
return true;
case Qt::UserRole+2:
if ((triplet.address() & 0x18) == 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, (intValue & 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, intValue >> 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, intValue, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x30, intValue, role));
break; return true;
case 0x15 ... 0x17: // Define object case Qt::UserRole+3: // Invoke object
// Local object: Designation code if ((triplet.address() & 0x18) == 0x08)
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, intValue >> 3, role));
break;
case 0x1f: // Termination
// More follows/Last
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x06, intValue, role));
break;
case 0x27: // Flash functions
// Flash rate and phase
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x03, intValue << 2, role));
break;
case 0x2c: // Display attributes
// Boxing/window
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7d, intValue << 1, role));
break;
case 0x2d: // DRCS character
// Character number
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x40, intValue, role));
break;
case 0x2e: // Font style
// Bold
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7d, intValue << 1, role));
break;
}
break;
case Qt::UserRole+3:
switch (triplet.modeExt()) {
case 0x11 ... 0x13: // Invoke object
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, intValue, 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, intValue - 1, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x7c, intValue - 1, role));
break; return true;
case 0x15 ... 0x17: // Define object case Qt::UserRole+4: // (G)POP object: Triplet number
// Local object: triplet number
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x70, intValue, role));
break;
case 0x18: // DRCS Mode
// Normal or Global
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x3f, intValue << 6, role));
break;
case 0x2c: // Display attributes
// Conceal
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7b, intValue << 2, role));
break;
case 0x2e: // Font style
// Italics
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7b, intValue << 2, role));
break;
}
break;
case Qt::UserRole+4:
switch (triplet.modeExt()) {
case 0x11 ... 0x13: // Invoke object
// (G)POP object: Triplet number
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1f, intValue << 5, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1f, intValue << 5, role));
break; return true;
case 0x18: // DRCS Mode case Qt::UserRole+5: // (G)POP object: Pointer position
// Subpage m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x6f, intValue << 4, role));
return true;
}
break;
case 0x15 ... 0x17: // Define object
switch (role) {
case Qt::UserRole+1: // Required at which levels
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETaddress, 0x27, (intValue+1) << 3, role));
return true;
case Qt::UserRole+2: // Local object: Designation code
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, intValue >> 3, role));
return true;
case Qt::UserRole+3: // Local object: triplet number
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x70, intValue, 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 }
// Invert break;
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x6f, intValue << 4, role)); case 0x18: // DRCS Mode
break; switch (role) {
case 0x2e: // Font style case Qt::UserRole+1: // Required at which levels
// Number of rows m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x4f, (intValue+1) << 4, role));
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x07, intValue << 4, role)); return true;
case Qt::UserRole+3: // Normal or Global
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x3f, intValue << 6, role));
return true;
case Qt::UserRole+4: // Subpage
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x70, intValue, role));
return true;
}
break;
case 0x1f: // Termination
switch (role) {
case Qt::UserRole+1: // 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, intValue << 1, role));
return true;
case Qt::UserRole+2: // More follows/Last
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x06, intValue, role));
return true;
}
break;
case 0x27: // Flash functions
switch (role) {
case Qt::UserRole+1: // Flash mode
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x1c, intValue, role));
return true;
case Qt::UserRole+2: // Flash rate and phase
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x03, intValue << 2, role));
break; break;
} }
break; break;
case 0x2c: // Display attributes
case Qt::UserRole+5: switch (role) {
switch (triplet.modeExt()) { case Qt::UserRole+1: // Text size
case 0x11 ... 0x13: // Invoke object m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x36, ((intValue & 0x02) << 5) | (intValue & 0x01), role));
// (G)POP object: Pointer position return true;
case Qt::UserRole+2: // Boxing/window
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7d, intValue << 1, role));
return true;
case Qt::UserRole+3: // Conceal
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7b, intValue << 2, role));
return true;
case Qt::UserRole+4: // Invert
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x6f, intValue << 4, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x6f, intValue << 4, role));
break; return true;
case 0x2c: // Display attributes case Qt::UserRole+5: // Underline/Separated
// Underline/Separated
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x5f, intValue << 5, role)); m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x5f, intValue << 5, role));
return true;
}
break;
case 0x2d: // DRCS character
switch (role) {
case Qt::UserRole+1: // Normal or Global
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x3f, intValue << 6, role));
return true;
case Qt::UserRole+2: // Character number
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x40, intValue, role));
break; break;
} }
break; break;
case 0x2e: // Font style
switch (role) {
case Qt::UserRole+1: // Proportional
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7e, intValue, role));
return true;
case Qt::UserRole+2: // Bold
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7d, intValue << 1, role));
return true;
case Qt::UserRole+3: // Italic
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x7b, intValue << 2, role));
return true;
case Qt::UserRole+4: // Number of rows
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x07, intValue << 4, role));
return true;
}
break;
} }
// Fpr other triplet modes, set the complete data value
if (role == Qt::UserRole+1) {
m_parentMainWidget->document()->undoStack()->push(new EditTripletCommand(m_parentMainWidget->document(), this, index.row(), EditTripletCommand::ETdata, 0x00, intValue, role));
return true;
}
return false; return false;
} }