diff --git a/sources/SQM-GUI-ng.pro.user b/sources/SQM-GUI-ng.pro.user index 96473c8..a322928 100644 --- a/sources/SQM-GUI-ng.pro.user +++ b/sources/SQM-GUI-ng.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/sources/sqmtablemodel.cpp b/sources/sqmtablemodel.cpp index 6a0ca9e..25a7287 100644 --- a/sources/sqmtablemodel.cpp +++ b/sources/sqmtablemodel.cpp @@ -27,6 +27,30 @@ QVariant SQMTableModel::data(const QModelIndex &index, int role) const { } +bool SQMTableModel::setData(const QModelIndex &index, const QVariant &value, int role) { + if (role == Qt::EditRole) { + if (!checkIndex(index)) { + return false; + } + int row = index.row(); + int col = index.column(); + + + // call calculateSqmMatrix + sqmMatrix.at(col).at(row) = value.toInt(); + CalculateSqmMatrix(row); + return true; + } + return false; +} + + +Qt::ItemFlags SQMTableModel::flags(const QModelIndex &index) const { + return Qt::ItemIsEditable | QAbstractTableModel::flags(index); +} + + + void SQMTableModel::SetStartValues(int pBase, int pExp, int pMod) { base = pBase; exp = pExp; diff --git a/sources/sqmtablemodel.h b/sources/sqmtablemodel.h index 65354c2..dd4a914 100644 --- a/sources/sqmtablemodel.h +++ b/sources/sqmtablemodel.h @@ -12,6 +12,8 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; + Qt::ItemFlags flags(const QModelIndex &index) const override; void SetStartValues(int pBase, int pExp, int pMod);