Show blast-through alphanumerics in G1 character selection
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
CharacterListModel::CharacterListModel(QObject *parent): QAbstractListModel(parent)
|
CharacterListModel::CharacterListModel(QObject *parent): QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
m_characterSet = 0;
|
m_characterSet = 0;
|
||||||
|
m_mosaic = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CharacterListModel::rowCount(const QModelIndex & /*parent*/) const
|
int CharacterListModel::rowCount(const QModelIndex & /*parent*/) const
|
||||||
@@ -58,16 +59,30 @@ QVariant CharacterListModel::data(const QModelIndex &index, int role) const
|
|||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole)
|
||||||
return QString("0x%1").arg(index.row()+0x20, 2, 16);
|
return QString("0x%1").arg(index.row()+0x20, 2, 16);
|
||||||
|
|
||||||
if (role == Qt::DecorationRole)
|
if (role == Qt::DecorationRole) {
|
||||||
|
if (m_mosaic && (index.row()+32) & 0x20)
|
||||||
|
return m_fontBitmap.charBitmap(index.row()+32, 24);
|
||||||
|
else
|
||||||
return m_fontBitmap.charBitmap(index.row()+32, m_characterSet);
|
return m_fontBitmap.charBitmap(index.row()+32, m_characterSet);
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CharacterListModel::setCharacterSet(int characterSet)
|
void CharacterListModel::setCharacterSet(int characterSet)
|
||||||
{
|
{
|
||||||
if (characterSet != m_characterSet) {
|
if (characterSet != m_characterSet || m_mosaic) {
|
||||||
m_characterSet = characterSet;
|
m_characterSet = characterSet;
|
||||||
|
m_mosaic = false;
|
||||||
|
emit dataChanged(createIndex(0, 0), createIndex(95, 0), QVector<int>(Qt::DecorationRole));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CharacterListModel::setG1AndBlastCharacterSet(int characterSet)
|
||||||
|
{
|
||||||
|
if (characterSet != m_characterSet || !m_mosaic) {
|
||||||
|
m_characterSet = characterSet;
|
||||||
|
m_mosaic = true;
|
||||||
emit dataChanged(createIndex(0, 0), createIndex(95, 0), QVector<int>(Qt::DecorationRole));
|
emit dataChanged(createIndex(0, 0), createIndex(95, 0), QVector<int>(Qt::DecorationRole));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -693,7 +708,7 @@ void X26DockWidget::updateAllCookedTripletWidgets(const QModelIndex &index)
|
|||||||
case 0x3f: // G0 character with diacritical
|
case 0x3f: // G0 character with diacritical
|
||||||
m_characterCodeComboBox->blockSignals(true);
|
m_characterCodeComboBox->blockSignals(true);
|
||||||
if (modeExt == 0x21)
|
if (modeExt == 0x21)
|
||||||
m_characterListModel.setCharacterSet(24);
|
m_characterListModel.setG1AndBlastCharacterSet(index.model()->data(index.model()->index(index.row(), 0), Qt::UserRole+3).toInt());
|
||||||
else if (modeExt == 0x22 || modeExt == 0x2b)
|
else if (modeExt == 0x22 || modeExt == 0x2b)
|
||||||
m_characterListModel.setCharacterSet(26);
|
m_characterListModel.setCharacterSet(26);
|
||||||
else
|
else
|
||||||
@@ -1142,6 +1157,8 @@ void X26DockWidget::customMenuRequested(QPoint pos)
|
|||||||
connect(static_cast<TripletFontStyleQMenu *>(customMenu)->rowsAction(i), &QAction::triggered, [=]() { updateModelFromCookedWidget(i, Qt::UserRole+4); updateAllCookedTripletWidgets(index); });
|
connect(static_cast<TripletFontStyleQMenu *>(customMenu)->rowsAction(i), &QAction::triggered, [=]() { updateModelFromCookedWidget(i, Qt::UserRole+4); updateAllCookedTripletWidgets(index); });
|
||||||
break;
|
break;
|
||||||
case 0x21: // G1 mosaic character
|
case 0x21: // G1 mosaic character
|
||||||
|
customMenu = new TripletCharacterQMenu(m_x26Model->data(index.model()->index(index.row(), 2), Qt::UserRole+3).toInt(), true, this);
|
||||||
|
// fall-through
|
||||||
case 0x22: // G3 mosaic character at level 1.5
|
case 0x22: // G3 mosaic character at level 1.5
|
||||||
case 0x2b: // G3 mosaic character at level >=2.5
|
case 0x2b: // G3 mosaic character at level >=2.5
|
||||||
case 0x29: // G0 character
|
case 0x29: // G0 character
|
||||||
@@ -1162,7 +1179,8 @@ void X26DockWidget::customMenuRequested(QPoint pos)
|
|||||||
case 0x3d:
|
case 0x3d:
|
||||||
case 0x3e:
|
case 0x3e:
|
||||||
case 0x3f: // G0 character with diacritical
|
case 0x3f: // G0 character with diacritical
|
||||||
customMenu = new TripletCharacterQMenu(m_x26Model->data(index.model()->index(index.row(), 2), Qt::UserRole+2).toInt(), this);
|
if (!customMenu)
|
||||||
|
customMenu = new TripletCharacterQMenu(m_x26Model->data(index.model()->index(index.row(), 2), Qt::UserRole+2).toInt(), false, this);
|
||||||
|
|
||||||
for (int i=0; i<96; i++)
|
for (int i=0; i<96; i++)
|
||||||
connect(static_cast<TripletCharacterQMenu *>(customMenu)->action(i), &QAction::triggered, [=]() { updateModelFromCookedWidget(i+32, Qt::UserRole+1); updateAllCookedTripletWidgets(index); });
|
connect(static_cast<TripletCharacterQMenu *>(customMenu)->action(i), &QAction::triggered, [=]() { updateModelFromCookedWidget(i+32, Qt::UserRole+1); updateAllCookedTripletWidgets(index); });
|
||||||
|
|||||||
@@ -48,10 +48,12 @@ public:
|
|||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
void setCharacterSet(int characterSet);
|
void setCharacterSet(int characterSet);
|
||||||
|
void setG1AndBlastCharacterSet(int characterSet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TeletextFontBitmap m_fontBitmap;
|
TeletextFontBitmap m_fontBitmap;
|
||||||
int m_characterSet;
|
int m_characterSet;
|
||||||
|
bool m_mosaic;
|
||||||
};
|
};
|
||||||
|
|
||||||
class X26DockWidget : public QDockWidget
|
class X26DockWidget : public QDockWidget
|
||||||
|
|||||||
@@ -130,15 +130,17 @@ void TripletCLUTQMenu::setColour(int i, QColor c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TripletCharacterQMenu::TripletCharacterQMenu(int charSet, QWidget *parent): QMenu(parent)
|
TripletCharacterQMenu::TripletCharacterQMenu(int charSet, bool mosaic, QWidget *parent): QMenu(parent)
|
||||||
{
|
{
|
||||||
QMenu *charRange[6];
|
QMenu *charRange[6];
|
||||||
|
|
||||||
for (int r=0; r<6; r++) {
|
for (int r=0; r<6; r++) {
|
||||||
charRange[r] = this->addMenu(QString("0x%010-0x%01f").arg(r+2));
|
charRange[r] = this->addMenu(QString("0x%010-0x%01f").arg(r+2));
|
||||||
|
|
||||||
|
const int charSetInColumn = (mosaic && ((r & 0x2) == 0)) ? 24 : charSet;
|
||||||
|
|
||||||
for (int c=0; c<16; c++)
|
for (int c=0; c<16; c++)
|
||||||
m_actions[r*16+c] = charRange[r]->addAction(QIcon(m_fontBitmap.charBitmap(r*16+c+32, charSet)), QString("0x%1").arg(r*16+c+32, 2, 16, QChar('0')));
|
m_actions[r*16+c] = charRange[r]->addAction(QIcon(m_fontBitmap.charBitmap(r*16+c+32, charSetInColumn)), QString("0x%1").arg(r*16+c+32, 2, 16, QChar('0')));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ class TripletCharacterQMenu : public QMenu
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TripletCharacterQMenu(int charSet, QWidget *parent = nullptr);
|
TripletCharacterQMenu(int charSet, bool mosaic, QWidget *parent = nullptr);
|
||||||
QAction *action(int n) const { return m_actions[n]; };
|
QAction *action(int n) const { return m_actions[n]; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
11
x26model.cpp
11
x26model.cpp
@@ -379,6 +379,9 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
|
|||||||
// Returning the bitmap as-is doesn't seem to work here
|
// Returning the bitmap as-is doesn't seem to work here
|
||||||
// but putting it inside a QIcon... does?
|
// but putting it inside a QIcon... does?
|
||||||
return QIcon(m_fontBitmap.charBitmap(triplet.data(), 24));
|
return QIcon(m_fontBitmap.charBitmap(triplet.data(), 24));
|
||||||
|
else if (triplet.data() >= 0x20)
|
||||||
|
// Blast-through
|
||||||
|
return QIcon(m_fontBitmap.charBitmap(triplet.data(), m_parentMainWidget->pageDecode()->cellG0CharacterSet(triplet.activePositionRow(), triplet.activePositionColumn())));
|
||||||
break;
|
break;
|
||||||
case 0x22: // G3 mosaic character at level 1.5
|
case 0x22: // G3 mosaic character at level 1.5
|
||||||
case 0x2b: // G3 mosaic character at level >=2.5
|
case 0x2b: // G3 mosaic character at level >=2.5
|
||||||
@@ -472,13 +475,17 @@ QVariant X26Model::data(const QModelIndex &index, int role) const
|
|||||||
break;
|
break;
|
||||||
case 0x21: // G1 character
|
case 0x21: // G1 character
|
||||||
// Qt::UserRole+1 is character number, returned by default below
|
// Qt::UserRole+1 is character number, returned by default below
|
||||||
if (role == Qt::UserRole+2) // Character set
|
switch (role) {
|
||||||
|
case Qt::UserRole+2: // G1 character set
|
||||||
return 24;
|
return 24;
|
||||||
|
case Qt::UserRole+3: // G0 character set for blast-through
|
||||||
|
return m_parentMainWidget->pageDecode()->cellG0CharacterSet(triplet.activePositionRow(), triplet.activePositionColumn());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 0x22: // G3 character at Level 1.5
|
case 0x22: // G3 character at Level 1.5
|
||||||
case 0x2b: // G3 character at Level 2.5
|
case 0x2b: // G3 character at Level 2.5
|
||||||
// Qt::UserRole+1 is character number, returned by default below
|
// Qt::UserRole+1 is character number, returned by default below
|
||||||
if (role == Qt::UserRole+2) // Character set
|
if (role == Qt::UserRole+2) // G3 character set
|
||||||
return 26;
|
return 26;
|
||||||
break;
|
break;
|
||||||
case 0x27: // Flash functions
|
case 0x27: // Flash functions
|
||||||
|
|||||||
Reference in New Issue
Block a user