Clean up some old test code and make sure graphs have right paramaters to be viewed.
This commit is contained in:
@@ -16,12 +16,13 @@
|
||||
*/
|
||||
|
||||
#include "florahistory.h"
|
||||
#include <QDebug>
|
||||
|
||||
QVariant FloraHistory::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if(role == Qt::DisplayRole && tableData.size()-1 >= index.row()) {
|
||||
if(index.column() == 0) {
|
||||
return QVariant(tableData[index.row()].time.toMSecsSinceEpoch());
|
||||
return QVariant(tableData[index.row()].time);
|
||||
} else if(index.column() == 1) {
|
||||
return QVariant(tableData[index.row()].temperature);
|
||||
} else if(index.column() == 2) {
|
||||
@@ -45,43 +46,14 @@ int FloraHistory::columnCount(const QModelIndex& parent) const
|
||||
|
||||
int FloraHistory::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
//return tableData.size();
|
||||
return 23;
|
||||
}
|
||||
|
||||
QVariant FloraHistory::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if(role == Qt::DisplayRole) {
|
||||
if(section == 0) {
|
||||
return QVariant("Time");
|
||||
} else if(section == 1) {
|
||||
return QVariant("Temperature");
|
||||
} else if(section == 2) {
|
||||
return QVariant("Brightness");
|
||||
} else if(section == 3) {
|
||||
return QVariant("Moisture");
|
||||
} else if(section == 4) {
|
||||
return QVariant("Conductivity");
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags FloraHistory::flags(const QModelIndex& index) const
|
||||
{
|
||||
return QAbstractTableModel::flags(index);
|
||||
return tableData.size();
|
||||
}
|
||||
|
||||
void FloraHistory::addData(QDateTime time, float temperature, quint32 brightness, quint8 moisture, quint16 conductivity)
|
||||
{
|
||||
//beginInsertRows(QModelIndex(),tableData.size(),tableData.size());
|
||||
beginInsertRows(QModelIndex(),tableData.size(),tableData.size());
|
||||
tableData.append(flora_data{time, temperature, brightness, moisture, conductivity});
|
||||
//emit dataChanged(createIndex(0,0), createIndex(tableData.size()-1,4));
|
||||
//endInsertRows();
|
||||
emit dataChanged(createIndex(0,0),createIndex(23,4));
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
void FloraHistory::clear()
|
||||
|
||||
Reference in New Issue
Block a user