Added temperature monitor screen. Added current factors for BMS configuration
This commit is contained in:
63
currenttablemodel.cpp
Normal file
63
currenttablemodel.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
#include "currenttablemodel.h"
|
||||
|
||||
CurrentTableModel::CurrentTableModel(QObject* parent) :
|
||||
QAbstractTableModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
CurrentTableModel::~CurrentTableModel()
|
||||
{
|
||||
}
|
||||
|
||||
void CurrentTableModel::setCurrentData(const QVariantList& data)
|
||||
{
|
||||
beginResetModel();
|
||||
data_.clear();
|
||||
|
||||
for (const auto& row: data)
|
||||
{
|
||||
QList<float> rowData;
|
||||
for (const auto& column: row.toList())
|
||||
{
|
||||
rowData.push_back(column.toFloat());
|
||||
}
|
||||
data_.push_back(rowData);
|
||||
}
|
||||
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
void CurrentTableModel::setCurrentData(const QList<QList<float>>& data)
|
||||
{
|
||||
beginResetModel();
|
||||
data_ = data;
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
int CurrentTableModel::rowCount(const QModelIndex&) const
|
||||
{
|
||||
return data_.size();
|
||||
}
|
||||
|
||||
int CurrentTableModel::columnCount(const QModelIndex&) const
|
||||
{
|
||||
return data_.empty() ? 0 : data_.at(0).size();
|
||||
}
|
||||
|
||||
QVariant CurrentTableModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return QString::number(data_.at(index.row()).at(index.column()));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> CurrentTableModel::roleNames() const
|
||||
{
|
||||
return { {Qt::DisplayRole, "display"} };
|
||||
}
|
||||
Reference in New Issue
Block a user