From 093f18ab363840fff796c14e6c7ad7b93dd0ffc6 Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Thu, 13 Oct 2022 11:03:30 +0200 Subject: testing charts --- client/mainwindow.cpp | 20 +++++++++++++++++--- client/mainwindow.h | 7 ++++++- client/mainwindow.ui | 4 ++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 955307e..80a7658 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -32,11 +32,25 @@ void MainWindow::on_pushButton_clicked() // dbRef.setPassword("Ab12345!"); // dbRef.setDatabaseName("thecrapbox"); + series = new QLineSeries(); + QChart *chart = new QChart(); + if(dbRef.open()){ QMessageBox::information(this, "Connection", "GREAT SUCCES!"); - pQueryModel = new QSqlQueryModel(); - pQueryModel->setQuery("SELECT * FROM opleiding;"); - ui->tableView->setModel(pQueryModel); + QSqlQuery queryGraphData; + queryGraphData.exec("SELECT id, temp FROM tblMain LIMIT 16 ORDER BY desc;"); +// ui->tableView->setModel(pQueryModel); + for (int i = 0; queryGraphData.next(); ++i) { + series->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).toInt()); + } + chart->legend()->show(); + chart->addSeries(series); + chart->createDefaultAxes(); + chart->setTitle("Hellow!"); + chartView = new QChartView(chart); + + MainWindow::setCentralWidget(chartView); + } else { QMessageBox::warning(this, "No connection", "Failed to connect"); } diff --git a/client/mainwindow.h b/client/mainwindow.h index 1e73657..78f2ce6 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -8,6 +8,10 @@ #include #include #include +#include +#include +#include + #include "main.h" @@ -36,7 +40,8 @@ private: dbConnector *_dbConenctor; // QSqlDatabase db; - QSqlQueryModel *pQueryModel; + QLineSeries *series; + QChartView *chartView; // Database database; }; diff --git a/client/mainwindow.ui b/client/mainwindow.ui index f827c85..e55caa0 100644 --- a/client/mainwindow.ui +++ b/client/mainwindow.ui @@ -41,7 +41,7 @@ - + @@ -52,7 +52,7 @@ 0 0 800 - 21 + 24 -- cgit v1.2.3 From 94db9a165fbb95d951d76cebb0937240b5d39545 Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Mon, 24 Oct 2022 17:02:09 +0200 Subject: 't worked just a minute ago' --- client/dbconnector.cpp | 9 +++------ client/dbconnector.h | 4 ---- client/dbconnector.ui | 5 ++++- client/main.cpp | 9 +++++---- client/mainwindow.cpp | 54 ++++++++++++++++++++++++-------------------------- client/mainwindow.h | 9 +++++---- client/mainwindow.ui | 54 +++++++++++++++++++++----------------------------- client/ui_mainwindow.h | 2 +- 8 files changed, 67 insertions(+), 79 deletions(-) diff --git a/client/dbconnector.cpp b/client/dbconnector.cpp index 5ed1efc..e925851 100644 --- a/client/dbconnector.cpp +++ b/client/dbconnector.cpp @@ -26,19 +26,16 @@ void dbConnector::on_pushButton_login_clicked() QString hostname = ui->lineEdit_adress->text(); QString username = ui->lineEdit_username->text(); QString password = ui->lineEdit_password->text(); - QString databaseName = "thecrapbox"; + QString databaseName = ui->lineEdit_database->text(); -// QSqlDatabase db = MainWindow.loginDb(adress, username, password); - -// QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); -// return; dbRef.setHostName(hostname); dbRef.setUserName(username); dbRef.setPassword(password); - dbRef.setDatabaseName("thecrapbox"); + dbRef.setDatabaseName(databaseName); if(dbRef.open()){ QMessageBox::information(this, "Connection", "GREAT SUCCES!"); + dbConnector::~dbConnector(); } else { QMessageBox::warning(this, "No connection", "Failed to connect"); } diff --git a/client/dbconnector.h b/client/dbconnector.h index cd722eb..db8ac4e 100644 --- a/client/dbconnector.h +++ b/client/dbconnector.h @@ -6,7 +6,6 @@ //#include //#include -//#include "database.h" namespace Ui { class dbConnector; @@ -21,7 +20,6 @@ public: ~dbConnector(); private slots: -// void on_pushButton_clicked(); void on_pushButton_cancel_clicked(); @@ -29,6 +27,4 @@ private slots: private: Ui::dbConnector *ui; - -// Database database; }; diff --git a/client/dbconnector.ui b/client/dbconnector.ui index 21d241f..1159faf 100644 --- a/client/dbconnector.ui +++ b/client/dbconnector.ui @@ -49,6 +49,9 @@ + + WSdb + Database name @@ -98,7 +101,7 @@ - + Ab12345! QLineEdit::Password diff --git a/client/main.cpp b/client/main.cpp index 0f6b816..8561786 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -9,8 +9,8 @@ #include #include -#include "chart.h" -#include "chartview.h" +//#include "chart.h" +//#include "chartview.h" #include "mainwindow.h" #include "main.h" #include "ui_mainwindow.h" @@ -25,8 +25,9 @@ int main(int argc, char *argv[]) TimeTest time; MyTcpSocket s; // s.doConnect(); - MainWindow w; - dbRef = QSqlDatabase::addDatabase("QMYSQL"); + MainWindow w; + + dbRef = QSqlDatabase::addDatabase("QMYSQL"); w.show(); return a.exec(); diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 80a7658..1e74ed0 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -4,11 +4,12 @@ #include "ui_mainwindow.h" #include "main.h" +//#include + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { -// db = QSqlDatabase::addDatabase("QMYSQL"); ui->setupUi(this); } @@ -18,47 +19,44 @@ MainWindow::~MainWindow() delete ui; } -void MainWindow::on_actionAbout_triggered() +void MainWindow::on_actionConnection_triggered() { - QMessageBox::warning(this, "Oops..", "Task Failed succesfully ;)"); + _dbConenctor = new dbConnector(this); + _dbConenctor->show(); } -void MainWindow::on_pushButton_clicked() +void MainWindow::on_actionRefresh_triggered() { -// dbRef = QSqlDatabase::addDatabase("QMYSQL"); -// dbRef.setHostName("localhost"); -// dbRef.setUserName("root"); -// dbRef.setPassword("Ab12345!"); -// dbRef.setDatabaseName("thecrapbox"); - - series = new QLineSeries(); - QChart *chart = new QChart(); + QLineSeries *seriesTemperature = new QLineSeries(); + QLineSeries *seriesHumidity = new QLineSeries(); + _pChart = new QChart(); if(dbRef.open()){ - QMessageBox::information(this, "Connection", "GREAT SUCCES!"); QSqlQuery queryGraphData; - queryGraphData.exec("SELECT id, temp FROM tblMain LIMIT 16 ORDER BY desc;"); -// ui->tableView->setModel(pQueryModel); + queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain` ORDER BY `tblMain`.`ID` DESC limit 16;"); +// queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain`;"); + for (int i = 0; queryGraphData.next(); ++i) { - series->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).toInt()); +// seriesTemp->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).toInt()); + seriesTemperature->append(i, queryGraphData.value(1).toFloat()); + seriesHumidity->append(i, queryGraphData.value(2).toFloat()*100); } - chart->legend()->show(); - chart->addSeries(series); - chart->createDefaultAxes(); - chart->setTitle("Hellow!"); - chartView = new QChartView(chart); - MainWindow::setCentralWidget(chartView); + _pChart->legend()->show(); + _pChart->addSeries(seriesTemperature); + _pChart->addSeries(seriesHumidity); + _pChart->createDefaultAxes(); + _pChart->setTitle("Weather data:"); + _pChartView = new QChartView(_pChart); + + MainWindow::setCentralWidget(_pChartView); + } else { QMessageBox::warning(this, "No connection", "Failed to connect"); } -} - -void MainWindow::on_actionConnection_triggered() -{ - _dbConenctor = new dbConnector(this); - _dbConenctor->show(); +// delete seriesTemperature; +// delete seriesHumidity; } diff --git a/client/mainwindow.h b/client/mainwindow.h index 78f2ce6..cf3c6e4 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -34,14 +34,15 @@ private slots: void on_actionConnection_triggered(); + void on_actionRefresh_triggered(); + private: Ui::MainWindow *ui; dbConnector *_dbConenctor; -// QSqlDatabase db; - QLineSeries *series; - QChartView *chartView; + QChart *_pChart; +// QLineSeries *_pSeries; + QChartView *_pChartView; -// Database database; }; diff --git a/client/mainwindow.ui b/client/mainwindow.ui index e55caa0..4ced639 100644 --- a/client/mainwindow.ui +++ b/client/mainwindow.ui @@ -14,35 +14,35 @@ MainWindow - - - true - - - - 310 - 0 - 121 - 41 - - - - DoesSomething - - - + - -10 - 40 - 801 - 401 + 90 + 80 + 621 + 301 - - + + + QLayout::SetDefaultConstraint + + + + + + + + + + + + Reload + + + @@ -62,13 +62,6 @@ - - - TEMP - - - - Database @@ -78,7 +71,6 @@ - diff --git a/client/ui_mainwindow.h b/client/ui_mainwindow.h index 8854685..e91631c 100644 --- a/client/ui_mainwindow.h +++ b/client/ui_mainwindow.h @@ -10,7 +10,7 @@ #define UI_MAINWINDOW_H #include -#include +//#include #include #include #include -- cgit v1.2.3 From 7b9db4b508c1dfbe79c7c702f1cd11ffbd05b9bd Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Tue, 25 Oct 2022 16:14:58 +0200 Subject: Added all three line graphs --- client/mainwindow.cpp | 8 ++++++-- client/mainwindow.ui | 37 +++++++++++-------------------------- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index 1e74ed0..d3da553 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -30,6 +30,7 @@ void MainWindow::on_actionRefresh_triggered() { QLineSeries *seriesTemperature = new QLineSeries(); QLineSeries *seriesHumidity = new QLineSeries(); + QLineSeries *seriesPressure = new QLineSeries(); _pChart = new QChart(); if(dbRef.open()){ @@ -41,11 +42,13 @@ void MainWindow::on_actionRefresh_triggered() // seriesTemp->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).toInt()); seriesTemperature->append(i, queryGraphData.value(1).toFloat()); seriesHumidity->append(i, queryGraphData.value(2).toFloat()*100); + seriesPressure->append(i, queryGraphData.value(3).toFloat()); } _pChart->legend()->show(); _pChart->addSeries(seriesTemperature); _pChart->addSeries(seriesHumidity); + _pChart->addSeries(seriesPressure); _pChart->createDefaultAxes(); _pChart->setTitle("Weather data:"); _pChartView = new QChartView(_pChart); @@ -56,7 +59,8 @@ void MainWindow::on_actionRefresh_triggered() } else { QMessageBox::warning(this, "No connection", "Failed to connect"); } -// delete seriesTemperature; -// delete seriesHumidity; + delete seriesTemperature; + delete seriesHumidity; + delete seriesPressure; } diff --git a/client/mainwindow.ui b/client/mainwindow.ui index 4ced639..f08cb23 100644 --- a/client/mainwindow.ui +++ b/client/mainwindow.ui @@ -14,36 +14,18 @@ MainWindow - + - 90 - 80 - 621 - 301 + 300 + 210 + 181 + 51 - - - QLayout::SetDefaultConstraint - - - - - - - - - - - - - - Reload - - - - + + Please load data first + @@ -83,6 +65,9 @@ Refresh + + Ctrl+R + -- cgit v1.2.3 From d9d4d4b35c90b81ed91eb29a33f0ae22635d8a8b Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Wed, 26 Oct 2022 14:35:47 +0200 Subject: working, no lines showing --- client/dbconnector.cpp | 2 +- client/mainwindow.cpp | 47 +++++++++++++++++++++++++++++++++-------------- client/mainwindow.h | 8 ++++++-- client/mainwindow.ui | 20 +++----------------- 4 files changed, 43 insertions(+), 34 deletions(-) diff --git a/client/dbconnector.cpp b/client/dbconnector.cpp index e925851..186f8f7 100644 --- a/client/dbconnector.cpp +++ b/client/dbconnector.cpp @@ -2,7 +2,7 @@ #include "ui_dbconnector.h" #include "main.h" -//#include "mainwindow.h" +#include "mainwindow.h" dbConnector::dbConnector(QWidget *parent) : QDialog(parent), diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index d3da553..d8b12cb 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -4,7 +4,7 @@ #include "ui_mainwindow.h" #include "main.h" -//#include +#include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) @@ -25,30 +25,48 @@ void MainWindow::on_actionConnection_triggered() _dbConenctor->show(); } - void MainWindow::on_actionRefresh_triggered() { - QLineSeries *seriesTemperature = new QLineSeries(); + drawGraph(); +} + +void MainWindow::on_actionDisconnenct_triggered() +{ + dbRef.close(); +} + + +void MainWindow::drawGraph(){ +// QLineSeries *seriesTemperature; +// seriesTemperature = new QLineSeries(); QLineSeries *seriesHumidity = new QLineSeries(); - QLineSeries *seriesPressure = new QLineSeries(); - _pChart = new QChart(); +// QLineSeries *seriesPressure = new QLineSeries(); + if(dbRef.open()){ QSqlQuery queryGraphData; - queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain` ORDER BY `tblMain`.`ID` DESC limit 16;"); -// queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain`;"); +// queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain` ORDER BY `tblMain`.`ID` DESC limit 16;"); + queryGraphData.exec("select * FROM `tblMain`ORDER BY `tblMain`.`ID` DESC limit 16;"); for (int i = 0; queryGraphData.next(); ++i) { // seriesTemp->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).toInt()); - seriesTemperature->append(i, queryGraphData.value(1).toFloat()); - seriesHumidity->append(i, queryGraphData.value(2).toFloat()*100); - seriesPressure->append(i, queryGraphData.value(3).toFloat()); +// seriesTemperature->append(i, queryGraphData.value(1).toInt()); +// seriesHumidity->append(i, queryGraphData.value(2).toFloat()); + seriesHumidity->append(i,i); +// seriesPressure->append(i, queryGraphData.value(3).toFloat()); + qDebug() << queryGraphData.value(2).toFloat(); } + QPen pen(QRgb(0x57FF00)); + pen.setWidth(5); + seriesHumidity->setPen(pen); + + + _pChart = new QChart(); _pChart->legend()->show(); - _pChart->addSeries(seriesTemperature); +// _pChart->addSeries(seriesTemperature); _pChart->addSeries(seriesHumidity); - _pChart->addSeries(seriesPressure); +// _pChart->addSeries(seriesPressure); _pChart->createDefaultAxes(); _pChart->setTitle("Weather data:"); _pChartView = new QChartView(_pChart); @@ -59,8 +77,9 @@ void MainWindow::on_actionRefresh_triggered() } else { QMessageBox::warning(this, "No connection", "Failed to connect"); } - delete seriesTemperature; +// delete seriesTemperature; delete seriesHumidity; - delete seriesPressure; +// delete seriesPressure; } + diff --git a/client/mainwindow.h b/client/mainwindow.h index cf3c6e4..25e22ec 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -27,15 +27,19 @@ public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); + virtual void drawGraph(); + private slots: - void on_actionAbout_triggered(); +// void on_actionAbout_triggered(); - void on_pushButton_clicked(); +// void on_pushButton_clicked(); void on_actionConnection_triggered(); void on_actionRefresh_triggered(); + void on_actionDisconnenct_triggered(); + private: Ui::MainWindow *ui; diff --git a/client/mainwindow.ui b/client/mainwindow.ui index f08cb23..eb17fe2 100644 --- a/client/mainwindow.ui +++ b/client/mainwindow.ui @@ -41,7 +41,6 @@ Home - @@ -50,17 +49,11 @@ - - - - About - - Refresh @@ -83,22 +76,15 @@ Connect + + Ctrl+O + Disconnenct - - - Querry - - - - - Status - - -- cgit v1.2.3 From 615dd097b7a03c73d0c9c922a652287d1e8a7466 Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Wed, 26 Oct 2022 16:53:07 +0200 Subject: 3 seperate graphs working --- client/mainwindow.cpp | 75 +++++++++++++++------- client/mainwindow.ui | 4 +- client/ui_dbconnector.h | 162 ------------------------------------------------ client/ui_mainwindow.h | 143 ------------------------------------------ 4 files changed, 55 insertions(+), 329 deletions(-) delete mode 100644 client/ui_dbconnector.h delete mode 100644 client/ui_mainwindow.h diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index d8b12cb..cc19b53 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -37,49 +37,80 @@ void MainWindow::on_actionDisconnenct_triggered() void MainWindow::drawGraph(){ -// QLineSeries *seriesTemperature; -// seriesTemperature = new QLineSeries(); + QLineSeries *seriesTemperature = new QLineSeries(); QLineSeries *seriesHumidity = new QLineSeries(); -// QLineSeries *seriesPressure = new QLineSeries(); + QLineSeries *seriesPressure = new QLineSeries(); + if(dbRef.open()){ QSqlQuery queryGraphData; // queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain` ORDER BY `tblMain`.`ID` DESC limit 16;"); - queryGraphData.exec("select * FROM `tblMain`ORDER BY `tblMain`.`ID` DESC limit 16;"); + queryGraphData.exec("select * FROM `tblMain` ORDER BY `tblMain`.`ID` ASC limit 16;"); for (int i = 0; queryGraphData.next(); ++i) { -// seriesTemp->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).toInt()); +// int time = queryGraphData.value(4).toTime().hour()*100 + queryGraphData.value(4).toTime().minute(); + int time = i; +// seriesPressure->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).toFloat()); // seriesTemperature->append(i, queryGraphData.value(1).toInt()); // seriesHumidity->append(i, queryGraphData.value(2).toFloat()); - seriesHumidity->append(i,i); -// seriesPressure->append(i, queryGraphData.value(3).toFloat()); - qDebug() << queryGraphData.value(2).toFloat(); +// seriesPressure->append(i, queryGraphData.value(3).toInt()); + + seriesTemperature->append(time, queryGraphData.value(1).toFloat()); + seriesHumidity->append(time, queryGraphData.value(2).toFloat()); + seriesPressure->append(time, (queryGraphData.value(3).toFloat()*100)); + +// qDebug() << time; } - QPen pen(QRgb(0x57FF00)); - pen.setWidth(5); - seriesHumidity->setPen(pen); +// QPen pen(QRgb(0x57FF00)); +// pen.setWidth(5); +// seriesHumidity->setPen(pen); + + + QChart *chartTemperature = new QChart(); + chartTemperature->legend()->hide(); + chartTemperature->addSeries(seriesTemperature); + chartTemperature->createDefaultAxes(); + chartTemperature->setTitle("Temperature!"); + QChartView *chartView1 = new QChartView(chartTemperature); + + QChart *chartHumidity = new QChart(); + chartHumidity->legend()->hide(); + chartHumidity->addSeries(seriesHumidity); + chartHumidity->createDefaultAxes(); + chartHumidity->setTitle("Humidity!"); + QChartView *chartView2 = new QChartView(chartHumidity); + QChart *chartPressure = new QChart(); + chartPressure->legend()->hide(); + chartPressure->addSeries(seriesPressure); + chartPressure->createDefaultAxes(); + chartPressure->setTitle("Pressure!"); + QChartView *chartView3 = new QChartView(chartPressure); - _pChart = new QChart(); - _pChart->legend()->show(); -// _pChart->addSeries(seriesTemperature); - _pChart->addSeries(seriesHumidity); -// _pChart->addSeries(seriesPressure); - _pChart->createDefaultAxes(); - _pChart->setTitle("Weather data:"); - _pChartView = new QChartView(_pChart); - MainWindow::setCentralWidget(_pChartView); + QWidget *window = new QWidget; + QGridLayout *layout = new QGridLayout(window); + layout->addWidget(chartView1, 0 ,0); + layout->addWidget(chartView2, 1 ,0); + layout->addWidget(chartView3, 2 ,0); + layout->setVerticalSpacing(0); + layout->setHorizontalSpacing(0); + layout->setContentsMargins(0,0,0,0); + + + +// window->show(); + + MainWindow::setCentralWidget(window); } else { QMessageBox::warning(this, "No connection", "Failed to connect"); } // delete seriesTemperature; - delete seriesHumidity; +// delete seriesHumidity; // delete seriesPressure; } - diff --git a/client/mainwindow.ui b/client/mainwindow.ui index eb17fe2..a31ffdc 100644 --- a/client/mainwindow.ui +++ b/client/mainwindow.ui @@ -17,8 +17,8 @@ - 300 - 210 + 270 + 190 181 51 diff --git a/client/ui_dbconnector.h b/client/ui_dbconnector.h deleted file mode 100644 index afb6f11..0000000 --- a/client/ui_dbconnector.h +++ /dev/null @@ -1,162 +0,0 @@ -/******************************************************************************** -** Form generated from reading UI file 'dbconnector.ui' -** -** Created by: Qt User Interface Compiler version 5.15.6 -** -** WARNING! All changes made in this file will be lost when recompiling UI file! -********************************************************************************/ - -#ifndef UI_DBCONNECTOR_H -#define UI_DBCONNECTOR_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class Ui_dbConnector -{ -public: - QWidget *formLayoutWidget; - QFormLayout *formLayout; - QLabel *label_3; - QLineEdit *lineEdit_adress; - QLabel *label_4; - QLineEdit *lineEdit_database; - QFrame *line; - QLabel *label; - QLineEdit *lineEdit_username; - QLabel *label_2; - QLineEdit *lineEdit_password; - QLabel *connectLabel; - QHBoxLayout *horizontalLayout; - QPushButton *pushButton_login; - QPushButton *pushButton_cancel; - - void setupUi(QDialog *dbConnector) - { - if (dbConnector->objectName().isEmpty()) - dbConnector->setObjectName(QString::fromUtf8("dbConnector")); - dbConnector->resize(362, 273); - formLayoutWidget = new QWidget(dbConnector); - formLayoutWidget->setObjectName(QString::fromUtf8("formLayoutWidget")); - formLayoutWidget->setGeometry(QRect(60, 60, 241, 173)); - formLayout = new QFormLayout(formLayoutWidget); - formLayout->setObjectName(QString::fromUtf8("formLayout")); - formLayout->setContentsMargins(0, 0, 0, 0); - label_3 = new QLabel(formLayoutWidget); - label_3->setObjectName(QString::fromUtf8("label_3")); - - formLayout->setWidget(0, QFormLayout::LabelRole, label_3); - - lineEdit_adress = new QLineEdit(formLayoutWidget); - lineEdit_adress->setObjectName(QString::fromUtf8("lineEdit_adress")); - - formLayout->setWidget(0, QFormLayout::FieldRole, lineEdit_adress); - - label_4 = new QLabel(formLayoutWidget); - label_4->setObjectName(QString::fromUtf8("label_4")); - - formLayout->setWidget(1, QFormLayout::LabelRole, label_4); - - lineEdit_database = new QLineEdit(formLayoutWidget); - lineEdit_database->setObjectName(QString::fromUtf8("lineEdit_database")); - - formLayout->setWidget(1, QFormLayout::FieldRole, lineEdit_database); - - line = new QFrame(formLayoutWidget); - line->setObjectName(QString::fromUtf8("line")); - line->setFrameShape(QFrame::HLine); - line->setFrameShadow(QFrame::Sunken); - - formLayout->setWidget(2, QFormLayout::SpanningRole, line); - - label = new QLabel(formLayoutWidget); - label->setObjectName(QString::fromUtf8("label")); - - formLayout->setWidget(3, QFormLayout::LabelRole, label); - - lineEdit_username = new QLineEdit(formLayoutWidget); - lineEdit_username->setObjectName(QString::fromUtf8("lineEdit_username")); - lineEdit_username->setEchoMode(QLineEdit::PasswordEchoOnEdit); - - formLayout->setWidget(3, QFormLayout::FieldRole, lineEdit_username); - - label_2 = new QLabel(formLayoutWidget); - label_2->setObjectName(QString::fromUtf8("label_2")); - - formLayout->setWidget(4, QFormLayout::LabelRole, label_2); - - lineEdit_password = new QLineEdit(formLayoutWidget); - lineEdit_password->setObjectName(QString::fromUtf8("lineEdit_password")); - QFont font; - font.setUnderline(false); - font.setStrikeOut(false); - font.setKerning(true); - lineEdit_password->setFont(font); - lineEdit_password->setEchoMode(QLineEdit::Password); - - formLayout->setWidget(4, QFormLayout::FieldRole, lineEdit_password); - - connectLabel = new QLabel(formLayoutWidget); - connectLabel->setObjectName(QString::fromUtf8("connectLabel")); - - formLayout->setWidget(5, QFormLayout::LabelRole, connectLabel); - - horizontalLayout = new QHBoxLayout(); - horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout")); - pushButton_login = new QPushButton(formLayoutWidget); - pushButton_login->setObjectName(QString::fromUtf8("pushButton_login")); - - horizontalLayout->addWidget(pushButton_login); - - pushButton_cancel = new QPushButton(formLayoutWidget); - pushButton_cancel->setObjectName(QString::fromUtf8("pushButton_cancel")); - - horizontalLayout->addWidget(pushButton_cancel); - - - formLayout->setLayout(5, QFormLayout::FieldRole, horizontalLayout); - - - retranslateUi(dbConnector); - - QMetaObject::connectSlotsByName(dbConnector); - } // setupUi - - void retranslateUi(QDialog *dbConnector) - { - dbConnector->setWindowTitle(QCoreApplication::translate("dbConnector", "Dialog", nullptr)); - label_3->setText(QCoreApplication::translate("dbConnector", "Adress", nullptr)); - lineEdit_adress->setText(QCoreApplication::translate("dbConnector", "localhost", nullptr)); - lineEdit_adress->setPlaceholderText(QCoreApplication::translate("dbConnector", "Hostname/IP-Adress", nullptr)); - label_4->setText(QCoreApplication::translate("dbConnector", "Database", nullptr)); - lineEdit_database->setPlaceholderText(QCoreApplication::translate("dbConnector", "Database name", nullptr)); - label->setText(QCoreApplication::translate("dbConnector", "Username", nullptr)); - lineEdit_username->setText(QCoreApplication::translate("dbConnector", "root", nullptr)); - lineEdit_username->setPlaceholderText(QCoreApplication::translate("dbConnector", "Username", nullptr)); - label_2->setText(QCoreApplication::translate("dbConnector", "Password", nullptr)); - lineEdit_password->setText(QString()); - lineEdit_password->setPlaceholderText(QCoreApplication::translate("dbConnector", "Password", nullptr)); - connectLabel->setText(QCoreApplication::translate("dbConnector", "Connect", nullptr)); - pushButton_login->setText(QCoreApplication::translate("dbConnector", "Login", nullptr)); - pushButton_cancel->setText(QCoreApplication::translate("dbConnector", "Cancel", nullptr)); - } // retranslateUi - -}; - -namespace Ui { - class dbConnector: public Ui_dbConnector {}; -} // namespace Ui - -QT_END_NAMESPACE - -#endif // UI_DBCONNECTOR_H diff --git a/client/ui_mainwindow.h b/client/ui_mainwindow.h deleted file mode 100644 index e91631c..0000000 --- a/client/ui_mainwindow.h +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************** -** Form generated from reading UI file 'mainwindow.ui' -** -** Created by: Qt User Interface Compiler version 5.15.6 -** -** WARNING! All changes made in this file will be lost when recompiling UI file! -********************************************************************************/ - -#ifndef UI_MAINWINDOW_H -#define UI_MAINWINDOW_H - -#include -//#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class Ui_MainWindow -{ -public: - QAction *actionAbout; - QAction *actionRefresh; - QAction *actionLOAD; - QAction *actionQuerry; - QAction *actionConnection; - QAction *actionDisconnenct; - QAction *actionQuerry_2; - QAction *actionStatus; - QWidget *centralwidget; - QPushButton *pushButton; - QWidget *verticalLayoutWidget; - QVBoxLayout *verticalLayout; - QTableView *tableView; - QMenuBar *menubar; - QMenu *menuAbouy; - QMenu *menuTEMP; - QMenu *menuDatabase; - QStatusBar *statusbar; - - void setupUi(QMainWindow *MainWindow) - { - if (MainWindow->objectName().isEmpty()) - MainWindow->setObjectName(QString::fromUtf8("MainWindow")); - MainWindow->resize(800, 600); - actionAbout = new QAction(MainWindow); - actionAbout->setObjectName(QString::fromUtf8("actionAbout")); - actionRefresh = new QAction(MainWindow); - actionRefresh->setObjectName(QString::fromUtf8("actionRefresh")); - actionLOAD = new QAction(MainWindow); - actionLOAD->setObjectName(QString::fromUtf8("actionLOAD")); - actionQuerry = new QAction(MainWindow); - actionQuerry->setObjectName(QString::fromUtf8("actionQuerry")); - actionConnection = new QAction(MainWindow); - actionConnection->setObjectName(QString::fromUtf8("actionConnection")); - actionDisconnenct = new QAction(MainWindow); - actionDisconnenct->setObjectName(QString::fromUtf8("actionDisconnenct")); - actionQuerry_2 = new QAction(MainWindow); - actionQuerry_2->setObjectName(QString::fromUtf8("actionQuerry_2")); - actionStatus = new QAction(MainWindow); - actionStatus->setObjectName(QString::fromUtf8("actionStatus")); - centralwidget = new QWidget(MainWindow); - centralwidget->setObjectName(QString::fromUtf8("centralwidget")); - pushButton = new QPushButton(centralwidget); - pushButton->setObjectName(QString::fromUtf8("pushButton")); - pushButton->setEnabled(true); - pushButton->setGeometry(QRect(310, 0, 121, 41)); - verticalLayoutWidget = new QWidget(centralwidget); - verticalLayoutWidget->setObjectName(QString::fromUtf8("verticalLayoutWidget")); - verticalLayoutWidget->setGeometry(QRect(-10, 40, 801, 401)); - verticalLayout = new QVBoxLayout(verticalLayoutWidget); - verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); - verticalLayout->setContentsMargins(0, 0, 0, 0); - tableView = new QTableView(verticalLayoutWidget); - tableView->setObjectName(QString::fromUtf8("tableView")); - - verticalLayout->addWidget(tableView); - - MainWindow->setCentralWidget(centralwidget); - menubar = new QMenuBar(MainWindow); - menubar->setObjectName(QString::fromUtf8("menubar")); - menubar->setGeometry(QRect(0, 0, 800, 21)); - menuAbouy = new QMenu(menubar); - menuAbouy->setObjectName(QString::fromUtf8("menuAbouy")); - menuTEMP = new QMenu(menubar); - menuTEMP->setObjectName(QString::fromUtf8("menuTEMP")); - menuDatabase = new QMenu(menubar); - menuDatabase->setObjectName(QString::fromUtf8("menuDatabase")); - MainWindow->setMenuBar(menubar); - statusbar = new QStatusBar(MainWindow); - statusbar->setObjectName(QString::fromUtf8("statusbar")); - MainWindow->setStatusBar(statusbar); - - menubar->addAction(menuAbouy->menuAction()); - menubar->addAction(menuTEMP->menuAction()); - menubar->addAction(menuDatabase->menuAction()); - menuAbouy->addAction(actionAbout); - menuAbouy->addAction(actionRefresh); - menuTEMP->addAction(actionLOAD); - menuTEMP->addAction(actionQuerry); - menuDatabase->addAction(actionConnection); - menuDatabase->addAction(actionDisconnenct); - menuDatabase->addAction(actionStatus); - - retranslateUi(MainWindow); - - QMetaObject::connectSlotsByName(MainWindow); - } // setupUi - - void retranslateUi(QMainWindow *MainWindow) - { - MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr)); - actionAbout->setText(QCoreApplication::translate("MainWindow", "About", nullptr)); - actionRefresh->setText(QCoreApplication::translate("MainWindow", "Refresh", nullptr)); - actionLOAD->setText(QCoreApplication::translate("MainWindow", "Load", nullptr)); - actionQuerry->setText(QCoreApplication::translate("MainWindow", "Query", nullptr)); - actionConnection->setText(QCoreApplication::translate("MainWindow", "Connect", nullptr)); - actionDisconnenct->setText(QCoreApplication::translate("MainWindow", "Disconnenct", nullptr)); - actionQuerry_2->setText(QCoreApplication::translate("MainWindow", "Querry", nullptr)); - actionStatus->setText(QCoreApplication::translate("MainWindow", "Status", nullptr)); - pushButton->setText(QCoreApplication::translate("MainWindow", "DoesSomething", nullptr)); - menuAbouy->setTitle(QCoreApplication::translate("MainWindow", "Home", nullptr)); - menuTEMP->setTitle(QCoreApplication::translate("MainWindow", "TEMP", nullptr)); - menuDatabase->setTitle(QCoreApplication::translate("MainWindow", "Database", nullptr)); - } // retranslateUi - -}; - -namespace Ui { - class MainWindow: public Ui_MainWindow {}; -} // namespace Ui - -QT_END_NAMESPACE - -#endif // UI_MAINWINDOW_H -- cgit v1.2.3 From cea50941344fb435de58e08e3086ada80c97cef7 Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Wed, 26 Oct 2022 20:42:05 +0200 Subject: Qt graphs working --- client/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp index cc19b53..e1736e6 100644 --- a/client/mainwindow.cpp +++ b/client/mainwindow.cpp @@ -46,7 +46,7 @@ void MainWindow::drawGraph(){ if(dbRef.open()){ QSqlQuery queryGraphData; // queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain` ORDER BY `tblMain`.`ID` DESC limit 16;"); - queryGraphData.exec("select * FROM `tblMain` ORDER BY `tblMain`.`ID` ASC limit 16;"); + queryGraphData.exec("select * FROM `tblMain` ORDER BY `tblMain`.`ID` DESC limit 190;"); for (int i = 0; queryGraphData.next(); ++i) { // int time = queryGraphData.value(4).toTime().hour()*100 + queryGraphData.value(4).toTime().minute(); -- cgit v1.2.3 From 28af8ed412224bd8969db98521b67e0f4027ddf7 Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Wed, 26 Oct 2022 20:42:50 +0200 Subject: added seeded data for temperature and humidity --- scripts/db-add.sql | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 194 insertions(+) create mode 100644 scripts/db-add.sql diff --git a/scripts/db-add.sql b/scripts/db-add.sql new file mode 100644 index 0000000..6b202aa --- /dev/null +++ b/scripts/db-add.sql @@ -0,0 +1,194 @@ +INSERT INTO `WSdb`.`tblMain` (temperature, humidity) VALUES +-- 20.6, 77.7, 0.59, now() +(23.6,57), +(23.6,57), +(23.6,56), +(23.6,56), +(23.5,58), +(23.4,59), +(23.4,59), +(23.4,60), +(23.4,60), +(23.4,60), +(23.3,60), +(23.3,60), +(23.3,60), +(23.2,60), +(23.4,60), +(23.3,60), +(23.2,60), +(23.2,59), +(23.1,59), +(23.1,59), +(23.0,59), +(23.0,59), +(22.9,59), +(22.9,59), +(22.9,58), +(22.8,58), +(22.8,58), +(22.8,58), +(22.8,58), +(22.7,58), +(22.7,58), +(22.7,58), +(22.6,58), +(22.6,58), +(22.6,58), +(22.6,58), +(22.5,58), +(22.5,58), +(22.5,58), +(22.4,58), +(22.4,58), +(22.4,58), +(22.4,57), +(22.4,57), +(22.3,57), +(22.3,57), +(22.3,57), +(22.3,57), +(22.3,57), +(22.4,57), +(22.7,57), +(22.9,57), +(23.0,57), +(23.2,57), +(23.2,57), +(23.1,59), +(23.0,59), +(23.0,59), +(23.2,58), +(23.4,58), +(23.4,58), +(23.5,57), +(23.6,57), +(23.7,57), +(23.7,57), +(23.8,57), +(23.9,57), +(23.8,59), +(23.8,59), +(23.7,58), +(23.6,58), +(23.5,58), +(23.5,58), +(23.4,57), +(23.5,59), +(23.8,58), +(23.7,59), +(23.7,59), +(23.7,59), +(23.9,59), +(23.8,57), +(23.7,56), +(23.5,55), +(23.4,54), +(23.4,54), +(23.6,53), +(23.6,56), +(23.7,55), +(23.7,54), +(23.8,54), +(23.8,54), +(23.8,55), +(23.7,55), +(23.6,55), +(23.5,55), +(23.5,56), +(23.4,56), +(23.4,58), +(23.3,59), +(23.4,63), +(23.4,63), +(23.4,63), +(23.4,63), +(23.4,63), +(23.3,64), +(23.2,63), +(23.2,62), +(23.1,62), +(23.1,61), +(23.0,61), +(22.9,61), +(22.9,61), +(22.9,61), +(22.8,60), +(22.8,60), +(22.8,60), +(22.7,60), +(22.7,60), +(22.6,60), +(22.6,60), +(22.5,59), +(22.5,59), +(22.5,59), +(22.4,59), +(22.4,59), +(22.4,59), +(22.4,59), +(22.4,59), +(22.4,58), +(22.3,58), +(22.3,58), +(22.3,58), +(22.3,58), +(22.2,58), +(22.2,58), +(22.2,58), +(22.2,58), +(22.2,58), +(22.1,58), +(22.1,58), +(22.1,58), +(22.1,57), +(22.0,57), +(22.0,57), +(22.0,57), +(22.1,58), +(22.4,57), +(22.5,58), +(22.6,58), +(22.7,58), +(22.8,58), +(22.9,58), +(22.9,58), +(22.8,57), +(22.7,57), +(22.7,57), +(22.9,57), +(22.9,57), +(23.0,58), +(23.2,58), +(23.3,58), +(23.2,59), +(23.2,59), +(23.2,58), +(23.4,58), +(23.6,59), +(23.7,59), +(23.9,59), +(24.0,58), +(23.9,55), +(23.9,54), +(23.9,55), +(24.0,55), +(24.2,55), +(24.2,55), +(24.1,56), +(24.0,55), +(24.0,56), +(23.9,57), +(23.9,56), +(24.0,55), +(24.1,55), +(23.9,56), +(23.9,56), +(23.9,56), +(23.9,56), +(23.8,56), +(23.8,56), +(23.7,56), +(23.7,56), +(23.6,58), +(23.6,59); -- cgit v1.2.3