notify result widget about plural test changes
This commit is contained in:
parent
1f9a051382
commit
077efaac32
11 changed files with 107 additions and 5 deletions
|
@ -5,7 +5,8 @@
|
|||
ResultModel::ResultModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
m_results = {{ "V2", "SVK", "VE", "Passiv", "Genus", "Akkusativ", "Dativ", "Genitiv", "Plural" }};
|
||||
m_results = { { "V2", "SVK", "VE", "Passiv", "Genus", "Akkusativ", "Dativ",
|
||||
"Genitiv", "Plural" } };
|
||||
}
|
||||
|
||||
int ResultModel::rowCount(const QModelIndex &parent) const
|
||||
|
@ -22,7 +23,16 @@ QVariant ResultModel::data(const QModelIndex &index, int role) const
|
|||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
return "data";
|
||||
if (index.column() < m_results.size())
|
||||
{
|
||||
size_t points = m_results[index.column()].points();
|
||||
if (points != 0)
|
||||
{
|
||||
return static_cast<uint>(points);
|
||||
}
|
||||
}
|
||||
|
||||
return "-";
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -59,3 +69,17 @@ QVariant ResultModel::headerData(
|
|||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
void ResultModel::setAge(const QDate &age)
|
||||
{
|
||||
m_age = age;
|
||||
}
|
||||
|
||||
void ResultModel::setPluralResult(size_t points)
|
||||
{
|
||||
if (m_results[8].points() != points)
|
||||
{
|
||||
m_results[8] = points;
|
||||
emit dataChanged(index(0, 8), index(2, 8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,22 +2,35 @@
|
|||
|
||||
#include <vector>
|
||||
#include <QAbstractTableModel>
|
||||
#include <QDate>
|
||||
|
||||
class TestResult
|
||||
{
|
||||
private:
|
||||
QString m_name;
|
||||
size_t m_points;
|
||||
|
||||
public:
|
||||
TestResult(const char *name)
|
||||
: m_name(name)
|
||||
, m_points(0)
|
||||
{
|
||||
}
|
||||
|
||||
void operator=(const size_t &points)
|
||||
{
|
||||
m_points = points;
|
||||
}
|
||||
|
||||
const QString &name() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
const size_t points() const
|
||||
{
|
||||
return m_points;
|
||||
}
|
||||
};
|
||||
|
||||
class ResultModel : public QAbstractTableModel
|
||||
|
@ -25,6 +38,7 @@ class ResultModel : public QAbstractTableModel
|
|||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QDate m_age;
|
||||
std::vector<TestResult> m_results;
|
||||
|
||||
public:
|
||||
|
@ -38,4 +52,7 @@ public:
|
|||
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
|
||||
void setAge(const QDate &age);
|
||||
void setPluralResult(size_t points);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue