2020-09-06 16:47:38 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2020 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 DOCUMENT_H
|
|
|
|
|
#define DOCUMENT_H
|
|
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QTextStream>
|
|
|
|
|
#include <QUndoStack>
|
|
|
|
|
#include <vector>
|
2020-09-11 12:06:06 +01:00
|
|
|
#include "levelonepage.h"
|
2020-09-06 16:47:38 +01:00
|
|
|
|
|
|
|
|
class TeletextDocument : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TeletextDocument();
|
|
|
|
|
~TeletextDocument();
|
|
|
|
|
bool isEmpty() const { return m_empty; }
|
|
|
|
|
void setModified(bool);
|
|
|
|
|
void loadDocument(QFile *);
|
|
|
|
|
void saveDocument(QTextStream *);
|
|
|
|
|
int numberOfSubPages() const { return m_subPages.size(); }
|
2020-09-16 11:15:46 +01:00
|
|
|
LevelOnePage* currentSubPage() const { return m_subPages[m_currentSubPageIndex]; }
|
2020-09-06 16:47:38 +01:00
|
|
|
int currentSubPageIndex() const { return m_currentSubPageIndex; }
|
|
|
|
|
void selectSubPageIndex(int, bool=false);
|
|
|
|
|
void selectSubPageNext();
|
|
|
|
|
void selectSubPagePrevious();
|
|
|
|
|
void insertSubPage(int, bool);
|
|
|
|
|
void deleteSubPage(int);
|
|
|
|
|
int pageNumber() const { return m_pageNumber; }
|
|
|
|
|
void setPageNumber(QString);
|
|
|
|
|
QString description() const { return m_description; }
|
|
|
|
|
void setDescription(QString);
|
2020-10-29 21:31:23 +00:00
|
|
|
void setFastTextLinkPageNumberOnAllSubPages(int, int);
|
2020-09-06 16:47:38 +01:00
|
|
|
QUndoStack *undoStack() const { return m_undoStack; }
|
|
|
|
|
int cursorRow() const { return m_cursorRow; }
|
|
|
|
|
int cursorColumn() const { return m_cursorColumn; }
|
|
|
|
|
void cursorUp();
|
|
|
|
|
void cursorDown();
|
|
|
|
|
void cursorLeft();
|
|
|
|
|
void cursorRight();
|
|
|
|
|
void moveCursor(int, int);
|
2020-10-25 11:07:04 +00:00
|
|
|
int selectionTopRow() const { return m_selectionTopRow; }
|
|
|
|
|
int selectionBottomRow() const { return m_selectionBottomRow; }
|
|
|
|
|
int selectionLeftColumn() const { return m_selectionLeftColumn; }
|
|
|
|
|
int selectionRightColumn() const { return m_selectionRightColumn; }
|
|
|
|
|
int selectionWidth() const { return m_selectionRightColumn - m_selectionLeftColumn + 1; }
|
|
|
|
|
int selectionHeight() const { return m_selectionBottomRow - m_selectionTopRow + 1; }
|
|
|
|
|
bool selectionActive() const { return m_selectionSubPage == currentSubPage(); }
|
|
|
|
|
void setSelection(int, int, int, int);
|
|
|
|
|
void cancelSelection();
|
2020-09-06 16:47:38 +01:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void cursorMoved();
|
2020-10-25 11:07:04 +00:00
|
|
|
void selectionMoved();
|
2020-09-06 16:47:38 +01:00
|
|
|
void colourChanged(int);
|
|
|
|
|
void contentsChange(int);
|
|
|
|
|
void aboutToChangeSubPage();
|
|
|
|
|
void subPageSelected();
|
|
|
|
|
void refreshNeeded();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString m_description;
|
|
|
|
|
bool m_empty;
|
|
|
|
|
int m_pageNumber, m_currentSubPageIndex;
|
2020-09-16 11:15:46 +01:00
|
|
|
std::vector<LevelOnePage *> m_subPages;
|
2020-09-06 16:47:38 +01:00
|
|
|
QUndoStack *m_undoStack;
|
2020-10-25 11:07:04 +00:00
|
|
|
int m_cursorRow, m_cursorColumn, m_selectionTopRow, m_selectionBottomRow, m_selectionLeftColumn, m_selectionRightColumn;
|
|
|
|
|
LevelOnePage *m_selectionSubPage;
|
2020-09-06 16:47:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|