Enforce 16 packet limit in Local Enhancement list

This commit is contained in:
G.K.MacGregor
2021-04-25 18:51:59 +01:00
parent d3607f5b00
commit 4584ba668d
4 changed files with 8 additions and 2 deletions

View File

@@ -27,13 +27,13 @@
LevelOnePage::LevelOnePage() LevelOnePage::LevelOnePage()
{ {
m_enhancements.reserve(208); m_enhancements.reserve(maxEnhancements());
clearPage(); clearPage();
} }
LevelOnePage::LevelOnePage(const PageBase &other) LevelOnePage::LevelOnePage(const PageBase &other)
{ {
m_enhancements.reserve(208); m_enhancements.reserve(maxEnhancements());
clearPage(); clearPage();
for (int i=0; i<26; i++) for (int i=0; i<26; i++)

View File

@@ -52,6 +52,8 @@ public:
void clearPage(); void clearPage();
int maxEnhancements() const { return 208; };
/* void setSubPageNumber(int); */ /* void setSubPageNumber(int); */
int cycleValue() const { return m_cycleValue; }; int cycleValue() const { return m_cycleValue; };
void setCycleValue(int); void setCycleValue(int);

View File

@@ -32,6 +32,7 @@ class PageX26Base : public PageBase //: public QObject
public: public:
QList<X26Triplet> *enhancements() { return &m_enhancements; }; QList<X26Triplet> *enhancements() { return &m_enhancements; };
virtual int maxEnhancements() const =0;
protected: protected:
QByteArray packetFromEnhancementList(int) const; QByteArray packetFromEnhancementList(int) const;

View File

@@ -799,6 +799,9 @@ bool X26Model::insertRows(int row, int count, const QModelIndex &parent)
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
if (m_parentMainWidget->document()->currentSubPage()->enhancements()->size() + count > m_parentMainWidget->document()->currentSubPage()->maxEnhancements())
return false;
m_parentMainWidget->document()->undoStack()->push(new InsertTripletCommand(m_parentMainWidget->document(), this, row, count, m_parentMainWidget->document()->currentSubPage()->enhancements()->at(row))); m_parentMainWidget->document()->undoStack()->push(new InsertTripletCommand(m_parentMainWidget->document(), this, row, count, m_parentMainWidget->document()->currentSubPage()->enhancements()->at(row)));
return true; return true;
} }