Add stacked widget to edit triplet parameters

The knowledge of how colour, character etc parameters fit within the
address and data triplets is no longer required. We now present
widgets that explicitly refer to colour, character that are more
user friendly.
This commit is contained in:
G.K.MacGregor
2020-10-18 20:59:04 +01:00
parent af6ec1cac9
commit 1c03481c13
4 changed files with 1390 additions and 412 deletions

View File

@@ -17,16 +17,16 @@ Although designed on and developed for Linux, the Qt 5 libraries are cross platf
### Linux
Install the QtCore, QtGui and QtWidgets libraries and build headers, along with the qmake tool. Then type `qmake && make -j3` in a terminal, you can replace -j3 with the number of processor cores used for the compile process.
The above will place the qteletextmaker executable in the same directory as the source, type `./qteletextmaker` in the terminal to launch. Optionally, type `make install` afterwards to place the exectuable into /usr/local/bin.
The above will place the qteletextmaker executable in the same directory as the source, type `./qteletextmaker` in the terminal to launch. Optionally, type `make install` afterwards to place the executable into /usr/local/bin.
## Current limitations
At the moment QTeletextMaker is in pre-alpha status so many features are not finished yet. The most-often encountered limitations are detailed here.
Spacing attributes are only accessible through an "Insert" menu. A toolbar to insert spacing attributes may be added in the future.
There is no visible widget for switching between subpages, use the PageUp and PageDown keys for this.
There is no visible widget for switching between subpages, use the `PageUp` and `PageDown` keys for this.
Undo only undoes keypresses, insertion of spacing attributes and CLUT changes. Other changes can't be undone, nor will they cause the "unsaved page" dialog to appear if the editor window is closed.
Undo only undoes keypresses, insertion of spacing attributes and CLUT changes. Other changes (most notably triplet editing) can't be undone, nor will they cause the "unsaved page" dialog to appear if the editor window is closed.
Keymapping between ASCII and Teletext character sets is not yet implemented e.g. in English pressing the hash key will type a pound sign instead, and in other languages the square and curly brackets keys need to be pressed to obtain the accented characters.
@@ -38,13 +38,27 @@ The following X/26 enhancement triplets are not rendered by the editor, although
- Level 3.5 font style: bold, italic and proportional spacing.
## Using the X/26 triplet editor
At present the editor only accepts raw triplet Address, Mode and Data numbers for input although the effects of the Triplet are shown in the list as a full description. The full behaviour of these enhancement triplets can be found in
section 12.3 of the [Enhanced Teletext specification ETS 300 706](https://web.archive.org/web/20160326062859/https://www.phecap.nl/download/enhenced-teletext-specs.pdf) but some hints and tips are below.
The X/26 triplet editor sorts all the triplet modes available into categories selected by the triplet *type* dropdown on the left. The categories are:
- Set Active Position
- Row triplet
- Column triplet
- Object
- Terminator
- PDC/reserved
### Address values
Address values 0-39 select a Column Triplet and, with the exception of reserved and PDC Modes, set the column co-ordinate of the Active Position.
Selecting "Set Active Position" or "Terminator" will change the triplet mode immediately, other selections will activate the triplet *mode* dropdown on the right which can be used to then change the triplet mode. Most triplet modes will present varying widgets below which can be used to alter the parameters of the currently selected triplet (e.g. colour or character).
Address values 40-63 select a Row Triplet which has a different set of modes. Modes 4 (Set Active Position) and 1 (Full Row Colour) will set the row co-ordinate of the Active Position to the Address value minus 40, except for Address value 40 which will set the row co-ordinate to 24.
Between the two dropdowns are the Row and Column spinboxes that are used to place the Active Position of the selected triplet, whether or not each spinbox can be altered depends on the mode of the selected triplet. As well as the explicit "Set Active Position" triplet that can set both the row and the column, all column triplets can simultaneously set the column of the Active Position. Additionally the Full Row Colour triplet can set the row of the Active Position, with the column always set to 0.
By checking "raw values" it is also possible to view and edit the raw Address, Mode and Data numbers of the triplets. When editing triplets this way, remember that address values 0-39 select a column triplet which has one set of modes and address values 40-63 select a row triplet which has a different set of modes.
The full behaviour of X/26 enhancement triplets can be found in section 12.3 of the [Enhanced Teletext specification ETS 300 706](https://web.archive.org/web/20160326062859/https://www.phecap.nl/download/enhenced-teletext-specs.pdf).
### Setting the Active Position
The Active Position, whether set explicitly by a row or column triplet, can only be moved in screen address order i.e. from left to right within a row and then from top to bottom across rows. In other words:
- The Active Position can never be moved up to a lesser numbered row.
- The Active Position can never be moved left *within the same row* to a lesser numbered column, but it can be moved left at the same time as it is moved down to a greater numbered row.
If this rule is not followed then triplets in earlier screen addresses will be ignored.
### Objects
"Define ... Object" triplets need to declare that they are in the correct place in the triplet list e.g. if the Define Object triplet is at `d1 t3` in the list then the data field must show `Local: d1 t3`, otherwise the Object won't appear.

View File

@@ -29,6 +29,7 @@
#include <QRadioButton>
#include <QShortcut>
#include <QSpinBox>
#include <QStackedLayout>
#include <QStandardItemModel>
#include <QToolButton>
#include <QVBoxLayout>
@@ -56,19 +57,74 @@ X26DockWidget::X26DockWidget(TeletextWidget *parent): QDockWidget(parent)
m_x26View->setColumnWidth(3, 200);
x26Layout->addWidget(m_x26View);
// "Temporary" widgets to edit raw triplet values
// Triplet type and mode selection, with row and column spinboxes
QHBoxLayout *tripletSelectLayout = new QHBoxLayout;
// Checkbox to select user-friendly or raw-value widgets
QCheckBox *rawOrCookedCheckBox = new QCheckBox(tr("Raw values"));
tripletSelectLayout->addWidget(rawOrCookedCheckBox);
// "Cooked" or user-friendly triplet type, row and column selection
QHBoxLayout *cookedTripletLayout = new QHBoxLayout;
m_cookedModeTypeComboBox = new QComboBox;
m_cookedModeTypeComboBox->addItem("Set Active Position");
m_cookedModeTypeComboBox->addItem("Row triplet");
m_cookedModeTypeComboBox->addItem("Column triplet");
m_cookedModeTypeComboBox->addItem("Object");
m_cookedModeTypeComboBox->addItem("Terminator");
m_cookedModeTypeComboBox->addItem("PDC/reserved");
cookedTripletLayout->addWidget(m_cookedModeTypeComboBox);
connect(m_cookedModeTypeComboBox, QOverload<int>::of(&QComboBox::activated), this, &X26DockWidget::updateCookedModeFromCookedType);
// Cooked row spinbox
QLabel *rowLabel = new QLabel(tr("Row"));
rowLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
cookedTripletLayout->addWidget(rowLabel);
m_cookedRowSpinBox = new QSpinBox;
m_cookedRowSpinBox->setMaximum(24); // FIXME maximum value reset when triplet is selected
m_cookedRowSpinBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
cookedTripletLayout->addWidget(m_cookedRowSpinBox);
connect(m_cookedRowSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &X26DockWidget::cookedRowSpinBoxChanged);
// Cooked column spinbox
QLabel *columnLabel = new QLabel(tr("Column"));
columnLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
cookedTripletLayout->addWidget(columnLabel);
// cookedTripletLayout->addWidget(new QLabel(tr("Column")));
m_cookedColumnSpinBox = new QSpinBox;
m_cookedColumnSpinBox->setMaximum(39); // FIXME maximum value reset when triplet is selected
m_cookedColumnSpinBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
cookedTripletLayout->addWidget(m_cookedColumnSpinBox);
connect(m_cookedColumnSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &X26DockWidget::cookedColumnSpinBoxChanged);
// Cooked triplet mode
m_cookedModeComboBox = new QComboBox;
// FIXME maybe remove this example
/* m_cookedModeComboBox->addItem("Colour");
m_cookedModeComboBox->addItem("Character");
m_cookedModeComboBox->addItem("Flash");
m_cookedModeComboBox->addItem("Display");*/
m_cookedModeComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
cookedTripletLayout->addWidget(m_cookedModeComboBox);
connect(m_cookedModeComboBox, QOverload<int>::of(&QComboBox::activated), this, &X26DockWidget::cookedModeComboBoxChanged);
// Raw triplet values
QHBoxLayout *rawTripletLayout = new QHBoxLayout;
// Raw triplet address
rawTripletLayout->addWidget(new QLabel(tr("Address")));
m_rawTripletAddressSpinBox = new QSpinBox;
m_rawTripletAddressSpinBox->setMaximum(63);
rawTripletLayout->addWidget(m_rawTripletAddressSpinBox);
// Raw triplet mode
rawTripletLayout->addWidget(new QLabel(tr("Mode")));
m_rawTripletModeSpinBox = new QSpinBox;
m_rawTripletModeSpinBox->setMaximum(31);
rawTripletLayout->addWidget(m_rawTripletModeSpinBox);
// Raw triplet data
rawTripletLayout->addWidget(new QLabel(tr("Data")));
m_rawTripletDataSpinBox = new QSpinBox;
m_rawTripletDataSpinBox->setMaximum(127);
@@ -78,7 +134,313 @@ X26DockWidget::X26DockWidget(TeletextWidget *parent): QDockWidget(parent)
connect(m_rawTripletModeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &X26DockWidget::rawTripletModeSpinBoxChanged);
connect(m_rawTripletDataSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, &X26DockWidget::rawTripletDataSpinBoxChanged);
x26Layout->addLayout(rawTripletLayout);
// Stack the raw and cooked layouts together
m_rawOrCookedStackedLayout = new QStackedLayout;
QWidget *cookedTripletWidget = new QWidget;
cookedTripletWidget->setLayout(cookedTripletLayout);
cookedTripletWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_rawOrCookedStackedLayout->addWidget(cookedTripletWidget);
QWidget *rawTripletWidget = new QWidget;
rawTripletWidget->setLayout(rawTripletLayout);
rawTripletWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_rawOrCookedStackedLayout->addWidget(rawTripletWidget);
// We could simply: tripletSelectLayout->addLayout(m_rawOrCookedStackedLayout);
// but we need to keep it to the smallest size, only possible by putting it inside a QWidget
QWidget *rawOrCookedWidget = new QWidget;
rawOrCookedWidget->setLayout(m_rawOrCookedStackedLayout);
rawOrCookedWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
tripletSelectLayout->addWidget(rawOrCookedWidget);
x26Layout->addLayout(tripletSelectLayout);
connect(rawOrCookedCheckBox, &QCheckBox::stateChanged,[=](const int value) { m_rawOrCookedStackedLayout->setCurrentIndex(value == 2); } );
// Widgets that alter the parameters of triplets which will all be stacked
// Colour and "this row only"/"down to bottom" selection
QHBoxLayout *colourAndRowLayout = new QHBoxLayout;
m_colourComboBox = new QComboBox;
for (int c=0; c<=3; c++)
for (int e=0; e<=7; e++)
m_colourComboBox->addItem(tr("CLUT %1:%2").arg(c).arg(e));
colourAndRowLayout->addWidget(m_colourComboBox);
connect(m_colourComboBox, QOverload<int>::of(&QComboBox::activated), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+1); } );
m_fullRowColourThisRowOnlyRadioButton = new QRadioButton(tr("This row only"));
m_fullRowColourDownToBottomRadioButton = new QRadioButton(tr("Down to bottom"));
QButtonGroup *rowsButtonGroup = new QButtonGroup;
rowsButtonGroup->addButton(m_fullRowColourThisRowOnlyRadioButton, 0);
rowsButtonGroup->addButton(m_fullRowColourDownToBottomRadioButton, 1);
colourAndRowLayout->addWidget(m_fullRowColourThisRowOnlyRadioButton);
colourAndRowLayout->addWidget(m_fullRowColourDownToBottomRadioButton);
connect(m_fullRowColourThisRowOnlyRadioButton, &QAbstractButton::clicked, this, [=] { updateModelFromCookedWidget(0, Qt::UserRole+2); } );
connect(m_fullRowColourDownToBottomRadioButton, &QAbstractButton::clicked, this, [=] { updateModelFromCookedWidget(1, Qt::UserRole+2); } );
// Character code - also used as parameter for PDC and reserved
QHBoxLayout *characterCodeLayout = new QHBoxLayout;
m_characterCodeSpinBox = new QSpinBox;
m_characterCodeSpinBox->setRange(32, 127);
m_characterCodeSpinBox->setDisplayIntegerBase(16);
m_characterCodeSpinBox->setPrefix("0x");
m_characterCodeSpinBox->setWrapping(true);
characterCodeLayout->addWidget(m_characterCodeSpinBox);
connect(m_characterCodeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+1); } );
// Flash rate and phase
QHBoxLayout *flashModeRateLayout = new QHBoxLayout;
m_flashModeComboBox = new QComboBox;
m_flashModeComboBox->addItem(tr("Steady"));
m_flashModeComboBox->addItem(tr("Normal"));
m_flashModeComboBox->addItem(tr("Invert"));
m_flashModeComboBox->addItem(tr("Adjacent CLUT"));
flashModeRateLayout->addWidget(m_flashModeComboBox);
connect(m_flashModeComboBox, QOverload<int>::of(&QComboBox::activated), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+1); } );
m_flashRateComboBox = new QComboBox;
m_flashRateComboBox->addItem(tr("Slow 1Hz"));
m_flashRateComboBox->addItem(tr("Fast 2Hz phase 1"));
m_flashRateComboBox->addItem(tr("Fast 2Hz phase 2"));
m_flashRateComboBox->addItem(tr("Fast 2Hz phase 3"));
m_flashRateComboBox->addItem(tr("Fast 2Hz inc/right"));
m_flashRateComboBox->addItem(tr("Fast 2Hz dec/left"));
flashModeRateLayout->addWidget(m_flashRateComboBox);
connect(m_flashRateComboBox, QOverload<int>::of(&QComboBox::activated), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+2); } );
// Display attributes
QHBoxLayout *displayAttributesLayout = new QHBoxLayout;
m_textSizeComboBox = new QComboBox;
m_textSizeComboBox->addItem(tr("Normal size"));
m_textSizeComboBox->addItem(tr("Double height"));
m_textSizeComboBox->addItem(tr("Double width"));
m_textSizeComboBox->addItem(tr("Double size"));
displayAttributesLayout->addWidget(m_textSizeComboBox);
connect(m_textSizeComboBox, QOverload<int>::of(&QComboBox::activated), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+1); } );
m_displayAttributeBoxingCheckBox = new QCheckBox(tr("Box/Win"));
m_displayAttributeConcealCheckBox = new QCheckBox(tr("Conceal"));
m_displayAttributeInvertCheckBox = new QCheckBox(tr("Invert"));
m_displayAttributeUnderlineCheckBox = new QCheckBox(tr("Und/Sep mosaics"));
displayAttributesLayout->addWidget(m_displayAttributeBoxingCheckBox);
displayAttributesLayout->addWidget(m_displayAttributeConcealCheckBox);
displayAttributesLayout->addWidget(m_displayAttributeInvertCheckBox);
displayAttributesLayout->addWidget(m_displayAttributeUnderlineCheckBox);
connect(m_displayAttributeBoxingCheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget((value == 2), Qt::UserRole+2); } );
connect(m_displayAttributeConcealCheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget((value == 2), Qt::UserRole+3); } );
connect(m_displayAttributeInvertCheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget((value == 2), Qt::UserRole+4); } );
connect(m_displayAttributeUnderlineCheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget((value == 2), Qt::UserRole+5); } );
// Invoke Object
QHBoxLayout *invokeObjectLayout = new QHBoxLayout;
// From local or (G)POP page
m_objectSourceComboBox = new QComboBox;
m_objectSourceComboBox->addItem("Local");
m_objectSourceComboBox->addItem("POP");
m_objectSourceComboBox->addItem("GPOP");
invokeObjectLayout->addWidget(m_objectSourceComboBox);
// FIXME combine this with bit setting
connect(m_objectSourceComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](const int value) { m_invokeObjectSourceStackedLayout->setCurrentIndex(value != 0); updateModelFromCookedWidget(value, Qt::UserRole+1); } );
// Object required at which levels
m_objectRequiredAtL2p5CheckBox = new QCheckBox("L2.5");
m_objectRequiredAtL3p5CheckBox = new QCheckBox("L3.5");
invokeObjectLayout->addWidget(m_objectRequiredAtL2p5CheckBox);
invokeObjectLayout->addWidget(m_objectRequiredAtL3p5CheckBox);
connect(m_objectRequiredAtL2p5CheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+1); } );
connect(m_objectRequiredAtL3p5CheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+4); } );
// Invoke Local Objects
QHBoxLayout *invokeLocalObjectLayout = new QHBoxLayout;
invokeLocalObjectLayout->addWidget(new QLabel(tr("Designation")));
m_invokeLocalObjectDesignationCodeSpinBox = new QSpinBox;
m_invokeLocalObjectDesignationCodeSpinBox->setMaximum(15);
invokeLocalObjectLayout->addWidget(m_invokeLocalObjectDesignationCodeSpinBox);
connect(m_invokeLocalObjectDesignationCodeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+2); } );
invokeLocalObjectLayout->addWidget(new QLabel(tr("Triplet")));
m_invokeLocalObjectTripletNumberSpinBox = new QSpinBox;
m_invokeLocalObjectTripletNumberSpinBox->setMaximum(12);
invokeLocalObjectLayout->addWidget(m_invokeLocalObjectTripletNumberSpinBox);
connect(m_invokeLocalObjectTripletNumberSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+3); } );
// Invoke (G)POP Object
QHBoxLayout *invokePOPLayout = new QHBoxLayout;
// (G)POP subpage
invokePOPLayout->addWidget(new QLabel(tr("Subpage")));
m_invokePOPSubPageSpinBox = new QSpinBox;
m_invokePOPSubPageSpinBox->setMaximum(15);
m_invokePOPSubPageSpinBox->setWrapping(true);
invokePOPLayout->addWidget(m_invokePOPSubPageSpinBox);
connect(m_invokePOPSubPageSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+2); } );
// (G)POP packet to locate the pointer
invokePOPLayout->addWidget(new QLabel(tr("Packet")));
m_invokePOPPacketNumberSpinBox = new QSpinBox;
m_invokePOPPacketNumberSpinBox->setRange(1, 4);
m_invokePOPPacketNumberSpinBox->setWrapping(true);
invokePOPLayout->addWidget(m_invokePOPPacketNumberSpinBox);
connect(m_invokePOPPacketNumberSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+3); } );
// (G)POP triplet with pointer
m_invokePOPTripletNumberComboBox = new QComboBox;
// FIXME test if this example removal works
/* m_invokePOPTripletNumberComboBox->addItem("Triplet 1");
m_invokePOPTripletNumberComboBox->addItem("Triplet 4");
m_invokePOPTripletNumberComboBox->addItem("Triplet 7");
m_invokePOPTripletNumberComboBox->addItem("Triplet 10");*/
invokePOPLayout->addWidget(m_invokePOPTripletNumberComboBox);
connect(m_invokePOPTripletNumberComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+4); } );
// (G)POP which bits of triplet for the pointer
m_invokePOPPointerBitsComboBox = new QComboBox;
m_invokePOPPointerBitsComboBox->addItem("Bits 1-9");
m_invokePOPPointerBitsComboBox->addItem("Bits 10-18");
invokePOPLayout->addWidget(m_invokePOPPointerBitsComboBox);
connect(m_invokePOPPointerBitsComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+5); } );
// Stack the Local and (G)POP layouts together
m_invokeObjectSourceStackedLayout = new QStackedLayout;
QWidget *invokeLocalObjectWidget = new QWidget;
invokeLocalObjectWidget->setLayout(invokeLocalObjectLayout);
invokeLocalObjectWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_invokeObjectSourceStackedLayout->addWidget(invokeLocalObjectWidget);
QWidget *invokeGPOPWidget = new QWidget;
invokeGPOPWidget->setLayout(invokePOPLayout);
invokeGPOPWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_invokeObjectSourceStackedLayout->addWidget(invokeGPOPWidget);
// We could simply: invokeObjectLayout->addLayout(m_rawOrCookedStackedLayout);
// but we need to keep it to the smallest size, only possible by putting it inside a QWidget
QWidget *invokeObjectSourceWidget = new QWidget;
invokeObjectSourceWidget->setLayout(m_invokeObjectSourceStackedLayout);
invokeObjectSourceWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
invokeObjectLayout->addWidget(invokeObjectSourceWidget);
// DRCS mode
QHBoxLayout *DRCSModeLayout = new QHBoxLayout;
m_DRCSModeRequiredAtL2p5CheckBox = new QCheckBox("L2.5");
m_DRCSModeRequiredAtL3p5CheckBox = new QCheckBox("L3.5");
DRCSModeLayout->addWidget(m_DRCSModeRequiredAtL2p5CheckBox);
DRCSModeLayout->addWidget(m_DRCSModeRequiredAtL3p5CheckBox);
connect(m_DRCSModeRequiredAtL2p5CheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+1); } );
connect(m_DRCSModeRequiredAtL3p5CheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+2); } );
m_DRCSModeGlobalRadioButton = new QRadioButton("Global");
m_DRCSModeNormalRadioButton = new QRadioButton("Normal");
QButtonGroup *DRCSModeButtonGroup = new QButtonGroup;
DRCSModeButtonGroup->addButton(m_DRCSModeGlobalRadioButton, 0);
DRCSModeButtonGroup->addButton(m_DRCSModeNormalRadioButton, 1);
DRCSModeLayout->addWidget(m_DRCSModeGlobalRadioButton);
DRCSModeLayout->addWidget(m_DRCSModeNormalRadioButton);
connect(m_DRCSModeGlobalRadioButton, &QAbstractButton::clicked, this, [=] { updateModelFromCookedWidget(0, Qt::UserRole+3); } );
connect(m_DRCSModeNormalRadioButton, &QAbstractButton::clicked, this, [=] { updateModelFromCookedWidget(1, Qt::UserRole+3); } );
DRCSModeLayout->addWidget(new QLabel(tr("Subpage")));
m_DRCSModeSubPageSpinBox = new QSpinBox;
m_DRCSModeSubPageSpinBox->setMaximum(15);
m_DRCSModeSubPageSpinBox->setWrapping(true);
DRCSModeLayout->addWidget(m_DRCSModeSubPageSpinBox);
connect(m_DRCSModeSubPageSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+4); } );
// DRCS character
QHBoxLayout *DRCSCharacterLayout = new QHBoxLayout;
m_DRCSCharacterGlobalRadioButton = new QRadioButton("Global");
m_DRCSCharacterNormalRadioButton = new QRadioButton("Normal");
QButtonGroup *DRCSCharacterButtonGroup = new QButtonGroup;
DRCSCharacterButtonGroup->addButton(m_DRCSCharacterGlobalRadioButton, 0);
DRCSCharacterButtonGroup->addButton(m_DRCSCharacterNormalRadioButton, 1);
DRCSCharacterLayout->addWidget(m_DRCSCharacterGlobalRadioButton);
DRCSCharacterLayout->addWidget(m_DRCSCharacterNormalRadioButton);
connect(m_DRCSCharacterGlobalRadioButton, &QAbstractButton::clicked, this, [=] { updateModelFromCookedWidget(0, Qt::UserRole+1); } );
connect(m_DRCSCharacterNormalRadioButton, &QAbstractButton::clicked, this, [=] { updateModelFromCookedWidget(1, Qt::UserRole+1); } );
DRCSCharacterLayout->addWidget(new QLabel(tr("Character")));
m_DRCSCharacterCodeSpinBox = new QSpinBox;
m_DRCSCharacterCodeSpinBox->setMaximum(47);
m_DRCSCharacterCodeSpinBox->setWrapping(true);
DRCSCharacterLayout->addWidget(m_DRCSCharacterCodeSpinBox);
connect(m_DRCSCharacterCodeSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+2); } );
// Font style
QHBoxLayout *fontStyleLayout = new QHBoxLayout;
m_fontStyleProportionalCheckBox = new QCheckBox(tr("Proportional"));
m_fontStyleBoldCheckBox = new QCheckBox(tr("Bold"));
m_fontStyleItalicCheckBox = new QCheckBox(tr("Italic"));
fontStyleLayout->addWidget(m_fontStyleProportionalCheckBox);
fontStyleLayout->addWidget(m_fontStyleBoldCheckBox);
fontStyleLayout->addWidget(m_fontStyleItalicCheckBox);
connect(m_fontStyleProportionalCheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget((value == 2), Qt::UserRole+1); } );
connect(m_fontStyleBoldCheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget((value == 2), Qt::UserRole+2);; } );
connect(m_fontStyleItalicCheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget((value == 2), Qt::UserRole+3); } );
m_fontStyleRowsSpinBox = new QSpinBox;
m_fontStyleRowsSpinBox->setRange(0, 7);
fontStyleLayout->addWidget(m_fontStyleRowsSpinBox);
connect(m_fontStyleRowsSpinBox, QOverload<int>::of(&QSpinBox::valueChanged), this, [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+4); } );
// Terminator
QHBoxLayout *terminationMarkerLayout = new QHBoxLayout;
m_terminationMarkerPageTypeComboBox = new QComboBox;
m_terminationMarkerPageTypeComboBox->addItem("Interm (G)POP page");
m_terminationMarkerPageTypeComboBox->addItem("Last (G)POP page");
m_terminationMarkerPageTypeComboBox->addItem("Local Object defs");
m_terminationMarkerPageTypeComboBox->addItem("Local enhancements");
terminationMarkerLayout->addWidget(m_terminationMarkerPageTypeComboBox);
connect(m_terminationMarkerPageTypeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), [=](const int value) { updateModelFromCookedWidget(value, Qt::UserRole+1); } );
m_terminationMarkerMoreFollowsCheckBox = new QCheckBox(tr("Objects follow"));
terminationMarkerLayout->addWidget(m_terminationMarkerMoreFollowsCheckBox);
connect(m_terminationMarkerMoreFollowsCheckBox, &QCheckBox::stateChanged, this, [=](const int value) { updateModelFromCookedWidget(value != 2, Qt::UserRole+2); } );
// Stack all the triplet parameter layouts together
m_tripletParameterStackedLayout = new QStackedLayout;
QLabel *blankWidget = new QLabel("Intentionally blank");
m_tripletParameterStackedLayout->addWidget(blankWidget);
QWidget *colourAndRowWidget = new QWidget;
colourAndRowWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
colourAndRowWidget->setLayout(colourAndRowLayout);
m_tripletParameterStackedLayout->addWidget(colourAndRowWidget);
QWidget *characterCodeWidget = new QWidget;
characterCodeWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
characterCodeWidget->setLayout(characterCodeLayout);
m_tripletParameterStackedLayout->addWidget(characterCodeWidget);
QWidget *flashModeRateWidget = new QWidget;
flashModeRateWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
flashModeRateWidget->setLayout(flashModeRateLayout);
m_tripletParameterStackedLayout->addWidget(flashModeRateWidget);
QWidget *displayAttributesWidget = new QWidget;
displayAttributesWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
displayAttributesWidget->setLayout(displayAttributesLayout);
m_tripletParameterStackedLayout->addWidget(displayAttributesWidget);
QWidget *invokeObjectWidget = new QWidget;
invokeObjectWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
invokeObjectWidget->setLayout(invokeObjectLayout);
m_tripletParameterStackedLayout->addWidget(invokeObjectWidget);
QWidget *DRCSModeWidget = new QWidget;
DRCSModeWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
DRCSModeWidget->setLayout(DRCSModeLayout);
m_tripletParameterStackedLayout->addWidget(DRCSModeWidget);
QWidget *DRCSCharacterWidget = new QWidget;
DRCSCharacterWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
DRCSCharacterWidget->setLayout(DRCSCharacterLayout);
m_tripletParameterStackedLayout->addWidget(DRCSCharacterWidget);
QWidget *fontStyleWidget = new QWidget;
fontStyleWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
fontStyleWidget->setLayout(fontStyleLayout);
m_tripletParameterStackedLayout->addWidget(fontStyleWidget);
QWidget *terminationMarkerWidget = new QWidget;
terminationMarkerWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
terminationMarkerWidget->setLayout(terminationMarkerLayout);
m_tripletParameterStackedLayout->addWidget(terminationMarkerWidget);
// We could simply: x26Layout->addLayout(m_tripletParameterStackedLayout);
// but we need to keep it to the smallest size, only possible by putting it inside a QWidget
QWidget *tripletParameterWidget = new QWidget;
tripletParameterWidget->setLayout(m_tripletParameterStackedLayout);
tripletParameterWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
x26Layout->addWidget(tripletParameterWidget);
// Insert and delete widgets
QHBoxLayout *insertDeleteLayout = new QHBoxLayout;
@@ -122,10 +484,356 @@ void X26DockWidget::unloadX26List()
void X26DockWidget::rowClicked(const QModelIndex &index)
{
updateRawTripletWidgets(index);
updateAllRawTripletSpinBoxes(index);
updateAllCookedTripletWidgets(index);
}
void X26DockWidget::updateRawTripletWidgets(const QModelIndex &index)
void X26DockWidget::updateAllCookedTripletWidgets(const QModelIndex &index)
{
const int modeExt = index.model()->data(index.model()->index(index.row(), 2), Qt::EditRole).toInt();
// Find which triplettype the triplet is
const int oldCookedModeType = m_cookedModeTypeComboBox->currentIndex();
switch (modeExt) {
case 0x04:
m_cookedModeTypeComboBox->setCurrentIndex(0);
break;
case 0x00:
case 0x01:
case 0x07:
case 0x18:
m_cookedModeTypeComboBox->setCurrentIndex(1);
break;
case 0x20 ... 0x23:
case 0x27 ... 0x29:
case 0x2b ... 0x3f:
m_cookedModeTypeComboBox->setCurrentIndex(2);
break;
case 0x10 ... 0x13:
case 0x15 ... 0x17:
m_cookedModeTypeComboBox->setCurrentIndex(3);
break;
case 0x1f:
m_cookedModeTypeComboBox->setCurrentIndex(4);
break;
default:
m_cookedModeTypeComboBox->setCurrentIndex(5);
}
// If the triplettype has changed, update the triplet mode combobox
if (oldCookedModeType != m_cookedModeTypeComboBox->currentIndex())
updateCookedModeFromCookedType(-1);
for (int i=0; i<m_cookedModeComboBox->count(); i++)
if (m_cookedModeComboBox->itemData(i) == modeExt) {
m_cookedModeComboBox->blockSignals(true);
m_cookedModeComboBox->setCurrentIndex(i);
m_cookedModeComboBox->blockSignals(false);
break;
}
updateCookedTripletParameters(index);
}
void X26DockWidget::updateCookedModeFromCookedType(const int value)
{
while (m_cookedModeComboBox->count() > 0)
m_cookedModeComboBox->removeItem(0);
// When called as a slot, "value" parameter would be the same as this currentIndex
switch (m_cookedModeTypeComboBox->currentIndex()) {
case 1:
m_cookedModeComboBox->addItem("select...", -1);
m_cookedModeComboBox->addItem("Full screen colour", 0x00);
m_cookedModeComboBox->addItem("Full row colour", 0x01);
m_cookedModeComboBox->addItem("Address row 0", 0x07);
m_cookedModeComboBox->addItem("DRCS mode", 0x18);
break;
case 2:
m_cookedModeComboBox->addItem("select...", -1);
m_cookedModeComboBox->addItem("Foreground colour", 0x20);
m_cookedModeComboBox->addItem("G1 block mosaic", 0x21);
m_cookedModeComboBox->addItem("G3 at L 1.5", 0x22);
m_cookedModeComboBox->addItem("Background colour", 0x23);
m_cookedModeComboBox->addItem("Flash functions", 0x27);
m_cookedModeComboBox->addItem("Mod G0 and G2", 0x28);
m_cookedModeComboBox->addItem("G0 character", 0x29);
m_cookedModeComboBox->addItem("G3 at L 2.5", 0x2b);
m_cookedModeComboBox->addItem("Display attrs", 0x2c);
m_cookedModeComboBox->addItem("DRCS character", 0x2d);
m_cookedModeComboBox->addItem("Font style", 0x2e);
m_cookedModeComboBox->addItem("G2 character", 0x2f);
for (int i=0; i<16; i++)
m_cookedModeComboBox->addItem(QString("G0 diactricial %1").arg(i), 0x30+i);
break;
case 3:
m_cookedModeComboBox->addItem("select...", -1);
m_cookedModeComboBox->addItem("Origin modifier", 0x10);
m_cookedModeComboBox->addItem("Invoke active obj", 0x11);
m_cookedModeComboBox->addItem("Invoke adaptive obj", 0x12);
m_cookedModeComboBox->addItem("Invoke passive obj", 0x13);
m_cookedModeComboBox->addItem("Define active obj", 0x15);
m_cookedModeComboBox->addItem("Define adaptive obj", 0x16);
m_cookedModeComboBox->addItem("Define passive obj", 0x17);
break;
case 5:
m_cookedModeComboBox->addItem("select...", -1);
m_cookedModeComboBox->addItem("Origin and Source", 0x08);
m_cookedModeComboBox->addItem("Month and day", 0x09);
m_cookedModeComboBox->addItem("Row + start hours", 0x0a);
m_cookedModeComboBox->addItem("Row + end hours", 0x0b);
m_cookedModeComboBox->addItem("Row + time offset", 0x0c);
m_cookedModeComboBox->addItem("Series ID and code", 0x0d);
m_cookedModeComboBox->addItem("Col + start/end mins", 0x26);
m_cookedModeComboBox->addItem("Reserved row 0x02", 0x02);
m_cookedModeComboBox->addItem("Reserved row 0x03", 0x03);
m_cookedModeComboBox->addItem("Reserved row 0x05", 0x05);
m_cookedModeComboBox->addItem("Reserved row 0x06", 0x06);
m_cookedModeComboBox->addItem("Reserved row 0x0e", 0x0e);
m_cookedModeComboBox->addItem("Reserved row 0x0f", 0x0f);
m_cookedModeComboBox->addItem("Reserved row 0x14", 0x14);
m_cookedModeComboBox->addItem("Reserved row 0x19", 0x19);
m_cookedModeComboBox->addItem("Reserved row 0x1a", 0x1a);
m_cookedModeComboBox->addItem("Reserved row 0x1b", 0x1b);
m_cookedModeComboBox->addItem("Reserved row 0x1c", 0x1c);
m_cookedModeComboBox->addItem("Reserved row 0x1d", 0x1d);
m_cookedModeComboBox->addItem("Reserved row 0x1e", 0x1e);
m_cookedModeComboBox->addItem("Reserved col 0x04", 0x04);
m_cookedModeComboBox->addItem("Reserved col 0x05", 0x05);
m_cookedModeComboBox->addItem("Reserved col 0x0a", 0x0a);
break;
case 0:
// When called as a slot the user set the combobox themself, so set the triplet mode immediately
if (value != -1) {
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 2), 4, Qt::EditRole);
updateAllRawTripletSpinBoxes(m_x26View->currentIndex());
updateCookedTripletParameters(m_x26View->currentIndex());
}
break;
case 4:
if (value != -1) {
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 2), 31, Qt::EditRole);
updateAllRawTripletSpinBoxes(m_x26View->currentIndex());
updateCookedTripletParameters(m_x26View->currentIndex());
}
break;
}
}
void X26DockWidget::updateCookedTripletParameters(const QModelIndex &index)
{
const int modeExt = index.model()->data(index.model()->index(index.row(), 2), Qt::EditRole).toInt();
switch (modeExt) {
case 0x04: // Set active position
case 0x10: // Origin modifier
m_tripletParameterStackedLayout->setCurrentIndex(0);
break;
case 0x01: // Full row colour
case 0x07: // Address row 0
m_fullRowColourThisRowOnlyRadioButton->blockSignals(true);
m_fullRowColourDownToBottomRadioButton->blockSignals(true);
m_fullRowColourThisRowOnlyRadioButton->setChecked(!index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+2).toBool());
m_fullRowColourDownToBottomRadioButton->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+2).toBool());
m_fullRowColourThisRowOnlyRadioButton->blockSignals(false);
m_fullRowColourDownToBottomRadioButton->blockSignals(false);
// fall-through
case 0x00: // Full screen colour
case 0x20: // Foreground colour
case 0x23: // Background colour
m_fullRowColourThisRowOnlyRadioButton->setVisible((modeExt == 0x01) || (modeExt == 0x07));
m_fullRowColourDownToBottomRadioButton->setVisible((modeExt == 0x01) || (modeExt == 0x07));
m_colourComboBox->blockSignals(true);
m_colourComboBox->setCurrentIndex(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toInt());
m_colourComboBox->blockSignals(false);
m_tripletParameterStackedLayout->setCurrentIndex(1);
break;
case 0x21: // G1 character
case 0x22: // G3 character at Level 1.5
case 0x29: // G0 character
case 0x2b: // G3 character at Level 2.5
case 0x2f ... 0x3f: // G2 character, G0 character with diacritical
case 0x28: // TODO replace with dedicated parameters - Modified G0 and G2 designation
m_characterCodeSpinBox->blockSignals(true);
m_characterCodeSpinBox->setMinimum(modeExt == 0x28 ? 0x00 : 0x20);
m_characterCodeSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toInt());
m_characterCodeSpinBox->blockSignals(false);
m_tripletParameterStackedLayout->setCurrentIndex(2);
break;
case 0x27: // Flash functions
m_flashModeComboBox->blockSignals(true);
m_flashRateComboBox->blockSignals(true);
m_flashModeComboBox->setCurrentIndex(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toInt());
m_flashRateComboBox->setCurrentIndex(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+2).toInt());
m_flashModeComboBox->blockSignals(false);
m_flashRateComboBox->blockSignals(false);
m_tripletParameterStackedLayout->setCurrentIndex(3);
break;
case 0x2c: // Display attributes
m_textSizeComboBox->blockSignals(true);
m_displayAttributeBoxingCheckBox->blockSignals(true);
m_displayAttributeConcealCheckBox->blockSignals(true);
m_displayAttributeInvertCheckBox->blockSignals(true);
m_displayAttributeUnderlineCheckBox->blockSignals(true);
m_textSizeComboBox->setCurrentIndex(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toInt());
m_displayAttributeBoxingCheckBox->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+2).toBool());
m_displayAttributeConcealCheckBox->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+3).toBool());
m_displayAttributeInvertCheckBox->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+4).toBool());
m_displayAttributeUnderlineCheckBox->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+5).toBool());
m_textSizeComboBox->blockSignals(false);
m_displayAttributeBoxingCheckBox->blockSignals(false);
m_displayAttributeConcealCheckBox->blockSignals(false);
m_displayAttributeInvertCheckBox->blockSignals(false);
m_displayAttributeUnderlineCheckBox->blockSignals(false);
m_tripletParameterStackedLayout->setCurrentIndex(4);
break;
case 0x11 ... 0x13: // Invoke object
case 0x15 ... 0x17: // Define object
if (index.model()->data(index.model()->index(index.row(), 1), Qt::UserRole).toInt() & 0x04) {
// Define object
m_objectSourceComboBox->setVisible(false);
m_objectRequiredAtL2p5CheckBox->setVisible(true);
m_objectRequiredAtL3p5CheckBox->setVisible(true);
m_objectRequiredAtL2p5CheckBox->blockSignals(true);
m_objectRequiredAtL3p5CheckBox->blockSignals(true);
m_objectRequiredAtL2p5CheckBox->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toBool());
m_objectRequiredAtL3p5CheckBox->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+4).toBool());
m_objectRequiredAtL2p5CheckBox->blockSignals(false);
m_objectRequiredAtL3p5CheckBox->blockSignals(false);
} else {
// Invoke object
m_objectRequiredAtL2p5CheckBox->setVisible(false);
m_objectRequiredAtL3p5CheckBox->setVisible(false);
m_objectSourceComboBox->setVisible(true);
}
m_objectSourceComboBox->blockSignals(true);
// BUG we're only dealing with Local Object Definitions at the moment!
if (index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toInt() == 0 || (index.model()->data(index.model()->index(index.row(), 1), Qt::UserRole).toInt() & 0x04)) {
// if (triplet.objectSource() == X26Triplet::LocalObjectSource) {
m_objectSourceComboBox->setCurrentIndex(0);
m_invokeObjectSourceStackedLayout->setCurrentIndex(0);
m_invokeLocalObjectDesignationCodeSpinBox->blockSignals(true);
m_invokeLocalObjectTripletNumberSpinBox->blockSignals(true);
m_invokeLocalObjectDesignationCodeSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+2).toInt());
m_invokeLocalObjectTripletNumberSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+3).toInt());
m_invokeLocalObjectDesignationCodeSpinBox->blockSignals(false);
m_invokeLocalObjectTripletNumberSpinBox->blockSignals(false);
} else { // if (triplet.objectSource() != X26Triplet::IllegalObjectSource) {
m_objectSourceComboBox->setCurrentIndex(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toInt());
m_invokeObjectSourceStackedLayout->setCurrentIndex(1);
m_invokePOPSubPageSpinBox->blockSignals(true);
m_invokePOPPacketNumberSpinBox->blockSignals(true);
m_invokePOPTripletNumberComboBox->blockSignals(true);
m_invokePOPPointerBitsComboBox->blockSignals(true);
m_invokePOPSubPageSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+2).toInt());
m_invokePOPPacketNumberSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+3).toInt());
while (m_invokePOPTripletNumberComboBox->count() > 0)
m_invokePOPTripletNumberComboBox->removeItem(0);
for (int i=0; i<4; i++)
m_invokePOPTripletNumberComboBox->addItem(QString("Triplet %1").arg(i*3+(modeExt & 0x03)));
m_invokePOPTripletNumberComboBox->setCurrentIndex(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+4).toInt());
m_invokePOPPointerBitsComboBox->setCurrentIndex(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+5).toInt());
m_invokePOPSubPageSpinBox->blockSignals(false);
m_invokePOPPacketNumberSpinBox->blockSignals(false);
m_invokePOPTripletNumberComboBox->blockSignals(false);
m_invokePOPPointerBitsComboBox->blockSignals(false);
}
m_objectSourceComboBox->blockSignals(false);
m_tripletParameterStackedLayout->setCurrentIndex(5);
break;
case 0x18: // DRCS mode
m_DRCSModeRequiredAtL2p5CheckBox->blockSignals(true);
m_DRCSModeRequiredAtL3p5CheckBox->blockSignals(true);
m_DRCSModeGlobalRadioButton->blockSignals(true);
m_DRCSModeNormalRadioButton->blockSignals(true);
m_DRCSModeSubPageSpinBox->blockSignals(true);
m_DRCSModeRequiredAtL2p5CheckBox->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toBool());
m_DRCSModeRequiredAtL3p5CheckBox->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+2).toBool());
m_DRCSModeGlobalRadioButton->setChecked(!index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+3).toBool());
m_DRCSModeNormalRadioButton->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+3).toBool());
m_DRCSModeSubPageSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+4).toInt());
m_DRCSModeRequiredAtL2p5CheckBox->blockSignals(false);
m_DRCSModeRequiredAtL3p5CheckBox->blockSignals(false);
m_DRCSModeGlobalRadioButton->blockSignals(false);
m_DRCSModeNormalRadioButton->blockSignals(false);
m_DRCSModeSubPageSpinBox->blockSignals(false);
m_tripletParameterStackedLayout->setCurrentIndex(6);
break;
case 0x2d: // DRCS character
m_DRCSCharacterGlobalRadioButton->blockSignals(true);
m_DRCSCharacterNormalRadioButton->blockSignals(true);
m_DRCSCharacterCodeSpinBox->blockSignals(true);
m_DRCSCharacterGlobalRadioButton->setChecked(!index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toBool());
m_DRCSCharacterNormalRadioButton->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toBool());
m_DRCSCharacterCodeSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+2).toInt());
m_DRCSCharacterGlobalRadioButton->blockSignals(false);
m_DRCSCharacterNormalRadioButton->blockSignals(false);
m_DRCSCharacterCodeSpinBox->blockSignals(false);
m_tripletParameterStackedLayout->setCurrentIndex(7);
break;
case 0x2e: // Font style
m_fontStyleProportionalCheckBox->blockSignals(true);
m_fontStyleBoldCheckBox->blockSignals(true);
m_fontStyleItalicCheckBox->blockSignals(true);
m_fontStyleRowsSpinBox->blockSignals(true);
m_fontStyleProportionalCheckBox->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toBool());
m_fontStyleBoldCheckBox->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+2).toBool());
m_fontStyleItalicCheckBox->setChecked(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+3).toBool());
m_fontStyleRowsSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+4).toInt());
m_fontStyleProportionalCheckBox->blockSignals(false);
m_fontStyleBoldCheckBox->blockSignals(false);
m_fontStyleItalicCheckBox->blockSignals(false);
m_fontStyleRowsSpinBox->blockSignals(false);
m_tripletParameterStackedLayout->setCurrentIndex(8);
break;
case 0x1f: // Termination marker
m_terminationMarkerPageTypeComboBox->blockSignals(true);
m_terminationMarkerMoreFollowsCheckBox->blockSignals(true);
m_terminationMarkerPageTypeComboBox->setCurrentIndex(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toInt());
m_terminationMarkerMoreFollowsCheckBox->setChecked(!index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+2).toBool());
m_terminationMarkerPageTypeComboBox->blockSignals(false);
m_terminationMarkerMoreFollowsCheckBox->blockSignals(false);
m_tripletParameterStackedLayout->setCurrentIndex(9);
break;
default: // PDC and reserved triplet, (mis)use character spinbox
m_characterCodeSpinBox->blockSignals(true);
m_characterCodeSpinBox->setMinimum(0);
m_characterCodeSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+1).toInt());
m_characterCodeSpinBox->blockSignals(false);
m_tripletParameterStackedLayout->setCurrentIndex(2);
break;
}
// Now deal with cooked row and column spinboxes
m_cookedRowSpinBox->blockSignals(true);
m_cookedColumnSpinBox->blockSignals(true);
QVariant rowVariant = index.model()->data(index.model()->index(index.row(), 0), Qt::EditRole);
if (rowVariant.isNull()) {
m_cookedRowSpinBox->setEnabled(false);
m_cookedRowSpinBox->setValue(0);
} else {
m_cookedRowSpinBox->setEnabled(true);
if (index.model()->data(index.model()->index(index.row(), 2), Qt::EditRole) == 0x10)
m_cookedRowSpinBox->setRange(0, 23);
else
m_cookedRowSpinBox->setRange(1, 24);
m_cookedRowSpinBox->setValue(rowVariant.toInt());
}
QVariant columnVariant = index.model()->data(index.model()->index(index.row(), 1), Qt::EditRole);
if (columnVariant.isNull()) {
m_cookedColumnSpinBox->setEnabled(false);
m_cookedColumnSpinBox->setValue(0);
} else {
m_cookedColumnSpinBox->setEnabled(true);
if (index.model()->data(index.model()->index(index.row(), 2), Qt::EditRole) == 0x10)
m_cookedColumnSpinBox->setMaximum(71);
else
m_cookedColumnSpinBox->setMaximum(39);
m_cookedColumnSpinBox->setValue(columnVariant.toInt());
}
m_cookedRowSpinBox->blockSignals(false);
m_cookedColumnSpinBox->blockSignals(false);
}
void X26DockWidget::updateAllRawTripletSpinBoxes(const QModelIndex &index)
{
m_rawTripletAddressSpinBox->setEnabled(true);
m_rawTripletDataSpinBox->setEnabled(true);
@@ -140,26 +848,79 @@ void X26DockWidget::updateRawTripletWidgets(const QModelIndex &index)
m_rawTripletModeSpinBox->blockSignals(false);
m_rawTripletDataSpinBox->blockSignals(false);
}
void X26DockWidget::rawTripletAddressSpinBoxChanged(int newValue)
void X26DockWidget::updateRawTripletDataSpinBox(const QModelIndex &index)
{
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 0), newValue, Qt::UserRole);
m_rawTripletDataSpinBox->blockSignals(true);
m_rawTripletDataSpinBox->setValue(index.model()->data(index.model()->index(index.row(), 2), Qt::UserRole).toInt());
m_rawTripletDataSpinBox->blockSignals(false);
}
void X26DockWidget::rawTripletModeSpinBoxChanged(int newValue)
void X26DockWidget::rawTripletAddressSpinBoxChanged(int value)
{
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 1), newValue, Qt::UserRole);
if (!m_x26View->currentIndex().isValid())
return;
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 0), value, Qt::UserRole);
updateAllCookedTripletWidgets(m_x26View->currentIndex());
}
void X26DockWidget::rawTripletDataSpinBoxChanged(int newValue)
void X26DockWidget::rawTripletModeSpinBoxChanged(int value)
{
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 2), newValue, Qt::UserRole);
if (!m_x26View->currentIndex().isValid())
return;
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 1), value, Qt::UserRole);
updateAllCookedTripletWidgets(m_x26View->currentIndex());
}
void X26DockWidget::tripletDataChanged(int newValue, int bitMask, int bitShift)
void X26DockWidget::rawTripletDataSpinBoxChanged(int value)
{
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 2), (m_x26Model->data(m_x26Model->index(m_x26View->currentIndex().row(), 2), Qt::UserRole).toInt() & bitMask) | (newValue << bitShift), Qt::UserRole);
updateRawTripletWidgets(m_x26View->currentIndex());
if (!m_x26View->currentIndex().isValid())
return;
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 2), value, Qt::UserRole);
updateAllCookedTripletWidgets(m_x26View->currentIndex());
}
void X26DockWidget::cookedRowSpinBoxChanged(const int value)
{
if (!m_x26View->currentIndex().isValid())
return;
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 0), value, Qt::EditRole);
updateAllRawTripletSpinBoxes(m_x26View->currentIndex());
}
void X26DockWidget::cookedColumnSpinBoxChanged(const int value)
{
if (!m_x26View->currentIndex().isValid())
return;
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 1), value, Qt::EditRole);
updateAllRawTripletSpinBoxes(m_x26View->currentIndex());
}
void X26DockWidget::cookedModeComboBoxChanged(const int value)
{
if (!m_x26View->currentIndex().isValid())
return;
// Avoid "select..."
if (m_cookedModeComboBox->itemData(value) == -1)
return;
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 2), m_cookedModeComboBox->itemData(value).toInt(), Qt::EditRole);
updateCookedTripletParameters(m_x26View->currentIndex());
}
void X26DockWidget::updateModelFromCookedWidget(const int value, const int role)
{
m_x26Model->setData(m_x26Model->index(m_x26View->currentIndex().row(), 0), value, role);
updateAllRawTripletSpinBoxes(m_x26View->currentIndex());
}
void X26DockWidget::insertTriplet()
{
QModelIndex index = m_x26View->currentIndex();

View File

@@ -27,6 +27,7 @@
#include <QPushButton>
#include <QRadioButton>
#include <QSpinBox>
#include <QStackedLayout>
#include <QTableView>
#include "mainwidget.h"
@@ -46,17 +47,48 @@ public slots:
void loadX26List();
void unloadX26List();
void rowClicked(const QModelIndex &);
void updateRawTripletWidgets(const QModelIndex &);
void updateAllRawTripletSpinBoxes(const QModelIndex &);
void updateRawTripletDataSpinBox(const QModelIndex &);
void updateAllCookedTripletWidgets(const QModelIndex &);
void updateCookedModeFromCookedType(const int);
void updateCookedTripletParameters(const QModelIndex &);
void rawTripletAddressSpinBoxChanged(int);
void rawTripletModeSpinBoxChanged(int);
void rawTripletDataSpinBoxChanged(int);
void tripletDataChanged(int, int=0, int=0);
void cookedRowSpinBoxChanged(const int);
void cookedColumnSpinBoxChanged(const int);
void cookedModeComboBoxChanged(const int);
void updateModelFromCookedWidget(const int, const int);
private:
QTableView *m_x26View;
X26Model *m_x26Model;
// "Temporary" widgets to edit raw triplet values
QComboBox *m_cookedModeTypeComboBox;
QSpinBox *m_cookedRowSpinBox, *m_cookedColumnSpinBox;
QComboBox *m_cookedModeComboBox;
QSpinBox *m_rawTripletAddressSpinBox, *m_rawTripletModeSpinBox, *m_rawTripletDataSpinBox;
QStackedLayout *m_rawOrCookedStackedLayout;
QComboBox *m_colourComboBox;
QRadioButton *m_fullRowColourThisRowOnlyRadioButton, *m_fullRowColourDownToBottomRadioButton;
QSpinBox *m_characterCodeSpinBox;
QComboBox *m_flashModeComboBox, *m_flashRateComboBox;
QComboBox *m_textSizeComboBox;
QCheckBox *m_displayAttributeBoxingCheckBox, *m_displayAttributeConcealCheckBox, *m_displayAttributeInvertCheckBox, *m_displayAttributeUnderlineCheckBox;
QComboBox *m_objectSourceComboBox;
QCheckBox *m_objectRequiredAtL2p5CheckBox, *m_objectRequiredAtL3p5CheckBox;
QSpinBox *m_invokeLocalObjectDesignationCodeSpinBox, *m_invokeLocalObjectTripletNumberSpinBox;
QSpinBox *m_invokePOPSubPageSpinBox, *m_invokePOPPacketNumberSpinBox;
QComboBox *m_invokePOPTripletNumberComboBox, *m_invokePOPPointerBitsComboBox;
QStackedLayout *m_invokeObjectSourceStackedLayout, *m_tripletParameterStackedLayout;
QCheckBox *m_DRCSModeRequiredAtL2p5CheckBox, *m_DRCSModeRequiredAtL3p5CheckBox;
QRadioButton *m_DRCSModeGlobalRadioButton, *m_DRCSModeNormalRadioButton;
QSpinBox *m_DRCSModeSubPageSpinBox;
QRadioButton *m_DRCSCharacterGlobalRadioButton, *m_DRCSCharacterNormalRadioButton;
QSpinBox *m_DRCSCharacterCodeSpinBox;
QCheckBox *m_fontStyleProportionalCheckBox, *m_fontStyleBoldCheckBox, *m_fontStyleItalicCheckBox;
QSpinBox *m_fontStyleRowsSpinBox;
QComboBox *m_terminationMarkerPageTypeComboBox;
QCheckBox *m_terminationMarkerMoreFollowsCheckBox;
QPushButton *m_insertPushButton, *m_deletePushButton;
TeletextWidget *m_parentMainWidget;

View File

@@ -67,7 +67,7 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
// Show row number only if address part of triplet actually represents a row
// i.e. Full row colour, Set Active Position and Origin Modifier
if (!m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
return "";
return QVariant();
// For Origin Modifier address of 40 refers to same row, so show it as 0
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).mode() == 0x10) {
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() == 40)
@@ -78,7 +78,7 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).mode() == 0x01 || m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).mode() == 0x04)
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).addressRow();
else
return "";
return QVariant();
case 1:
if (!m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).addressColumn();
@@ -86,20 +86,18 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
else if (mode == 0x04 || mode == 0x10)
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data();
else
return "";
return QVariant();
}
if (!m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
mode |= 0x20;
QString result;
if (role == Qt::DisplayRole)
switch (index.column()) {
case 2:
if (!m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
mode |= 0x20;
if (role == Qt::DisplayRole) {
if (index.column() == 2)
return (modeTripletName[mode]);
case 3:
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
// Row address group
// Column 3 - describe effects of data/address triplet parameters in plain English
switch (mode) {
case 0x01: // Full row colour
case 0x07: // Address row 0
@@ -117,7 +115,7 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
case 0x04: // Set Active Position
case 0x10: // Origin Modifier
// For Set Active Position and Origin Modifier, data is the column, so return blank
return "";
return QVariant();
case 0x11 ... 0x13: // Invoke object
switch (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x18) {
case 0x08:
@@ -128,7 +126,7 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
case 0x18:
result = "GPOP";
break;
// case 0x00: won'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()->localEnhance.at(index.row()).data() & 0x0f).arg((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x03) + 1).arg(((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60) >> 5) * 3 + (mode & 0x03)));
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x10)
@@ -148,7 +146,7 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
case 0x18:
result.append("L2.5 and 3.5");
break;
// case 0x00: won'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
}
return result;
case 0x18: // DRCS mode
@@ -199,24 +197,20 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
break;
case 0x08 ... 0x0d: // PDC
return QString("0x%1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data(), 2, 16, QChar('0'));
}
else
// Column address group
switch (mode) {
case 0x00: // Foreground colour
case 0x03: // Background colour
case 0x20: // Foreground colour
case 0x23: // Background colour
if (!(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60))
return QString("CLUT %1:%2").arg((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x18) >> 3).arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x07);
break;
case 0x01: // G1 mosaic character
case 0x02: // G3 mosaic character at level 1.5
case 0x09: // G0 character
case 0x0b: // G3 mosaic character at level >=2.5
case 0x0f ... 0x1f: // G2 character or G0 diacrtitical mark
case 0x21: // G1 mosaic character
case 0x22: // G3 mosaic character at level 1.5
case 0x29: // G0 character
case 0x2b: // G3 mosaic character at level >=2.5
case 0x2f ... 0x3f: // G2 character or G0 diacrtitical mark
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() >= 0x20)
return QString("0x%1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data(), 2, 16);
break;
case 0x07: // Flash functions
case 0x27: // Flash functions
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() < 0x18) {
switch (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x03) {
case 0x00:
@@ -255,8 +249,8 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
return result;
}
break;
//TODO case 0x08: // G0 and G2 designation
case 0x0c: // Display attributes
//TODO case 0x28: // G0 and G2 designation
case 0x2c: // Display attributes
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x02)
result.append("Boxing ");
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x04)
@@ -285,11 +279,11 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
break;
}
return result;
case 0x0d: // DRCS character
case 0x2d: // DRCS character
result = (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x40) == 0x40 ? "Normal" : "Global";
result.append(QString(": %1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x3f));
return result;
case 0x0e: // Font style
case 0x2e: // Font style
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x01)
result.append("Proportional ");
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x02)
@@ -303,7 +297,8 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
result.chop(1);
result.append(QString(", %1 row(s)").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() >> 4));
return result;
case 0x06: // PDC
case 0x28: // Modified G0 and G2 character set
case 0x26: // PDC
return QString("0x%1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data(), 2, 16, QChar('0'));
default: // Reserved
return QString("Reserved 0x%1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data(), 2, 16, QChar('0'));
@@ -312,82 +307,148 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
return QString("Reserved 0x%1").arg(m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data(), 2, 16, QChar('0'));
}
if (role == Qt::EditRole)
switch (index.column()) {
case 2:
if (role == Qt::EditRole && index.column() == 2) {
if (!m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
mode |= 0x20;
return mode;
case 3:
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
// Row address group
}
if (role <= Qt::UserRole)
return QVariant();
switch (role) {
case Qt::UserRole+1:
switch (mode) {
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 m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x1f;
case 0x11 ... 0x13: // Invoke object
// Local, POP or GPOP
// Object source: Local, POP or GPOP
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x18) >> 3) - 1;
break;
case 0x15 ... 0x17: // Define object
// Required at level 2.5 and/or 3.5
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x18) >> 3) - 1;
// Required at level 2.5
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x08) == 0x08;
case 0x18: // DRCS mode
// Required at level 2.5
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x10) == 0x10;
case 0x1f: // Termination
// Intermed POP subpage|Last POP subpage|Local Object|Local enhance
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x06) >> 1);
default:
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data();
}
else
// Column address group
switch (mode) {
case 0x00: // Foreground colour
case 0x03: // Background colour
// Colour index
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x1f;
case 0x07: // Flash functions
case 0x27: // Flash functions
// Flash mode
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x03;
case 0x0c: // Display attributes
// underline/separated, invert, conceal, boxing/window
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x06) >> 1) | ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x30) >> 2);
case 0x0e: // Font style
// Proportional, Bold, Italics
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x07;
case 0x2c: // Display attributes
// Text size
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x01) | ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x40) >> 5);
case 0x2d: // DRCS character
// Normal or Global
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x40) == 0x40;
case 0x2e: // Font style
// Proportional
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x01) == 0x01;
default:
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data();
}
case 4:
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
// Row address group
break;
case Qt::UserRole+2:
switch (mode) {
case 0x01: // Full row colour
case 0x07: // Address row 0
// "this row only" or "down to bottom"
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60) == 0x60) ? 1 : 0;
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60) == 0x60;
case 0x11 ... 0x13: // Invoke object
// Object source
//TODO POP and GPOP, if ((x26Triplet.address() & 0x08) == 0x08)
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() | ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 1) << 7);
if ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x08) == 0x08)
// Local object: Designation code
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x01) << 3) | ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x70) >> 4);
else
// (G)POP object: Subpage
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x0f;
break;
case 0x15 ... 0x17: // Define object
// Local object: Designation code
return ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x01) << 3) | ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x70) >> 4);
case 0x18: // DRCS mode
// Required at level 3.5
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x20) == 0x20;
case 0x1f: // Termination
// More follows/Last
// return entire value as dropdown text changes depending on setting
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x07;
}
else
// Column address group
switch (mode) {
case 0x07: // Flash functions
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x01) == 0x01;
case 0x27: // Flash functions
// Flash rate and phase
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() >> 2;
case 0x0c: // Display attributes
// Text size
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x01) | ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x40) >> 5);
case 0x0e: // Font style
case 0x2c: // Display attributes
// Boxing/window
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x02) == 0x02;
case 0x2d: // DRCS character
// Character number
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x3f;
case 0x2e: // Font style
// Bold
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x02) == 0x02;
}
break;
case Qt::UserRole+3:
switch (mode) {
case 0x11 ... 0x13: // Invoke object
if ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x08) == 0x08)
// Local object: Triplet number
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x0f;
else
// (G)POP object: Pointer location
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x03) + 1;
break;
case 0x15 ... 0x17: // Define object
// Local object: Triplet number
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x0f;
case 0x18: // DRCS mode
// Normal or Global
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x40) == 0x40;
case 0x2c: // Display attributes
// Conceal
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x04) == 0x04;
case 0x2e: // Font style
// Italics
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x04) == 0x04;
}
break;
case Qt::UserRole+4:
switch (mode) {
case 0x11 ... 0x13: // Invoke object
// (G)POP object: Triplet number
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() >> 5;
case 0x15 ... 0x17: // Define object
// Required at level 3.5
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x10) == 0x10;
case 0x18: // DRCS mode
// Subpage
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x0f;
case 0x2c: // Display attributes
// Invert
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x10) == 0x10;
case 0x2e: // Font style
// Number of rows
return m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() >> 4;
}
break;
case Qt::UserRole+5:
switch (mode) {
case 0x11 ... 0x13: // Invoke object
// (G)POP object: Pointer position
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x10) >> 4;
case 0x2c: // Display attributes
// Underline/Separated
return (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x20) == 0x20;
}
break;
}
return QVariant();
@@ -398,8 +459,7 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
if (!index.isValid())
return false;
int mode = m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).mode();
// Raw address, mode and data values
if (role == Qt::UserRole && value.canConvert<int>() && index.column() <= 2) {
int intValue = value.toInt();
switch (index.column()) {
@@ -413,10 +473,14 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(intValue);
break;
}
emit dataChanged(createIndex(index.row(), 0), createIndex(index.row(), 4), {role});
emit dataChanged(createIndex(index.row(), 0), createIndex(index.row(), 3), {role});
m_parentMainWidget->refreshPage();
return true;
}
int mode = m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).modeExt();
// Row, column and triplet mode
if (role == Qt::EditRole && value.canConvert<int>()) {
int intValue = value.toInt();
if (intValue < 0)
@@ -425,17 +489,27 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
case 0:
if (intValue > 24)
return false;
if (((mode == 0x04) || (mode == 0x01)) && intValue == 0)
return false;
if (mode == 0x10)
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress(intValue + 40);
else
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddressRow(intValue);
break;
emit dataChanged(index, index, {role});
m_parentMainWidget->refreshPage();
return true;
case 1:
if (intValue > 39)
// Origin modifier allows columns up to 71
if (intValue > (mode == 0x10 ? 71 : 39))
return false;
// For Set Active Position and Origin Modifier, data is the column
if (mode == 0x04 || mode == 0x10)
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(intValue);
else
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddressColumn(intValue);
break;
emit dataChanged(index, index, {role});
m_parentMainWidget->refreshPage();
return true;
case 2:
if (intValue < 0x20 && !m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet()) {
// Changing mode from column triplet to row triplet
@@ -448,55 +522,73 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(0);
}
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setMode(intValue & 0x1f);
break;
case 3:
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
// Row address group
emit dataChanged(createIndex(index.row(), 0), createIndex(index.row(), 3), {role});
m_parentMainWidget->refreshPage();
return true;
}
return false;
}
if (role <= Qt::UserRole || !value.canConvert<int>())
return false;
int intValue = value.toInt();
if (intValue < 0)
return false;
// Triplet data
switch (role) {
case Qt::UserRole+1:
switch (mode) {
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
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x60) | intValue);
break;
case 0x04: // Set Active Position
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(intValue);
break;
// case 0x04: // Set Active Position - data is the column
// m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(intValue);
// break;
case 0x11 ... 0x13: // Invoke object
// Local, POP or GPOP
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x67) | ((intValue+1) << 3));
// Object source: Local, POP or GPOP
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x27) | ((intValue+1) << 3));
break;
case 0x15 ... 0x17: // Define object
// required at level 2.5 and/or 3.5
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x67) | ((intValue+1) << 3));
// Required at level 2.5
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x37) | (intValue << 2));
break;
case 0x18: // DRCS Mode
// Required at level 2.5
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x6f) | (intValue << 3));
break;
case 0x1f: // Termination
// Intermed POP subpage|Last POP subpage|Local Object|Local enhance
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x01) | (intValue << 1));
break;
}
else
// Column address group
switch (mode) {
case 0x07: // Flash functions
case 0x27: // Flash functions
// Flash mode
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x1c) | intValue);
break;
case 0x0c: // Display attributes
// underline/separated, invert, conceal, boxing/window
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x41) | ((intValue & 0x0c) << 2) | ((intValue & 0x03) << 1));
case 0x2c: // Display attributes
// Text size
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x36) | ((intValue & 0x02) << 5) | (intValue & 0x01));
break;
case 0x0e: // Font style
// Proportional, Bold, Italics
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x70) | intValue);
case 0x2d: // DRCS character
// Normal or Global
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x3f) | (intValue << 6));
break;
case 0x2e: // Font style
// Proportional
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x7e) | intValue);
break;
default:
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(intValue);
}
break;
case 4:
if (m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).isRowTriplet())
// Row address group
case Qt::UserRole+2:
switch (mode) {
case 0x00: // Full screen colour
case 0x01: // Full row colour
@@ -505,38 +597,117 @@ bool X26Model::setData(const QModelIndex &index, const QVariant &value, int role
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x1f) | (intValue * 0x60));
break;
case 0x11 ... 0x13: // Invoke object
// Object source
//TODO POP and GPOP, if ((x26Triplet.address() & 0x08) == 0x08)
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData(intValue & 0x7f);
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x3e) | (intValue >> 7));
if ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x08) == 0x08) {
// Local object: Designation code
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x0f) | ((intValue & 0x07) << 4));
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x3e) | (intValue >> 3));
} else
// (G)POP object: Subpage
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x30) | intValue);
break;
case 0x15 ... 0x17: // Define object
// Local object: Designation code
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x0f) | ((intValue & 0x07) << 4));
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x3e) | (intValue >> 3));
break;
case 0x18: // DRCS Mode
// Required at level 3.5
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x5f) | (intValue << 4));
break;
case 0x1f: // Termination
// More follows/Last
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x06) | intValue);
break;
}
else
// Column address group
switch (mode) {
case 0x07: // Flash functions
case 0x27: // Flash functions
// Flash rate and phase
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x03) | (intValue << 2));
break;
case 0x0c: // Display attributes
// Text size
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x36) | ((intValue & 0x02) << 5) | (intValue & 0x01));
case 0x2c: // Display attributes
// Boxing/window
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x7d) | (intValue << 1));
break;
case 0x0e: // Font style
case 0x2d: // DRCS character
// Character number
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x40) | intValue);
break;
case 0x2e: // Font style
// Bold
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x7d) | (intValue << 1));
break;
}
break;
case Qt::UserRole+3:
switch (mode) {
case 0x11 ... 0x13: // Invoke object
if ((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x08) == 0x08)
// Local object: triplet number
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x70) | intValue);
else
// (G)POP object: Pointer location
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x7c) | (intValue - 1));
break;
case 0x15 ... 0x17: // Define object
// Local object: triplet number
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x70) | intValue);
break;
case 0x18: // DRCS Mode
// Normal or Global
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x3f) | (intValue << 6));
break;
case 0x2c: // Display attributes
// Conceal
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x7b) | (intValue << 2));
break;
case 0x2e: // Font style
// Italics
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x7b) | (intValue << 2));
break;
}
break;
case Qt::UserRole+4:
switch (mode) {
case 0x11 ... 0x13: // Invoke object
// (G)POP object: Triplet number
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x1f) | (intValue << 5));
break;
case 0x15 ... 0x17: // Define object
// Required at level 3.5
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setAddress((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).address() & 0x2f) | (intValue << 3));
break;
case 0x18: // DRCS Mode
// Subpage
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x70) | intValue);
break;
case 0x2c: // Display attributes
// Invert
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x6f) | (intValue << 4));
break;
case 0x2e: // Font style
// Number of rows
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x07) | (intValue << 4));
break;
}
break;
case Qt::UserRole+5:
switch (mode) {
case 0x11 ... 0x13: // Invoke object
// (G)POP object: Pointer position
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x6f) | (intValue << 4));
break;
case 0x2c: // Display attributes
// Invert
m_parentMainWidget->document()->currentSubPage()->localEnhance[index.row()].setData((m_parentMainWidget->document()->currentSubPage()->localEnhance.at(index.row()).data() & 0x5f) | (intValue << 5));
break;
}
emit dataChanged(index, index, {role});
break;
}
emit dataChanged(createIndex(index.row(), 0), createIndex(index.row(), 3), {role});
m_parentMainWidget->refreshPage();
return true;
}
return false;
}
QVariant X26Model::headerData(int section, Qt::Orientation orientation, int role) const
@@ -553,7 +724,7 @@ QVariant X26Model::headerData(int section, Qt::Orientation orientation, int role
case 3:
return tr("Data");
default:
return QString("");
return QVariant();
}
} else if (orientation == Qt::Vertical)
return QString("d%1 t%2").arg(section / 13).arg(section % 13);