Split out X28 commands
This commit is contained in:
@@ -804,219 +804,3 @@ void DeleteSubPageCommand::undo()
|
|||||||
m_teletextDocument->unDeleteSubPageFromRecycle(m_subPageIndex);
|
m_teletextDocument->unDeleteSubPageFromRecycle(m_subPageIndex);
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex, true);
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SetFullScreenColourCommand::SetFullScreenColourCommand(TeletextDocument *teletextDocument, int newColour, QUndoCommand *parent) : LevelOneCommand(teletextDocument, parent)
|
|
||||||
{
|
|
||||||
m_oldColour = teletextDocument->currentSubPage()->defaultScreenColour();
|
|
||||||
m_newColour = newColour;
|
|
||||||
|
|
||||||
setText(QObject::tr("full screen colour"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetFullScreenColourCommand::redo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
m_teletextDocument->currentSubPage()->setDefaultScreenColour(m_newColour);
|
|
||||||
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
emit m_teletextDocument->pageOptionsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetFullScreenColourCommand::undo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
m_teletextDocument->currentSubPage()->setDefaultScreenColour(m_oldColour);
|
|
||||||
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
emit m_teletextDocument->pageOptionsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SetFullScreenColourCommand::mergeWith(const QUndoCommand *command)
|
|
||||||
{
|
|
||||||
const SetFullScreenColourCommand *newerCommand = static_cast<const SetFullScreenColourCommand *>(command);
|
|
||||||
|
|
||||||
if (m_subPageIndex != newerCommand->m_subPageIndex)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
m_newColour = newerCommand->m_newColour;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SetFullRowColourCommand::SetFullRowColourCommand(TeletextDocument *teletextDocument, int newColour, QUndoCommand *parent) : LevelOneCommand(teletextDocument, parent)
|
|
||||||
{
|
|
||||||
m_oldColour = teletextDocument->currentSubPage()->defaultRowColour();
|
|
||||||
m_newColour = newColour;
|
|
||||||
|
|
||||||
setText(QObject::tr("full row colour"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetFullRowColourCommand::redo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
m_teletextDocument->currentSubPage()->setDefaultRowColour(m_newColour);
|
|
||||||
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
emit m_teletextDocument->pageOptionsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetFullRowColourCommand::undo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
m_teletextDocument->currentSubPage()->setDefaultRowColour(m_oldColour);
|
|
||||||
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
emit m_teletextDocument->pageOptionsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SetFullRowColourCommand::mergeWith(const QUndoCommand *command)
|
|
||||||
{
|
|
||||||
const SetFullRowColourCommand *newerCommand = static_cast<const SetFullRowColourCommand *>(command);
|
|
||||||
|
|
||||||
if (m_subPageIndex != newerCommand->m_subPageIndex)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
m_newColour = newerCommand->m_newColour;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SetCLUTRemapCommand::SetCLUTRemapCommand(TeletextDocument *teletextDocument, int newMap, QUndoCommand *parent) : LevelOneCommand(teletextDocument, parent)
|
|
||||||
{
|
|
||||||
m_oldMap = teletextDocument->currentSubPage()->colourTableRemap();
|
|
||||||
m_newMap = newMap;
|
|
||||||
|
|
||||||
setText(QObject::tr("CLUT remapping"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetCLUTRemapCommand::redo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
m_teletextDocument->currentSubPage()->setColourTableRemap(m_newMap);
|
|
||||||
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
emit m_teletextDocument->pageOptionsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetCLUTRemapCommand::undo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
m_teletextDocument->currentSubPage()->setColourTableRemap(m_oldMap);
|
|
||||||
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
emit m_teletextDocument->pageOptionsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SetCLUTRemapCommand::mergeWith(const QUndoCommand *command)
|
|
||||||
{
|
|
||||||
const SetCLUTRemapCommand *newerCommand = static_cast<const SetCLUTRemapCommand *>(command);
|
|
||||||
|
|
||||||
if (m_subPageIndex != newerCommand->m_subPageIndex)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
m_newMap = newerCommand->m_newMap;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SetBlackBackgroundSubstCommand::SetBlackBackgroundSubstCommand(TeletextDocument *teletextDocument, bool newSub, QUndoCommand *parent) : LevelOneCommand(teletextDocument, parent)
|
|
||||||
{
|
|
||||||
m_oldSub = teletextDocument->currentSubPage()->blackBackgroundSubst();
|
|
||||||
m_newSub = newSub;
|
|
||||||
|
|
||||||
setText(QObject::tr("black background substitution"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetBlackBackgroundSubstCommand::redo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
m_teletextDocument->currentSubPage()->setBlackBackgroundSubst(m_newSub);
|
|
||||||
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
emit m_teletextDocument->pageOptionsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetBlackBackgroundSubstCommand::undo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
m_teletextDocument->currentSubPage()->setBlackBackgroundSubst(m_oldSub);
|
|
||||||
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
emit m_teletextDocument->pageOptionsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SetBlackBackgroundSubstCommand::mergeWith(const QUndoCommand *command)
|
|
||||||
{
|
|
||||||
const SetBlackBackgroundSubstCommand *newerCommand = static_cast<const SetBlackBackgroundSubstCommand *>(command);
|
|
||||||
|
|
||||||
if (m_subPageIndex != newerCommand->m_subPageIndex)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
setObsolete(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SetColourCommand::SetColourCommand(TeletextDocument *teletextDocument, int colourIndex, int newColour, QUndoCommand *parent) : LevelOneCommand(teletextDocument, parent)
|
|
||||||
{
|
|
||||||
m_colourIndex = colourIndex;
|
|
||||||
m_oldColour = teletextDocument->currentSubPage()->CLUT(colourIndex);
|
|
||||||
m_newColour = newColour;
|
|
||||||
|
|
||||||
setText(QObject::tr("colour change"));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetColourCommand::redo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
m_teletextDocument->currentSubPage()->setCLUT(m_colourIndex, m_newColour);
|
|
||||||
|
|
||||||
emit m_teletextDocument->colourChanged(m_colourIndex);
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetColourCommand::undo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
m_teletextDocument->currentSubPage()->setCLUT(m_colourIndex, m_oldColour);
|
|
||||||
|
|
||||||
emit m_teletextDocument->colourChanged(m_colourIndex);
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ResetCLUTCommand::ResetCLUTCommand(TeletextDocument *teletextDocument, int colourTable, QUndoCommand *parent) : LevelOneCommand(teletextDocument, parent)
|
|
||||||
{
|
|
||||||
m_colourTable = colourTable;
|
|
||||||
for (int i=m_colourTable*8; i<m_colourTable*8+8; i++)
|
|
||||||
m_oldColourEntry[i&7] = teletextDocument->currentSubPage()->CLUT(i);
|
|
||||||
|
|
||||||
setText(QObject::tr("CLUT %1 reset").arg(m_colourTable));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResetCLUTCommand::redo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
for (int i=m_colourTable*8; i<m_colourTable*8+8; i++) {
|
|
||||||
m_teletextDocument->currentSubPage()->setCLUT(i, m_teletextDocument->currentSubPage()->CLUT(i, 0));
|
|
||||||
emit m_teletextDocument->colourChanged(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResetCLUTCommand::undo()
|
|
||||||
{
|
|
||||||
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
|
||||||
for (int i=m_colourTable*8; i<m_colourTable*8+8; i++) {
|
|
||||||
m_teletextDocument->currentSubPage()->setCLUT(i, m_oldColourEntry[i&7]);
|
|
||||||
emit m_teletextDocument->colourChanged(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
emit m_teletextDocument->contentsChanged();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -194,93 +194,4 @@ private:
|
|||||||
};
|
};
|
||||||
#endif // !QT_NO_CLIPBOARD
|
#endif // !QT_NO_CLIPBOARD
|
||||||
|
|
||||||
class SetFullScreenColourCommand : public LevelOneCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum { Id = 105 };
|
|
||||||
|
|
||||||
SetFullScreenColourCommand(TeletextDocument *teletextDocument, int newColour, QUndoCommand *parent = 0);
|
|
||||||
|
|
||||||
void redo() override;
|
|
||||||
void undo() override;
|
|
||||||
bool mergeWith(const QUndoCommand *command) override;
|
|
||||||
int id() const override { return Id; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_oldColour, m_newColour;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SetFullRowColourCommand : public LevelOneCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum { Id = 106 };
|
|
||||||
|
|
||||||
SetFullRowColourCommand(TeletextDocument *teletextDocument, int newColour, QUndoCommand *parent = 0);
|
|
||||||
|
|
||||||
void redo() override;
|
|
||||||
void undo() override;
|
|
||||||
bool mergeWith(const QUndoCommand *command) override;
|
|
||||||
int id() const override { return Id; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_oldColour, m_newColour;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SetCLUTRemapCommand : public LevelOneCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum { Id = 107 };
|
|
||||||
|
|
||||||
SetCLUTRemapCommand(TeletextDocument *teletextDocument, int newMap, QUndoCommand *parent = 0);
|
|
||||||
|
|
||||||
void redo() override;
|
|
||||||
void undo() override;
|
|
||||||
bool mergeWith(const QUndoCommand *command) override;
|
|
||||||
int id() const override { return Id; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_oldMap, m_newMap;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SetBlackBackgroundSubstCommand : public LevelOneCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum { Id = 108 };
|
|
||||||
|
|
||||||
SetBlackBackgroundSubstCommand(TeletextDocument *teletextDocument, bool newSub, QUndoCommand *parent = 0);
|
|
||||||
|
|
||||||
void redo() override;
|
|
||||||
void undo() override;
|
|
||||||
bool mergeWith(const QUndoCommand *command) override;
|
|
||||||
int id() const override { return Id; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_oldSub, m_newSub;
|
|
||||||
};
|
|
||||||
|
|
||||||
class SetColourCommand : public LevelOneCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
SetColourCommand(TeletextDocument *teletextDocument, int colourIndex, int newColour, QUndoCommand *parent = 0);
|
|
||||||
|
|
||||||
void redo() override;
|
|
||||||
void undo() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_colourIndex, m_oldColour, m_newColour;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ResetCLUTCommand : public LevelOneCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ResetCLUTCommand(TeletextDocument *teletextDocument, int colourTable, QUndoCommand *parent = 0);
|
|
||||||
|
|
||||||
void redo() override;
|
|
||||||
void undo() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_colourTable;
|
|
||||||
int m_oldColourEntry[8];
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "pageenhancementsdockwidget.h"
|
#include "pageenhancementsdockwidget.h"
|
||||||
|
|
||||||
#include "levelonecommands.h"
|
#include "x28commands.h"
|
||||||
|
|
||||||
PageEnhancementsDockWidget::PageEnhancementsDockWidget(TeletextWidget *parent): QDockWidget(parent)
|
PageEnhancementsDockWidget::PageEnhancementsDockWidget(TeletextWidget *parent): QDockWidget(parent)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "palettedockwidget.h"
|
#include "palettedockwidget.h"
|
||||||
|
|
||||||
#include "levelonecommands.h"
|
#include "x28commands.h"
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ HEADERS = decode.h \
|
|||||||
x26dockwidget.h \
|
x26dockwidget.h \
|
||||||
x26menus.h \
|
x26menus.h \
|
||||||
x26model.h \
|
x26model.h \
|
||||||
x26triplets.h
|
x26triplets.h \
|
||||||
|
x28commands.h
|
||||||
SOURCES = decode.cpp \
|
SOURCES = decode.cpp \
|
||||||
document.cpp \
|
document.cpp \
|
||||||
levelonecommands.cpp \
|
levelonecommands.cpp \
|
||||||
@@ -41,7 +42,8 @@ SOURCES = decode.cpp \
|
|||||||
x26dockwidget.cpp \
|
x26dockwidget.cpp \
|
||||||
x26menus.cpp \
|
x26menus.cpp \
|
||||||
x26model.cpp \
|
x26model.cpp \
|
||||||
x26triplets.cpp
|
x26triplets.cpp \
|
||||||
|
x28commands.cpp
|
||||||
RESOURCES = qteletextmaker.qrc
|
RESOURCES = qteletextmaker.qrc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
|
|||||||
243
x28commands.cpp
Normal file
243
x28commands.cpp
Normal file
@@ -0,0 +1,243 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020-2024 Gavin MacGregor
|
||||||
|
*
|
||||||
|
* This file is part of QTeletextMaker.
|
||||||
|
*
|
||||||
|
* QTeletextMaker is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* QTeletextMaker is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "x28commands.h"
|
||||||
|
|
||||||
|
#include "document.h"
|
||||||
|
|
||||||
|
X28Command::X28Command(TeletextDocument *teletextDocument, QUndoCommand *parent) : QUndoCommand(parent)
|
||||||
|
{
|
||||||
|
m_teletextDocument = teletextDocument;
|
||||||
|
m_subPageIndex = teletextDocument->currentSubPageIndex();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SetFullScreenColourCommand::SetFullScreenColourCommand(TeletextDocument *teletextDocument, int newColour, QUndoCommand *parent) : X28Command(teletextDocument, parent)
|
||||||
|
{
|
||||||
|
m_oldColour = teletextDocument->currentSubPage()->defaultScreenColour();
|
||||||
|
m_newColour = newColour;
|
||||||
|
|
||||||
|
setText(QObject::tr("full screen colour"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetFullScreenColourCommand::redo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
m_teletextDocument->currentSubPage()->setDefaultScreenColour(m_newColour);
|
||||||
|
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
emit m_teletextDocument->pageOptionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetFullScreenColourCommand::undo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
m_teletextDocument->currentSubPage()->setDefaultScreenColour(m_oldColour);
|
||||||
|
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
emit m_teletextDocument->pageOptionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SetFullScreenColourCommand::mergeWith(const QUndoCommand *command)
|
||||||
|
{
|
||||||
|
const SetFullScreenColourCommand *newerCommand = static_cast<const SetFullScreenColourCommand *>(command);
|
||||||
|
|
||||||
|
if (m_subPageIndex != newerCommand->m_subPageIndex)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_newColour = newerCommand->m_newColour;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SetFullRowColourCommand::SetFullRowColourCommand(TeletextDocument *teletextDocument, int newColour, QUndoCommand *parent) : X28Command(teletextDocument, parent)
|
||||||
|
{
|
||||||
|
m_oldColour = teletextDocument->currentSubPage()->defaultRowColour();
|
||||||
|
m_newColour = newColour;
|
||||||
|
|
||||||
|
setText(QObject::tr("full row colour"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetFullRowColourCommand::redo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
m_teletextDocument->currentSubPage()->setDefaultRowColour(m_newColour);
|
||||||
|
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
emit m_teletextDocument->pageOptionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetFullRowColourCommand::undo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
m_teletextDocument->currentSubPage()->setDefaultRowColour(m_oldColour);
|
||||||
|
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
emit m_teletextDocument->pageOptionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SetFullRowColourCommand::mergeWith(const QUndoCommand *command)
|
||||||
|
{
|
||||||
|
const SetFullRowColourCommand *newerCommand = static_cast<const SetFullRowColourCommand *>(command);
|
||||||
|
|
||||||
|
if (m_subPageIndex != newerCommand->m_subPageIndex)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_newColour = newerCommand->m_newColour;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SetCLUTRemapCommand::SetCLUTRemapCommand(TeletextDocument *teletextDocument, int newMap, QUndoCommand *parent) : X28Command(teletextDocument, parent)
|
||||||
|
{
|
||||||
|
m_oldMap = teletextDocument->currentSubPage()->colourTableRemap();
|
||||||
|
m_newMap = newMap;
|
||||||
|
|
||||||
|
setText(QObject::tr("CLUT remapping"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetCLUTRemapCommand::redo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
m_teletextDocument->currentSubPage()->setColourTableRemap(m_newMap);
|
||||||
|
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
emit m_teletextDocument->pageOptionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetCLUTRemapCommand::undo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
m_teletextDocument->currentSubPage()->setColourTableRemap(m_oldMap);
|
||||||
|
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
emit m_teletextDocument->pageOptionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SetCLUTRemapCommand::mergeWith(const QUndoCommand *command)
|
||||||
|
{
|
||||||
|
const SetCLUTRemapCommand *newerCommand = static_cast<const SetCLUTRemapCommand *>(command);
|
||||||
|
|
||||||
|
if (m_subPageIndex != newerCommand->m_subPageIndex)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_newMap = newerCommand->m_newMap;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SetBlackBackgroundSubstCommand::SetBlackBackgroundSubstCommand(TeletextDocument *teletextDocument, bool newSub, QUndoCommand *parent) : X28Command(teletextDocument, parent)
|
||||||
|
{
|
||||||
|
m_oldSub = teletextDocument->currentSubPage()->blackBackgroundSubst();
|
||||||
|
m_newSub = newSub;
|
||||||
|
|
||||||
|
setText(QObject::tr("black background substitution"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBlackBackgroundSubstCommand::redo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
m_teletextDocument->currentSubPage()->setBlackBackgroundSubst(m_newSub);
|
||||||
|
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
emit m_teletextDocument->pageOptionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBlackBackgroundSubstCommand::undo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
m_teletextDocument->currentSubPage()->setBlackBackgroundSubst(m_oldSub);
|
||||||
|
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
emit m_teletextDocument->pageOptionsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SetBlackBackgroundSubstCommand::mergeWith(const QUndoCommand *command)
|
||||||
|
{
|
||||||
|
const SetBlackBackgroundSubstCommand *newerCommand = static_cast<const SetBlackBackgroundSubstCommand *>(command);
|
||||||
|
|
||||||
|
if (m_subPageIndex != newerCommand->m_subPageIndex)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
setObsolete(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SetColourCommand::SetColourCommand(TeletextDocument *teletextDocument, int colourIndex, int newColour, QUndoCommand *parent) : X28Command(teletextDocument, parent)
|
||||||
|
{
|
||||||
|
m_colourIndex = colourIndex;
|
||||||
|
m_oldColour = teletextDocument->currentSubPage()->CLUT(colourIndex);
|
||||||
|
m_newColour = newColour;
|
||||||
|
|
||||||
|
setText(QObject::tr("colour change"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetColourCommand::redo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
m_teletextDocument->currentSubPage()->setCLUT(m_colourIndex, m_newColour);
|
||||||
|
|
||||||
|
emit m_teletextDocument->colourChanged(m_colourIndex);
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetColourCommand::undo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
m_teletextDocument->currentSubPage()->setCLUT(m_colourIndex, m_oldColour);
|
||||||
|
|
||||||
|
emit m_teletextDocument->colourChanged(m_colourIndex);
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ResetCLUTCommand::ResetCLUTCommand(TeletextDocument *teletextDocument, int colourTable, QUndoCommand *parent) : X28Command(teletextDocument, parent)
|
||||||
|
{
|
||||||
|
m_colourTable = colourTable;
|
||||||
|
for (int i=m_colourTable*8; i<m_colourTable*8+8; i++)
|
||||||
|
m_oldColourEntry[i&7] = teletextDocument->currentSubPage()->CLUT(i);
|
||||||
|
|
||||||
|
setText(QObject::tr("CLUT %1 reset").arg(m_colourTable));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetCLUTCommand::redo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
for (int i=m_colourTable*8; i<m_colourTable*8+8; i++) {
|
||||||
|
m_teletextDocument->currentSubPage()->setCLUT(i, m_teletextDocument->currentSubPage()->CLUT(i, 0));
|
||||||
|
emit m_teletextDocument->colourChanged(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetCLUTCommand::undo()
|
||||||
|
{
|
||||||
|
m_teletextDocument->selectSubPageIndex(m_subPageIndex);
|
||||||
|
for (int i=m_colourTable*8; i<m_colourTable*8+8; i++) {
|
||||||
|
m_teletextDocument->currentSubPage()->setCLUT(i, m_oldColourEntry[i&7]);
|
||||||
|
emit m_teletextDocument->colourChanged(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
emit m_teletextDocument->contentsChanged();
|
||||||
|
}
|
||||||
126
x28commands.h
Normal file
126
x28commands.h
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020-2024 Gavin MacGregor
|
||||||
|
*
|
||||||
|
* This file is part of QTeletextMaker.
|
||||||
|
*
|
||||||
|
* QTeletextMaker is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* QTeletextMaker is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef X28COMMANDS_H
|
||||||
|
#define X28COMMANDS_H
|
||||||
|
|
||||||
|
#include <QUndoCommand>
|
||||||
|
|
||||||
|
#include "document.h"
|
||||||
|
|
||||||
|
class X28Command : public QUndoCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
X28Command(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
TeletextDocument *m_teletextDocument;
|
||||||
|
int m_subPageIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SetFullScreenColourCommand : public X28Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum { Id = 301 };
|
||||||
|
|
||||||
|
SetFullScreenColourCommand(TeletextDocument *teletextDocument, int newColour, QUndoCommand *parent = 0);
|
||||||
|
|
||||||
|
void redo() override;
|
||||||
|
void undo() override;
|
||||||
|
bool mergeWith(const QUndoCommand *command) override;
|
||||||
|
int id() const override { return Id; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_oldColour, m_newColour;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SetFullRowColourCommand : public X28Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum { Id = 302 };
|
||||||
|
|
||||||
|
SetFullRowColourCommand(TeletextDocument *teletextDocument, int newColour, QUndoCommand *parent = 0);
|
||||||
|
|
||||||
|
void redo() override;
|
||||||
|
void undo() override;
|
||||||
|
bool mergeWith(const QUndoCommand *command) override;
|
||||||
|
int id() const override { return Id; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_oldColour, m_newColour;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SetCLUTRemapCommand : public X28Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum { Id = 303 };
|
||||||
|
|
||||||
|
SetCLUTRemapCommand(TeletextDocument *teletextDocument, int newMap, QUndoCommand *parent = 0);
|
||||||
|
|
||||||
|
void redo() override;
|
||||||
|
void undo() override;
|
||||||
|
bool mergeWith(const QUndoCommand *command) override;
|
||||||
|
int id() const override { return Id; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_oldMap, m_newMap;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SetBlackBackgroundSubstCommand : public X28Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum { Id = 304 };
|
||||||
|
|
||||||
|
SetBlackBackgroundSubstCommand(TeletextDocument *teletextDocument, bool newSub, QUndoCommand *parent = 0);
|
||||||
|
|
||||||
|
void redo() override;
|
||||||
|
void undo() override;
|
||||||
|
bool mergeWith(const QUndoCommand *command) override;
|
||||||
|
int id() const override { return Id; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_oldSub, m_newSub;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SetColourCommand : public X28Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SetColourCommand(TeletextDocument *teletextDocument, int colourIndex, int newColour, QUndoCommand *parent = 0);
|
||||||
|
|
||||||
|
void redo() override;
|
||||||
|
void undo() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_colourIndex, m_oldColour, m_newColour;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ResetCLUTCommand : public X28Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ResetCLUTCommand(TeletextDocument *teletextDocument, int colourTable, QUndoCommand *parent = 0);
|
||||||
|
|
||||||
|
void redo() override;
|
||||||
|
void undo() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_colourTable;
|
||||||
|
int m_oldColourEntry[8];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user