Move page status bits to PageBase superclass

This commit is contained in:
G.K.MacGregor
2020-09-16 12:47:46 +01:00
parent 0f864c7787
commit 959822bd95
4 changed files with 14 additions and 8 deletions

View File

@@ -40,8 +40,6 @@ void LevelOnePage::clearPage()
for (int r=0; r<25; r++)
for (int c=0; c<40; c++)
m_level1Page[r][c] = 0x20;
for (int i=0; i<8; i++)
m_controlBits[i] = false;
/* m_subPageNumber = 0x0000; */
m_cycleValue = 8;
m_cycleType = CTseconds;
@@ -316,9 +314,9 @@ void LevelOnePage::savePage(QTextStream *outStream, int pageNumber, int subPageN
int LevelOnePage::controlBitsToPS() const
{
//TODO map page language for regions other than 0
int pageStatus = 0x8000 | (m_controlBits[0] << 14) | ((m_defaultNOS & 1) << 9) | ((m_defaultNOS & 2) << 7) | ((m_defaultNOS & 4) << 5);
int pageStatus = 0x8000 | (controlBit(0) << 14) | ((m_defaultNOS & 1) << 9) | ((m_defaultNOS & 2) << 7) | ((m_defaultNOS & 4) << 5);
for (int i=1; i<8; i++)
pageStatus |= m_controlBits[i] << (i-1);
pageStatus |= controlBit(i) << (i-1);
return pageStatus;
}
@@ -379,7 +377,6 @@ QString LevelOnePage::exportURLHash(QString pageHash)
}
/* void LevelOnePage::setSubPageNumber(int newSubPageNumber) { m_subPageNumber = newSubPageNumber; } */
void LevelOnePage::setControlBit(int bitNumber, bool active) { m_controlBits[bitNumber] = active; }
void LevelOnePage::setCycleValue(int newValue) { m_cycleValue = newValue; };
void LevelOnePage::setCycleType(CycleTypeEnum newType) { m_cycleType = newType; }
void LevelOnePage::setDefaultCharSet(int newDefaultCharSet) { m_defaultCharSet = newDefaultCharSet; }

View File

@@ -53,8 +53,6 @@ public:
QString exportURLHash(QString);
/* void setSubPageNumber(int); */
bool controlBit(int bitNumber) const { return m_controlBits[bitNumber]; }
void setControlBit(int, bool);
int cycleValue() const { return m_cycleValue; };
void setCycleValue(int);
CycleTypeEnum cycleType() const { return m_cycleType; };
@@ -96,7 +94,6 @@ protected:
private:
unsigned char m_level1Page[25][40];
/* int m_subPageNumber; */
bool m_controlBits[8];
int m_cycleValue;
CycleTypeEnum m_cycleType;
int m_defaultCharSet, m_defaultNOS, m_secondCharSet, m_secondNOS;

View File

@@ -28,6 +28,8 @@ PageBase::PageBase()
// 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;
for (int i=0; i<8; i++)
m_controlBits[i] = false;
}
PageBase::~PageBase()
@@ -89,6 +91,12 @@ bool PageBase::deletePacket(int packetNumber, int designationCode)
return true;
}
bool PageBase::setControlBit(int bitNumber, bool active)
{
m_controlBits[bitNumber] = active;
return true;
}
PageBase::PacketCodingEnum PageBase::packetCoding(int packetNumber, int designationCode) const
{
switch (packetNumber) {

View File

@@ -41,12 +41,16 @@ public:
bool setPacket(int, int, QByteArray);
bool deletePacket(int, int=0);
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, 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