This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
ESGRAF48/source/ResultWidget/ResultModel.h

59 lines
982 B
C
Raw Normal View History

2018-06-06 16:05:30 +00:00
#pragma once
#include <vector>
#include <QAbstractTableModel>
#include <QDate>
2018-06-06 16:05:30 +00:00
class TestResult
{
private:
QString m_name;
size_t m_points;
2018-06-06 16:05:30 +00:00
public:
TestResult(const char *name)
: m_name(name)
, m_points(0)
2018-06-06 16:05:30 +00:00
{
}
void operator=(const size_t &points)
{
m_points = points;
}
2018-06-06 16:05:30 +00:00
const QString &name() const
{
return m_name;
}
const size_t points() const
{
return m_points;
}
2018-06-06 16:05:30 +00:00
};
class ResultModel : public QAbstractTableModel
{
Q_OBJECT
private:
QDate m_age;
2018-06-06 16:05:30 +00:00
std::vector<TestResult> m_results;
public:
ResultModel(QObject *parent);
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;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const override;
void setAge(const QDate &age);
void setPluralResult(size_t points);
2018-06-06 16:05:30 +00:00
};