aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/dbconnector.cpp2
-rw-r--r--client/mainwindow.cpp47
-rw-r--r--client/mainwindow.h8
-rw-r--r--client/mainwindow.ui20
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 <QDebug>
+#include <QDebug>
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 @@
<property name="title">
<string>Home</string>
</property>
- <addaction name="actionAbout"/>
<addaction name="actionRefresh"/>
</widget>
<widget class="QMenu" name="menuDatabase">
@@ -50,17 +49,11 @@
</property>
<addaction name="actionConnection"/>
<addaction name="actionDisconnenct"/>
- <addaction name="actionStatus"/>
</widget>
<addaction name="menuAbouy"/>
<addaction name="menuDatabase"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
- <action name="actionAbout">
- <property name="text">
- <string>About</string>
- </property>
- </action>
<action name="actionRefresh">
<property name="text">
<string>Refresh</string>
@@ -83,22 +76,15 @@
<property name="text">
<string>Connect</string>
</property>
+ <property name="shortcut">
+ <string>Ctrl+O</string>
+ </property>
</action>
<action name="actionDisconnenct">
<property name="text">
<string>Disconnenct</string>
</property>
</action>
- <action name="actionQuerry_2">
- <property name="text">
- <string>Querry</string>
- </property>
- </action>
- <action name="actionStatus">
- <property name="text">
- <string>Status</string>
- </property>
- </action>
</widget>
<resources/>
<connections/>