replace flatpak config with published one. Only builds from git now.
Made large progress on getting history from device.
This commit is contained in:
93
src/miflora/florahistory.cpp
Normal file
93
src/miflora/florahistory.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Kevin Whitaker <eyecreate@eyecreate.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "florahistory.h"
|
||||
|
||||
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());
|
||||
} else if(index.column() == 1) {
|
||||
return QVariant(tableData[index.row()].temperature);
|
||||
} else if(index.column() == 2) {
|
||||
return QVariant(tableData[index.row()].brightness);
|
||||
} else if(index.column() == 3) {
|
||||
return QVariant(tableData[index.row()].moisture);
|
||||
} else if(index.column() == 4) {
|
||||
return QVariant(tableData[index.row()].conductivity);
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
} else {
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
int FloraHistory::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void FloraHistory::addData(QDateTime time, float temperature, quint32 brightness, quint8 moisture, quint16 conductivity)
|
||||
{
|
||||
//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));
|
||||
}
|
||||
|
||||
void FloraHistory::clear()
|
||||
{
|
||||
tableData.clear();
|
||||
emit layoutChanged();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user