Move page function and packet coding
This commit is contained in:
@@ -41,6 +41,9 @@ public:
|
|||||||
|
|
||||||
LevelOnePage();
|
LevelOnePage();
|
||||||
|
|
||||||
|
PageFunctionEnum pageFunction() const override { return PFLevelOnePage; }
|
||||||
|
PacketCodingEnum packetCoding() const override { return Coding7bit; }
|
||||||
|
|
||||||
bool isEmpty() const override;
|
bool isEmpty() const override;
|
||||||
|
|
||||||
QByteArray packet(int y, int d) const override;
|
QByteArray packet(int y, int d) const override;
|
||||||
|
|||||||
@@ -29,9 +29,16 @@ class PageBase //: public QObject
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
enum ControlBitsEnum { C4ErasePage, C5Newsflash, C6Subtitle, C7SuppressHeader, C8Update, C9InterruptedSequence, C10InhibitDisplay, C11SerialMagazine, C12NOS, C13NOS, C14NOS };
|
enum ControlBitsEnum { C4ErasePage, C5Newsflash, C6Subtitle, C7SuppressHeader, C8Update, C9InterruptedSequence, C10InhibitDisplay, C11SerialMagazine, C12NOS, C13NOS, C14NOS };
|
||||||
|
// Available Page Functions according to 9.4.2.1 of the spec
|
||||||
|
enum PageFunctionEnum { PFUnknown = -1, 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 { CodingUnknown = -1, Coding7bit, Coding8bit, Coding18bit, Coding4bit, Coding4bitThen7bit, CodingPerPacket };
|
||||||
|
|
||||||
PageBase();
|
PageBase();
|
||||||
|
|
||||||
|
virtual PageFunctionEnum pageFunction() const { return PFUnknown; }
|
||||||
|
virtual PacketCodingEnum packetCoding() const { return CodingUnknown; }
|
||||||
|
|
||||||
virtual bool isEmpty() const;
|
virtual bool isEmpty() const;
|
||||||
|
|
||||||
virtual QByteArray packet(int y) const { return m_displayPackets[y]; }
|
virtual QByteArray packet(int y) const { return m_displayPackets[y]; }
|
||||||
@@ -40,9 +47,9 @@ public:
|
|||||||
virtual bool setPacket(int y, int d, QByteArray pkt);
|
virtual bool setPacket(int y, int d, QByteArray pkt);
|
||||||
virtual bool packetExists(int y) const { return !m_displayPackets[y].isEmpty(); }
|
virtual bool packetExists(int y) const { return !m_displayPackets[y].isEmpty(); }
|
||||||
virtual bool packetExists(int y, int d) const { return !m_designationPackets[y-26][d].isEmpty(); }
|
virtual bool packetExists(int y, int d) const { return !m_designationPackets[y-26][d].isEmpty(); }
|
||||||
bool clearPacket(int y);
|
virtual bool clearPacket(int y);
|
||||||
bool clearPacket(int y, int d);
|
virtual bool clearPacket(int y, int d);
|
||||||
void clearAllPackets();
|
virtual void clearAllPackets();
|
||||||
|
|
||||||
virtual bool controlBit(int b) const { return m_controlBits[b]; }
|
virtual bool controlBit(int b) const { return m_controlBits[b]; }
|
||||||
virtual bool setControlBit(int b, bool active);
|
virtual bool setControlBit(int b, bool active);
|
||||||
|
|||||||
@@ -62,8 +62,6 @@ TeletextDocument::TeletextDocument()
|
|||||||
{
|
{
|
||||||
m_pageNumber = 0x199;
|
m_pageNumber = 0x199;
|
||||||
m_description.clear();
|
m_description.clear();
|
||||||
m_pageFunction = PFLevelOnePage;
|
|
||||||
m_packetCoding = Coding7bit;
|
|
||||||
m_subPages.append(new LevelOnePage);
|
m_subPages.append(new LevelOnePage);
|
||||||
m_currentSubPageIndex = 0;
|
m_currentSubPageIndex = 0;
|
||||||
m_undoStack = new QUndoStack(this);
|
m_undoStack = new QUndoStack(this);
|
||||||
@@ -113,18 +111,6 @@ void TeletextDocument::clear()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void TeletextDocument::setPageFunction(PageFunctionEnum newPageFunction)
|
|
||||||
{
|
|
||||||
m_pageFunction = newPageFunction;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TeletextDocument::setPacketCoding(PacketCodingEnum newPacketEncoding)
|
|
||||||
{
|
|
||||||
m_packetCoding = newPacketEncoding;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void TeletextDocument::selectSubPageIndex(int newSubPageIndex, bool forceRefresh)
|
void TeletextDocument::selectSubPageIndex(int newSubPageIndex, bool forceRefresh)
|
||||||
{
|
{
|
||||||
// forceRefresh overrides "beyond the last subpage" check, so inserting a subpage after the last one still shows - dangerous workaround?
|
// forceRefresh overrides "beyond the last subpage" check, so inserting a subpage after the last one still shows - dangerous workaround?
|
||||||
|
|||||||
@@ -48,22 +48,12 @@ class TeletextDocument : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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();
|
||||||
~TeletextDocument();
|
~TeletextDocument();
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
PageFunctionEnum pageFunction() const { return m_pageFunction; }
|
|
||||||
// void setPageFunction(PageFunctionEnum);
|
|
||||||
PacketCodingEnum packetCoding() const { return m_packetCoding; }
|
|
||||||
// void setPacketCoding(PacketCodingEnum);
|
|
||||||
|
|
||||||
int numberOfSubPages() const { return m_subPages.size(); }
|
int numberOfSubPages() const { return m_subPages.size(); }
|
||||||
LevelOnePage* subPage(int p) const { return m_subPages[p]; }
|
LevelOnePage* subPage(int p) const { return m_subPages[p]; }
|
||||||
LevelOnePage* currentSubPage() const { return m_subPages[m_currentSubPageIndex]; }
|
LevelOnePage* currentSubPage() const { return m_subPages[m_currentSubPageIndex]; }
|
||||||
@@ -121,8 +111,6 @@ signals:
|
|||||||
private:
|
private:
|
||||||
QString m_description;
|
QString m_description;
|
||||||
int m_pageNumber, m_currentSubPageIndex;
|
int m_pageNumber, m_currentSubPageIndex;
|
||||||
PageFunctionEnum m_pageFunction;
|
|
||||||
PacketCodingEnum m_packetCoding;
|
|
||||||
QList<LevelOnePage *> m_subPages;
|
QList<LevelOnePage *> m_subPages;
|
||||||
QList<LevelOnePage *> m_recycleSubPages;
|
QList<LevelOnePage *> m_recycleSubPages;
|
||||||
QUndoStack *m_undoStack;
|
QUndoStack *m_undoStack;
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ void SaveFormat::writeSubPageBody(const PageBase &subPage)
|
|||||||
{
|
{
|
||||||
writeX27Packets(subPage);
|
writeX27Packets(subPage);
|
||||||
writeX28Packets(subPage);
|
writeX28Packets(subPage);
|
||||||
if (m_document->pageFunction() == TeletextDocument::PFLevelOnePage) {
|
if (subPage.pageFunction() == PageBase::PFLevelOnePage) {
|
||||||
writeX26Packets(subPage);
|
writeX26Packets(subPage);
|
||||||
writeX1to25Packets(subPage);
|
writeX1to25Packets(subPage);
|
||||||
} else {
|
} else {
|
||||||
@@ -173,7 +173,7 @@ void SaveTTIFormat::writeSubPageStart(const PageBase &subPage, int subPageNumber
|
|||||||
|
|
||||||
// Subpage
|
// Subpage
|
||||||
// Magazine Organisation Table and Magazine Inventory Page don't have subpages
|
// Magazine Organisation Table and Magazine Inventory Page don't have subpages
|
||||||
if (m_document->pageFunction() != TeletextDocument::PFMOT && m_document->pageFunction() != TeletextDocument::PFMIP)
|
if (subPage.pageFunction() != PageBase::PFMOT && subPage.pageFunction() != PageBase::PFMIP)
|
||||||
writeString(QString("SC,%1").arg(subPageNumber, 4, 10, QChar('0')));
|
writeString(QString("SC,%1").arg(subPageNumber, 4, 10, QChar('0')));
|
||||||
|
|
||||||
// Status bits
|
// Status bits
|
||||||
@@ -190,14 +190,14 @@ void SaveTTIFormat::writeSubPageStart(const PageBase &subPage, int subPageNumber
|
|||||||
|
|
||||||
writeString(QString("PS,%1").arg(0x8000 | statusBits, 4, 16, QChar('0')));
|
writeString(QString("PS,%1").arg(0x8000 | statusBits, 4, 16, QChar('0')));
|
||||||
|
|
||||||
if (m_document->pageFunction() == TeletextDocument::PFLevelOnePage) {
|
if (subPage.pageFunction() == PageBase::PFLevelOnePage) {
|
||||||
// Level One Page: page region and cycle
|
// Level One Page: page region and cycle
|
||||||
writeString(QString("RE,%1").arg(static_cast<const LevelOnePage *>(&subPage)->defaultCharSet()));
|
writeString(QString("RE,%1").arg(static_cast<const LevelOnePage *>(&subPage)->defaultCharSet()));
|
||||||
writeString(QString("CT,%1,%2").arg(static_cast<const LevelOnePage *>(&subPage)->cycleValue()).arg(static_cast<const LevelOnePage *>(&subPage)->cycleType()==LevelOnePage::CTcycles ? 'C' : 'T'));
|
writeString(QString("CT,%1,%2").arg(static_cast<const LevelOnePage *>(&subPage)->cycleValue()).arg(static_cast<const LevelOnePage *>(&subPage)->cycleType()==LevelOnePage::CTcycles ? 'C' : 'T'));
|
||||||
} else
|
} else
|
||||||
// Not a Level One Page: X/28/0 specifies page function and coding but the PF command
|
// Not a Level One Page: X/28/0 specifies page function and coding but the PF command
|
||||||
// should make it obvious to a human that this is not a Level One Page
|
// should make it obvious to a human that this is not a Level One Page
|
||||||
writeString(QString("PF,%1,%2").arg(m_document->pageFunction()).arg(m_document->packetCoding()));
|
writeString(QString("PF,%1,%2").arg(subPage.pageFunction()).arg(subPage.packetCoding()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveTTIFormat::writeSubPageBody(const PageBase &subPage)
|
void SaveTTIFormat::writeSubPageBody(const PageBase &subPage)
|
||||||
@@ -208,7 +208,7 @@ void SaveTTIFormat::writeSubPageBody(const PageBase &subPage)
|
|||||||
|
|
||||||
// FLOF links
|
// FLOF links
|
||||||
bool writeFLCommand = false;
|
bool writeFLCommand = false;
|
||||||
if (m_document->pageFunction() == TeletextDocument::PFLevelOnePage && subPage.packetExists(27,0)) {
|
if (subPage.pageFunction() == PageBase::PFLevelOnePage && subPage.packetExists(27,0)) {
|
||||||
// Subpage has FLOF links - if any link to a specific subpage we need to write X/27/0
|
// Subpage has FLOF links - if any link to a specific subpage we need to write X/27/0
|
||||||
// as raw, otherwise we write the links as a human-readable FL command later on
|
// as raw, otherwise we write the links as a human-readable FL command later on
|
||||||
writeFLCommand = true;
|
writeFLCommand = true;
|
||||||
@@ -231,7 +231,7 @@ void SaveTTIFormat::writeSubPageBody(const PageBase &subPage)
|
|||||||
|
|
||||||
// Now write the other packets like the rest of writeSubPageBody does
|
// Now write the other packets like the rest of writeSubPageBody does
|
||||||
writeX28Packets(subPage);
|
writeX28Packets(subPage);
|
||||||
if (m_document->pageFunction() == TeletextDocument::PFLevelOnePage) {
|
if (subPage.pageFunction() == PageBase::PFLevelOnePage) {
|
||||||
writeX26Packets(subPage);
|
writeX26Packets(subPage);
|
||||||
writeX1to25Packets(subPage);
|
writeX1to25Packets(subPage);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user