Initial QT project upload

This commit is contained in:
2026-05-04 02:48:33 +08:00
commit fca1ea21d2
43 changed files with 7367 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
#include "StatisticsListModel.h"
StatisticsListModel::StatisticsListModel(QObject *parent)
: QAbstractListModel(parent)
{
}
int StatisticsListModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid()) {
return 0;
}
return m_items.size();
}
QVariant StatisticsListModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row() < 0 || index.row() >= m_items.size()) {
return {};
}
const Item &item = m_items.at(index.row());
switch (role) {
case StudentIdRole: return item.studentId;
case NameRole: return item.name;
case TotalCountRole: return item.totalCount;
case TodayCountRole: return item.todayCount;
case LastCheckInRole: return item.lastCheckIn;
case AverageConfidenceRole: return item.averageConfidence;
case AverageConfidenceTextRole: return QString::number(item.averageConfidence * 100.0, 'f', 2) + "%";
default: return {};
}
}
QHash<int, QByteArray> StatisticsListModel::roleNames() const
{
return {
{StudentIdRole, "studentId"},
{NameRole, "name"},
{TotalCountRole, "totalCount"},
{TodayCountRole, "todayCount"},
{LastCheckInRole, "lastCheckIn"},
{AverageConfidenceRole, "averageConfidence"},
{AverageConfidenceTextRole, "averageConfidenceText"}
};
}
void StatisticsListModel::setItems(const QVector<Item> &items)
{
beginResetModel();
m_items = items;
endResetModel();
}