From a76a04f15cbfc4dac4bac598ba55ba8e4db3d085 Mon Sep 17 00:00:00 2001 From: moerp Date: Sat, 29 May 2021 19:22:46 +0200 Subject: [PATCH] everything working --- sources/sqmtablemodel.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sources/sqmtablemodel.cpp b/sources/sqmtablemodel.cpp index 7311497..168515f 100644 --- a/sources/sqmtablemodel.cpp +++ b/sources/sqmtablemodel.cpp @@ -81,6 +81,9 @@ bool SQMTableModel::setData(const QModelIndex &index, const QVariant &value, int int row = index.row(); int col = index.column(); + if (col == 0 && value.toInt() != 0 && value.toInt() != 1) { + return false; + } // call calculateSqmMatrix sqmMatrix.at(col).at(row) = value.toInt(); @@ -174,10 +177,14 @@ void SQMTableModel::UpdateSqmMatrix(QModelIndex startIndex) { // Update sqmMatrix for (int i = start_row; i < binLen; i++) { - if (start_col != 1) { - sqmMatrix.at(1).at(i) = (sqmMatrix.at(2).at(i - 1) * sqmMatrix.at(2).at(i - 1)) % mod; - + if (start_row == 0 && start_col == 0) { + sqmMatrix.at(1).at(i) = 1; + start_row = 1; } + else if (start_col != 1) { + sqmMatrix.at(1).at(i) = (sqmMatrix.at(2).at(i - 1) * sqmMatrix.at(2).at(i - 1)) % mod; + } + start_col = 0; if (sqmMatrix.at(0).at(i) == 0) { sqmMatrix.at(2).at(i) = sqmMatrix.at(1).at(i);