Get "empty document detection" working
This commit is contained in:
10
document.cpp
10
document.cpp
@@ -29,7 +29,6 @@ TeletextDocument::TeletextDocument()
|
|||||||
m_description.clear();
|
m_description.clear();
|
||||||
m_pageFunction = PFLevelOnePage;
|
m_pageFunction = PFLevelOnePage;
|
||||||
m_packetCoding = Coding7bit;
|
m_packetCoding = Coding7bit;
|
||||||
m_empty = true;
|
|
||||||
m_subPages.push_back(new LevelOnePage);
|
m_subPages.push_back(new LevelOnePage);
|
||||||
m_currentSubPageIndex = 0;
|
m_currentSubPageIndex = 0;
|
||||||
m_undoStack = new QUndoStack(this);
|
m_undoStack = new QUndoStack(this);
|
||||||
@@ -44,6 +43,15 @@ TeletextDocument::~TeletextDocument()
|
|||||||
delete(subPage);
|
delete(subPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TeletextDocument::isEmpty() const
|
||||||
|
{
|
||||||
|
for (auto &subPage : m_subPages)
|
||||||
|
if (!subPage->isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void TeletextDocument::setPageFunction(PageFunctionEnum newPageFunction)
|
void TeletextDocument::setPageFunction(PageFunctionEnum newPageFunction)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ public:
|
|||||||
|
|
||||||
TeletextDocument();
|
TeletextDocument();
|
||||||
~TeletextDocument();
|
~TeletextDocument();
|
||||||
bool isEmpty() const { return m_empty; }
|
|
||||||
void setModified(bool);
|
bool isEmpty() const;
|
||||||
|
|
||||||
PageFunctionEnum pageFunction() const { return m_pageFunction; }
|
PageFunctionEnum pageFunction() const { return m_pageFunction; }
|
||||||
// void setPageFunction(PageFunctionEnum);
|
// void setPageFunction(PageFunctionEnum);
|
||||||
@@ -88,7 +88,6 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_description;
|
QString m_description;
|
||||||
bool m_empty;
|
|
||||||
int m_pageNumber, m_currentSubPageIndex;
|
int m_pageNumber, m_currentSubPageIndex;
|
||||||
PageFunctionEnum m_pageFunction;
|
PageFunctionEnum m_pageFunction;
|
||||||
PacketCodingEnum m_packetCoding;
|
PacketCodingEnum m_packetCoding;
|
||||||
|
|||||||
@@ -81,6 +81,23 @@ void LevelOnePage::clearPage()
|
|||||||
// If clearPage() is called outside constructor, we need to implement localEnhance.clear();
|
// If clearPage() is called outside constructor, we need to implement localEnhance.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LevelOnePage::isEmpty() const
|
||||||
|
{
|
||||||
|
if (!localEnhance.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (int i=0; i<32; i++)
|
||||||
|
if (m_CLUT[i] != defaultCLUT[i])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (int r=0; r<25; r++)
|
||||||
|
for (int c=0; c<40; c++)
|
||||||
|
if (m_level1Page[r][c] != 0x20)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray LevelOnePage::packet(int packetNumber, int designationCode) const
|
QByteArray LevelOnePage::packet(int packetNumber, int designationCode) const
|
||||||
{
|
{
|
||||||
QByteArray result(40, 0x00);
|
QByteArray result(40, 0x00);
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ public:
|
|||||||
LevelOnePage();
|
LevelOnePage();
|
||||||
LevelOnePage(const PageBase &);
|
LevelOnePage(const PageBase &);
|
||||||
|
|
||||||
|
bool isEmpty() const override;
|
||||||
|
|
||||||
QByteArray packet(int, int=0) const override;
|
QByteArray packet(int, int=0) const override;
|
||||||
bool packetNeeded(int, int=0) const override;
|
bool packetNeeded(int, int=0) const override;
|
||||||
bool setPacket(int, QByteArray) override;
|
bool setPacket(int, QByteArray) override;
|
||||||
|
|||||||
10
pagebase.cpp
10
pagebase.cpp
@@ -47,6 +47,16 @@ PageBase::~PageBase()
|
|||||||
if (m_packets[i] != nullptr)
|
if (m_packets[i] != nullptr)
|
||||||
delete m_packets[i];
|
delete m_packets[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PageBase::isEmpty() const
|
||||||
|
{
|
||||||
|
for (int i=0; i<90; i++)
|
||||||
|
if (m_packets[i] != nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray PageBase::packet(int packetNumber, int designationCode) const
|
QByteArray PageBase::packet(int packetNumber, int designationCode) const
|
||||||
{
|
{
|
||||||
int arrayIndex = packetNumber;
|
int arrayIndex = packetNumber;
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ public:
|
|||||||
PageBase(const PageBase &);
|
PageBase(const PageBase &);
|
||||||
~PageBase();
|
~PageBase();
|
||||||
|
|
||||||
|
virtual bool isEmpty() const;
|
||||||
|
|
||||||
virtual QByteArray packet(int, int=0) const;
|
virtual QByteArray packet(int, int=0) const;
|
||||||
virtual bool packetNeeded(int, int=0) const;
|
virtual bool packetNeeded(int, int=0) const;
|
||||||
virtual bool setPacket(int, QByteArray);
|
virtual bool setPacket(int, QByteArray);
|
||||||
|
|||||||
Reference in New Issue
Block a user