7 Star 2 Fork 1

NKEO2333/sleepHelper

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
healthy.cpp 5.31 KB
一键复制 编辑 原始数据 按行查看 历史
#include "healthy.h"
#include "ui_healthy.h"
#include "myapp.h"
#include "mydata.h"
#include "widget.h"
healthy::healthy(QWidget *parent) :
QWidget(parent),
ui(new Ui::healthy)
{
ui->setupUi(this);
QPalette palette;
palette.setBrush(QPalette::Background, QBrush(QPixmap(":/Rescoure_File/13.jpg").scaled(this->size())));
this->setPalette(palette);
this->ui->pushButton->setStyleSheet("border-image:url(:/Rescoure_File/25.png); ");
QLabel *background = new QLabel(this);
background->setPixmap(QPixmap(":/Rescoure_File/Main_BK.png"));
background->setGeometry(0, 0, this->width(), this->height());
background->lower();
background->show();
setupSleepList();
setupHeartOxyList();
}
healthy::~healthy()
{
delete ui;
}
void healthy::on_pushButton_clicked()
{
this->close();
myapp::getapp()->widget->show();
}
void healthy::onSignalReceived()
{
qDebug() << "接受到了信号";
this->ui->HeartOxy_list->clear();
this->ui->Sleep_List->clear();
setupSleepList();
setupHeartOxyList();
}
void healthy::setupSleepList()
{
// Title setup
QListWidgetItem *item_sevenDays_title = new QListWidgetItem("入 睡--起 床 打 鼾 次 数 翻 身 次 数 睡 眠 时 长");
font_sleep = item_sevenDays_title->font();
font_sleep.setPointSize(12);
item_sevenDays_title->setFont(font_sleep);
item_sevenDays_title->setIcon(QIcon(":/Rescoure_File/sleep_icon.png"));
ui->Sleep_List->addItem(item_sevenDays_title);
// Fetch and display sleep data
QString query = "SELECT get_sleep_time, wakeup_time, snore_time, filp_time, sleep_time_length "
"FROM user_sleep_info ORDER BY get_sleep_time DESC LIMIT 7";
displaySleepData(query);
}
void healthy::setupHeartOxyList()
{
// Title setup
QListWidgetItem *item_HeartOxy_title = new QListWidgetItem(" 测量时间 心率值 血氧值");
QFont font_Oxy = item_HeartOxy_title->font();
font_Oxy.setPointSize(12);
item_HeartOxy_title->setFont(font_Oxy);
item_HeartOxy_title->setIcon(QIcon(":/Rescoure_File/heart_icon.png"));
ui->HeartOxy_list->addItem(item_HeartOxy_title);
// Fetch and display heart rate and blood oxygen data
QString query = "SELECT current_timetemp, Heart_rate, blood_oxygen "
"FROM User_HeartRate_Info "
"ORDER BY current_time DESC LIMIT 10";
displayHeartOxyData(query);
}
void healthy::displaySleepData(const QString &query)
{
MyDate* data = MyDate::getdata();
char** qres_sleep_info = nullptr;
int row_sleep_info = 0;
int col_sleep_info = 0;
data->getData_exec(query.toStdString().c_str(), qres_sleep_info, row_sleep_info, col_sleep_info);
if (row_sleep_info == 0) {
qDebug() << "表中无数据!";
} else {
for (int i = 1; i <= row_sleep_info; ++i) {
QString str_time = QString(qres_sleep_info[i * col_sleep_info + 0]) + "--" + QString(qres_sleep_info[i * col_sleep_info + 1]);
str_time = str_time.left(18);
QString str_snore_time = QString(qres_sleep_info[i * col_sleep_info + 2]);
QString str_filp_time = QString(qres_sleep_info[i * col_sleep_info + 3]);
QString str_time_length = QString(qres_sleep_info[i * col_sleep_info + 4]);
QListWidgetItem *item_sleep_info = new QListWidgetItem(str_time + " " + str_snore_time + " " + str_filp_time + " " + str_time_length);
item_sleep_info->setIcon(QIcon(":/Rescoure_File/sleep_icon.png"));
item_sleep_info->setFont(font_sleep);
ui->Sleep_List->addItem(item_sleep_info);
}
}
sqlite3_free_table(qres_sleep_info);
}
void healthy::displayHeartOxyData(const QString &query)
{
MyDate* data = MyDate::getdata();
char** qres_heartOxy_info = nullptr;
int row_heartOxy_info = 0;
int col_heartOxy_info = 0;
data->getData_exec(query.toStdString().c_str(), qres_heartOxy_info, row_heartOxy_info, col_heartOxy_info);
if (row_heartOxy_info == 0) {
qDebug() << "表中无数据!";
} else {
for (int i = 1; i <= row_heartOxy_info; ++i) {
QString time_in_bloodoxygon = QString(qres_heartOxy_info[i * col_heartOxy_info + 0]);
QString heartRate =QString(qres_heartOxy_info[i * col_heartOxy_info + 1]);
QString bloodOxygen =QString(qres_heartOxy_info[i * col_heartOxy_info + 2]);
QListWidgetItem *item_HeartOxy_info = new QListWidgetItem(time_in_bloodoxygon + " " + heartRate + " " + bloodOxygen);
item_HeartOxy_info->setIcon(QIcon(":/Rescoure_File/heart_icon.png"));
item_HeartOxy_info->setFont(font_Oxy);
ui->HeartOxy_list->addItem(item_HeartOxy_info);
}
}
sqlite3_free_table(qres_heartOxy_info);
}
void healthy::readData()
{
QByteArray data = this->client->readAll();
// Read data and process it
}
void healthy::on_server_clicked()
{
this->server = new QTcpServer(this);
this->server->listen(QHostAddress("192.168.110.161"), 9999);
connect(this->server, &QTcpServer::newConnection, this, [=]()
{
this->client = this->server->nextPendingConnection();
connect(this->client, &QTcpSocket::readyRead, this, &healthy::readData);
});
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/NEKO12580/sleephelper.git
git@gitee.com:NEKO12580/sleephelper.git
NEKO12580
sleephelper
sleepHelper
master

搜索帮助