added setData and flags
This commit is contained in:
parent
fc4875dd27
commit
4d781c3523
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.15.0, 2021-05-24T12:12:52. -->
|
||||
<!-- Written by QtCreator 4.15.0, 2021-05-24T23:36:50. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user