2020-11-10 18:48:12 +00:00
|
|
|
/*
|
2020-12-31 22:08:52 +00:00
|
|
|
* Copyright (C) 2020, 2021 Gavin MacGregor
|
2020-11-10 18:48:12 +00:00
|
|
|
*
|
|
|
|
|
* 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 LEVELONECOMMANDS_H
|
|
|
|
|
#define LEVELONECOMMANDS_H
|
|
|
|
|
|
|
|
|
|
#include <QUndoCommand>
|
|
|
|
|
|
|
|
|
|
#include "document.h"
|
|
|
|
|
|
2021-02-14 17:35:11 +00:00
|
|
|
class TypeCharacterCommand : public QUndoCommand
|
2020-11-10 18:48:12 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2021-01-03 21:47:29 +00:00
|
|
|
enum { Id = 101 };
|
|
|
|
|
|
2021-02-14 17:35:11 +00:00
|
|
|
TypeCharacterCommand(TeletextDocument *, unsigned char, bool, QUndoCommand *parent = 0);
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
2021-01-03 21:47:29 +00:00
|
|
|
bool mergeWith(const QUndoCommand *) override;
|
|
|
|
|
int id() const override { return Id; }
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TeletextDocument *m_teletextDocument;
|
2021-01-03 21:47:29 +00:00
|
|
|
unsigned char m_newCharacter, m_oldRowContents[40], m_newRowContents[40];
|
|
|
|
|
int m_subPageIndex, m_row, m_columnStart, m_columnEnd;
|
2021-02-14 17:35:11 +00:00
|
|
|
bool m_firstDo, m_insertMode;
|
2020-11-10 18:48:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ToggleMosaicBitCommand : public QUndoCommand
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-01-03 21:47:29 +00:00
|
|
|
enum { Id = 102 };
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
ToggleMosaicBitCommand(TeletextDocument *, unsigned char, QUndoCommand *parent = 0);
|
|
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
bool mergeWith(const QUndoCommand *) override;
|
|
|
|
|
int id() const override { return Id; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TeletextDocument *m_teletextDocument;
|
|
|
|
|
unsigned char m_oldCharacter, m_newCharacter;
|
|
|
|
|
int m_subPageIndex, m_row, m_column;
|
|
|
|
|
};
|
|
|
|
|
|
2021-02-14 17:35:11 +00:00
|
|
|
class BackspaceKeyCommand : public QUndoCommand
|
2020-11-10 18:48:12 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2021-01-03 21:47:29 +00:00
|
|
|
enum { Id = 103 };
|
|
|
|
|
|
2021-02-14 17:35:11 +00:00
|
|
|
BackspaceKeyCommand(TeletextDocument *, bool insertMode, QUndoCommand *parent = 0);
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
2021-01-03 21:47:29 +00:00
|
|
|
bool mergeWith(const QUndoCommand *) override;
|
|
|
|
|
int id() const override { return Id; }
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TeletextDocument *m_teletextDocument;
|
2021-01-03 21:47:29 +00:00
|
|
|
unsigned char m_oldRowContents[40], m_newRowContents[40];
|
|
|
|
|
int m_subPageIndex, m_row, m_columnStart, m_columnEnd;
|
2021-02-14 17:35:11 +00:00
|
|
|
bool m_firstDo, m_insertMode;
|
2020-11-10 18:48:12 +00:00
|
|
|
};
|
|
|
|
|
|
2021-02-12 21:33:06 +00:00
|
|
|
class DeleteKeyCommand : public QUndoCommand
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum { Id = 104 };
|
|
|
|
|
|
|
|
|
|
DeleteKeyCommand(TeletextDocument *, QUndoCommand *parent = 0);
|
|
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
bool mergeWith(const QUndoCommand *) override;
|
|
|
|
|
int id() const override { return Id; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TeletextDocument *m_teletextDocument;
|
|
|
|
|
unsigned char m_oldRowContents[40], m_newRowContents[40];
|
|
|
|
|
int m_subPageIndex, m_row, m_column;
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-10 18:48:12 +00:00
|
|
|
class InsertSubPageCommand : public QUndoCommand
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
InsertSubPageCommand(TeletextDocument *, bool, bool, QUndoCommand *parent = 0);
|
|
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TeletextDocument *m_teletextDocument;
|
|
|
|
|
int m_newSubPageIndex;
|
|
|
|
|
bool m_copySubPage;
|
|
|
|
|
};
|
|
|
|
|
|
2020-12-15 21:57:42 +00:00
|
|
|
class DeleteSubPageCommand : public QUndoCommand
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DeleteSubPageCommand(TeletextDocument *, QUndoCommand *parent = 0);
|
|
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TeletextDocument *m_teletextDocument;
|
|
|
|
|
int m_subPageToDelete;
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-10 18:48:12 +00:00
|
|
|
class InsertRowCommand : public QUndoCommand
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
InsertRowCommand(TeletextDocument *, bool, QUndoCommand *parent = 0);
|
|
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TeletextDocument *m_teletextDocument;
|
|
|
|
|
int m_subPageIndex, m_row;
|
|
|
|
|
bool m_copyRow;
|
|
|
|
|
unsigned char m_deletedBottomRow[40];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DeleteRowCommand : public QUndoCommand
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DeleteRowCommand(TeletextDocument *, QUndoCommand *parent = 0);
|
|
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TeletextDocument *m_teletextDocument;
|
|
|
|
|
int m_subPageIndex, m_row;
|
|
|
|
|
unsigned char m_deletedRow[40];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class SetColourCommand : public QUndoCommand
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
SetColourCommand(TeletextDocument *, int, int, QUndoCommand *parent = 0);
|
|
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TeletextDocument *m_teletextDocument;
|
|
|
|
|
int m_subPageIndex, m_colourIndex, m_oldColour, m_newColour;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ResetCLUTCommand : public QUndoCommand
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ResetCLUTCommand(TeletextDocument *, int, QUndoCommand *parent = 0);
|
|
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
TeletextDocument *m_teletextDocument;
|
|
|
|
|
int m_subPageIndex, m_colourTable;
|
|
|
|
|
int m_oldColourEntry[8];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|