Move page function and packet coding to document
This commit is contained in:
14
document.cpp
14
document.cpp
@@ -29,6 +29,8 @@ TeletextDocument::TeletextDocument()
|
||||
{
|
||||
m_pageNumber = 0x198;
|
||||
m_description.clear();
|
||||
m_pageFunction = PFLevelOnePage;
|
||||
m_packetCoding = Coding7bit;
|
||||
m_empty = true;
|
||||
m_subPages.push_back(new LevelOnePage);
|
||||
m_currentSubPageIndex = 0;
|
||||
@@ -44,6 +46,18 @@ TeletextDocument::~TeletextDocument()
|
||||
delete(subPage);
|
||||
}
|
||||
|
||||
/*
|
||||
void TeletextDocument::setPageFunction(PageFunctionEnum newPageFunction)
|
||||
{
|
||||
m_pageFunction = newPageFunction;
|
||||
}
|
||||
|
||||
void TeletextDocument::setPacketCoding(PacketCodingEnum newPacketEncoding)
|
||||
{
|
||||
m_packetCoding = newPacketEncoding;
|
||||
}
|
||||
*/
|
||||
|
||||
void TeletextDocument::loadDocument(QFile *inFile)
|
||||
{
|
||||
QByteArray inLine;
|
||||
|
||||
13
document.h
13
document.h
@@ -32,10 +32,21 @@ class TeletextDocument : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Available Page Functions according to 9.4.2.1 of the spec
|
||||
enum PageFunctionEnum { PFLevelOnePage, PFDataBroadcasting, PFGlobalPOP, PFNormalPOP, PFGlobalDRCS, PFNormalDRCS, PFMOT, PFMIP, PFBasicTOPTable, PFAdditionalInformationTable, PFMultiPageTable, PFMultiPageExtensionTable, PFTriggerMessages };
|
||||
// Available Page Codings of X/1 to X/25 according to 9.4.2.1 of the spec
|
||||
enum PacketCodingEnum { Coding7bit, Coding8bit, Coding18bit, Coding4bit, Coding4bitThen7bit, CodingPerPacket };
|
||||
|
||||
TeletextDocument();
|
||||
~TeletextDocument();
|
||||
bool isEmpty() const { return m_empty; }
|
||||
void setModified(bool);
|
||||
|
||||
PageFunctionEnum pageFunction() const { return m_pageFunction; }
|
||||
// void setPageFunction(PageFunctionEnum);
|
||||
PacketCodingEnum packetCoding() const { return m_packetCoding; }
|
||||
// void setPacketCoding(PacketCodingEnum);
|
||||
|
||||
void loadDocument(QFile *);
|
||||
void saveDocument(QTextStream *);
|
||||
int numberOfSubPages() const { return m_subPages.size(); }
|
||||
@@ -82,6 +93,8 @@ private:
|
||||
QString m_description;
|
||||
bool m_empty;
|
||||
int m_pageNumber, m_currentSubPageIndex;
|
||||
PageFunctionEnum m_pageFunction;
|
||||
PacketCodingEnum m_packetCoding;
|
||||
std::vector<LevelOnePage *> m_subPages;
|
||||
QUndoStack *m_undoStack;
|
||||
int m_cursorRow, m_cursorColumn, m_selectionTopRow, m_selectionBottomRow, m_selectionLeftColumn, m_selectionRightColumn;
|
||||
|
||||
29
pagebase.cpp
29
pagebase.cpp
@@ -23,8 +23,6 @@
|
||||
|
||||
PageBase::PageBase()
|
||||
{
|
||||
m_pageFunction = PFLOP;
|
||||
m_packetCoding = PC7bit;
|
||||
// We use nullptrs to keep track of allocated packets, so initialise them this way
|
||||
for (int i=0; i<90; i++)
|
||||
m_packets[i] = nullptr;
|
||||
@@ -34,8 +32,6 @@ PageBase::PageBase()
|
||||
|
||||
PageBase::PageBase(const PageBase &other)
|
||||
{
|
||||
setPageFunction(other.pageFunction());
|
||||
setPacketCoding(other.packetCoding());
|
||||
for (int i=0; i<8; i++)
|
||||
setControlBit(i, other.controlBit(i));
|
||||
for (int i=0; i<90; i++)
|
||||
@@ -129,28 +125,3 @@ bool PageBase::setControlBit(int bitNumber, bool active)
|
||||
m_controlBits[bitNumber] = active;
|
||||
return true;
|
||||
}
|
||||
|
||||
PageBase::PacketCodingEnum PageBase::packetCoding(int packetNumber) const
|
||||
{
|
||||
switch (packetNumber) {
|
||||
case 26:
|
||||
case 28:
|
||||
return PC18bit;
|
||||
case 27:
|
||||
return PC4bit;
|
||||
default:
|
||||
return m_packetCoding;
|
||||
}
|
||||
}
|
||||
|
||||
bool PageBase::setPageFunction(PageBase::PageFunctionEnum newPageFunction)
|
||||
{
|
||||
m_pageFunction = newPageFunction;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PageBase::setPacketCoding(PageBase::PacketCodingEnum newPacketEncoding)
|
||||
{
|
||||
m_packetCoding = newPacketEncoding;
|
||||
return true;
|
||||
}
|
||||
|
||||
12
pagebase.h
12
pagebase.h
@@ -28,11 +28,6 @@ class PageBase //: public QObject
|
||||
//Q_OBJECT
|
||||
|
||||
public:
|
||||
// Available Page Functions according to 9.4.2.1 of the spec
|
||||
enum PageFunctionEnum { PFLOP, PFData, PFGPOP, PFPOP, PFGDRCS, PFDRCS, PFMOT, PFMIP, PFBTT, PFAIT, PFMPT, PFMPTEX, PFTriggers };
|
||||
// Available Page Codings of X/1 to X/25 according to 9.4.2.1 of the spec
|
||||
enum PacketCodingEnum { PC7bit, PC8bit, PC18bit, PC4bit, PC4bit7bit, PCMixed };
|
||||
|
||||
PageBase();
|
||||
PageBase(const PageBase &);
|
||||
~PageBase();
|
||||
@@ -51,15 +46,8 @@ public:
|
||||
bool controlBit(int bitNumber) const { return m_controlBits[bitNumber]; }
|
||||
bool setControlBit(int, bool);
|
||||
|
||||
PageFunctionEnum pageFunction() const { return m_pageFunction; }
|
||||
bool setPageFunction(PageFunctionEnum);
|
||||
PacketCodingEnum packetCoding(int=0) const;
|
||||
bool setPacketCoding(PacketCodingEnum);
|
||||
|
||||
private:
|
||||
bool m_controlBits[8];
|
||||
PageFunctionEnum m_pageFunction;
|
||||
PacketCodingEnum m_packetCoding;
|
||||
QByteArray *m_packets[90]; // X/0 to X/25, plus 16 packets for X/26, another 16 for X/27, for X28 and for X/29
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user