emit change message after reading from file
This commit is contained in:
parent
682265bf1a
commit
c8ab63723f
1 changed files with 7 additions and 30 deletions
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
MetaDataModel::MetaDataModel(QObject *parent) : QAbstractTableModel(parent)
|
MetaDataModel::MetaDataModel(QObject *parent)
|
||||||
|
: QAbstractTableModel(parent)
|
||||||
{
|
{
|
||||||
m_dateOfBirth = QDate::currentDate().addYears(-9);
|
m_dateOfBirth = QDate::currentDate().addYears(-9);
|
||||||
m_dateOfTest = QDate::currentDate();
|
m_dateOfTest = QDate::currentDate();
|
||||||
|
@ -121,33 +122,9 @@ void MetaDataModel::write(QJsonObject &json) const
|
||||||
|
|
||||||
void MetaDataModel::read(const QJsonObject &json)
|
void MetaDataModel::read(const QJsonObject &json)
|
||||||
{
|
{
|
||||||
const auto &participant = json["participant name"];
|
setData(index(0, 0), json["participant name"].toVariant(), Qt::EditRole);
|
||||||
if (participant.isString())
|
setData(index(0, 1), json["instructor name"].toVariant(), Qt::EditRole);
|
||||||
{
|
setData(index(0, 2), json["date of birth"].toVariant(), Qt::EditRole);
|
||||||
m_participant = participant.toString();
|
setData(index(0, 3), json["date of test"].toVariant(), Qt::EditRole);
|
||||||
}
|
setData(index(0, 4), json["remarks"].toVariant(), Qt::EditRole);
|
||||||
|
|
||||||
const auto &instructor = json["instructor name"];
|
|
||||||
if (instructor.isString())
|
|
||||||
{
|
|
||||||
m_instructor = instructor.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &dateOfBirth = json["date of birth"];
|
|
||||||
if (dateOfBirth.isString())
|
|
||||||
{
|
|
||||||
m_dateOfBirth = QDate::fromString(dateOfBirth.toString(), Qt::ISODate);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &dateOfTest = json["date of test"];
|
|
||||||
if (dateOfTest.isString())
|
|
||||||
{
|
|
||||||
m_dateOfTest = QDate::fromString(dateOfTest.toString(), Qt::ISODate);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto &remarks = json["remarks"];
|
|
||||||
if (remarks.isString())
|
|
||||||
{
|
|
||||||
m_remarks = remarks.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue