2020-11-10 18:48:12 +00:00
|
|
|
/*
|
2024-01-01 00:12:17 +00:00
|
|
|
* Copyright (C) 2020-2024 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
|
|
|
|
|
|
2021-05-03 22:17:51 +01:00
|
|
|
#include <QByteArrayList>
|
2020-11-10 18:48:12 +00:00
|
|
|
#include <QUndoCommand>
|
|
|
|
|
|
|
|
|
|
#include "document.h"
|
|
|
|
|
|
2021-05-02 11:35:02 +01:00
|
|
|
class LevelOneCommand : public QUndoCommand
|
|
|
|
|
{
|
|
|
|
|
public:
|
2023-08-27 14:25:16 +01:00
|
|
|
LevelOneCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
|
2021-05-02 11:35:02 +01:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
TeletextDocument *m_teletextDocument;
|
|
|
|
|
int m_subPageIndex, m_row, m_column;
|
|
|
|
|
bool m_firstDo;
|
|
|
|
|
};
|
|
|
|
|
|
2024-02-02 18:00:43 +00:00
|
|
|
class StoreOldCharactersCommand : public LevelOneCommand
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
StoreOldCharactersCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void storeOldCharacters(int topRow, int leftColumn, int bottomRow, int rightColumn);
|
|
|
|
|
void retrieveOldCharacters(int topRow, int leftColumn, int bottomRow, int rightColumn);
|
|
|
|
|
|
|
|
|
|
QByteArrayList m_oldCharacters;
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-02 11:35:02 +01:00
|
|
|
class TypeCharacterCommand : public LevelOneCommand
|
2020-11-10 18:48:12 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2021-01-03 21:47:29 +00:00
|
|
|
enum { Id = 101 };
|
|
|
|
|
|
2023-08-27 14:25:16 +01:00
|
|
|
TypeCharacterCommand(TeletextDocument *teletextDocument, unsigned char newCharacter, bool insertMode, QUndoCommand *parent = 0);
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
2023-08-27 14:25:16 +01:00
|
|
|
bool mergeWith(const QUndoCommand *command) override;
|
2021-01-03 21:47:29 +00:00
|
|
|
int id() const override { return Id; }
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
private:
|
2021-01-03 21:47:29 +00:00
|
|
|
unsigned char m_newCharacter, m_oldRowContents[40], m_newRowContents[40];
|
2021-05-02 11:35:02 +01:00
|
|
|
int m_columnStart, m_columnEnd;
|
|
|
|
|
bool m_insertMode;
|
2020-11-10 18:48:12 +00:00
|
|
|
};
|
|
|
|
|
|
2021-05-02 11:35:02 +01:00
|
|
|
class ToggleMosaicBitCommand : public LevelOneCommand
|
2020-11-10 18:48:12 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2021-01-03 21:47:29 +00:00
|
|
|
enum { Id = 102 };
|
2020-11-10 18:48:12 +00:00
|
|
|
|
2023-08-27 14:25:16 +01:00
|
|
|
ToggleMosaicBitCommand(TeletextDocument *teletextDocument, unsigned char bitToToggle, QUndoCommand *parent = 0);
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
2023-08-27 14:25:16 +01:00
|
|
|
bool mergeWith(const QUndoCommand *command) override;
|
2020-11-10 18:48:12 +00:00
|
|
|
int id() const override { return Id; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
unsigned char m_oldCharacter, m_newCharacter;
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-02 11:35:02 +01:00
|
|
|
class BackspaceKeyCommand : public LevelOneCommand
|
2020-11-10 18:48:12 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2021-01-03 21:47:29 +00:00
|
|
|
enum { Id = 103 };
|
|
|
|
|
|
2023-08-27 14:25:16 +01:00
|
|
|
BackspaceKeyCommand(TeletextDocument *teletextDocument, bool insertMode, QUndoCommand *parent = 0);
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
2023-08-27 14:25:16 +01:00
|
|
|
bool mergeWith(const QUndoCommand *command) override;
|
2021-01-03 21:47:29 +00:00
|
|
|
int id() const override { return Id; }
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
private:
|
2021-01-03 21:47:29 +00:00
|
|
|
unsigned char m_oldRowContents[40], m_newRowContents[40];
|
2021-05-02 11:35:02 +01:00
|
|
|
int m_columnStart, m_columnEnd;
|
|
|
|
|
bool m_insertMode;
|
2020-11-10 18:48:12 +00:00
|
|
|
};
|
|
|
|
|
|
2021-05-02 11:35:02 +01:00
|
|
|
class DeleteKeyCommand : public LevelOneCommand
|
2021-02-12 21:33:06 +00:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
enum { Id = 104 };
|
|
|
|
|
|
2023-08-27 14:25:16 +01:00
|
|
|
DeleteKeyCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
|
2021-02-12 21:33:06 +00:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
2023-08-27 14:25:16 +01:00
|
|
|
bool mergeWith(const QUndoCommand *command) override;
|
2021-02-12 21:33:06 +00:00
|
|
|
int id() const override { return Id; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
unsigned char m_oldRowContents[40], m_newRowContents[40];
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-02 11:35:02 +01:00
|
|
|
class InsertSubPageCommand : public LevelOneCommand
|
2020-11-10 18:48:12 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2023-08-27 14:25:16 +01:00
|
|
|
InsertSubPageCommand(TeletextDocument *teletextDocument, bool afterCurrentSubPage, bool copySubPage, QUndoCommand *parent = 0);
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_newSubPageIndex;
|
|
|
|
|
bool m_copySubPage;
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-02 11:35:02 +01:00
|
|
|
class DeleteSubPageCommand : public LevelOneCommand
|
2020-12-15 21:57:42 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2023-08-27 14:25:16 +01:00
|
|
|
DeleteSubPageCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
|
2020-12-15 21:57:42 +00:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-02 11:35:02 +01:00
|
|
|
class InsertRowCommand : public LevelOneCommand
|
2020-11-10 18:48:12 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2023-08-27 14:25:16 +01:00
|
|
|
InsertRowCommand(TeletextDocument *teletextDocument, bool copyRow, QUndoCommand *parent = 0);
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
bool m_copyRow;
|
|
|
|
|
unsigned char m_deletedBottomRow[40];
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-02 11:35:02 +01:00
|
|
|
class DeleteRowCommand : public LevelOneCommand
|
2020-11-10 18:48:12 +00:00
|
|
|
{
|
|
|
|
|
public:
|
2023-08-27 14:25:16 +01:00
|
|
|
DeleteRowCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
|
2020-11-10 18:48:12 +00:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
unsigned char m_deletedRow[40];
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-03 22:17:51 +01:00
|
|
|
#ifndef QT_NO_CLIPBOARD
|
2024-02-02 18:00:43 +00:00
|
|
|
class CutCommand : public StoreOldCharactersCommand
|
2021-05-03 22:17:51 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2023-08-27 14:25:16 +01:00
|
|
|
CutCommand(TeletextDocument *teletextDocument, QUndoCommand *parent = 0);
|
2021-05-03 22:17:51 +01:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_selectionTopRow, m_selectionBottomRow, m_selectionLeftColumn, m_selectionRightColumn;
|
|
|
|
|
int m_selectionCornerRow, m_selectionCornerColumn;
|
|
|
|
|
};
|
|
|
|
|
|
2024-02-02 18:00:43 +00:00
|
|
|
class PasteCommand : public StoreOldCharactersCommand
|
2021-05-03 22:17:51 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2023-08-27 14:25:16 +01:00
|
|
|
PasteCommand(TeletextDocument *teletextDocument, int pageCharSet, QUndoCommand *parent = 0);
|
2021-05-03 22:17:51 +01:00
|
|
|
|
|
|
|
|
void redo() override;
|
|
|
|
|
void undo() override;
|
|
|
|
|
|
|
|
|
|
private:
|
2024-02-02 18:00:43 +00:00
|
|
|
QByteArrayList m_pastingCharacters;
|
2021-05-03 22:17:51 +01:00
|
|
|
int m_pasteTopRow, m_pasteBottomRow, m_pasteLeftColumn, m_pasteRightColumn;
|
|
|
|
|
int m_clipboardDataHeight, m_clipboardDataWidth;
|
|
|
|
|
int m_selectionCornerRow, m_selectionCornerColumn;
|
2022-11-20 17:36:53 +00:00
|
|
|
bool m_selectionActive, m_plainText;
|
2021-05-03 22:17:51 +01:00
|
|
|
};
|
|
|
|
|
#endif // !QT_NO_CLIPBOARD
|
|
|
|
|
|
2020-11-10 18:48:12 +00:00
|
|
|
#endif
|