aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/chart.cpp72
-rw-r--r--client/chart.h59
-rw-r--r--client/chartview.cpp109
-rw-r--r--client/chartview.h58
-rw-r--r--client/dbconnector.cpp27
-rw-r--r--client/dbconnector.h6
-rw-r--r--client/dbconnector.ui55
-rw-r--r--client/main.cpp16
-rw-r--r--client/mainwindow.cpp13
-rw-r--r--client/mainwindow.ui13
10 files changed, 80 insertions, 348 deletions
diff --git a/client/chart.cpp b/client/chart.cpp
deleted file mode 100644
index bf2825e..0000000
--- a/client/chart.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Charts module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "chart.h"
-#include <QtWidgets/QGesture>
-#include <QtWidgets/QGraphicsScene>
-#include <QtWidgets/QGraphicsView>
-
-Chart::Chart(QGraphicsItem *parent, Qt::WindowFlags wFlags)
- : QChart(QChart::ChartTypeCartesian, parent, wFlags)
-{
- // Seems that QGraphicsView (QChartView) does not grab gestures.
- // They can only be grabbed here in the QGraphicsWidget (QChart).
- grabGesture(Qt::PanGesture);
- grabGesture(Qt::PinchGesture);
-}
-
-Chart::~Chart()
-{
-
-}
-
-//![1]
-bool Chart::sceneEvent(QEvent *event)
-{
- if (event->type() == QEvent::Gesture)
- return gestureEvent(static_cast<QGestureEvent *>(event));
- return QChart::event(event);
-}
-
-bool Chart::gestureEvent(QGestureEvent *event)
-{
- if (QGesture *gesture = event->gesture(Qt::PanGesture)) {
- QPanGesture *pan = static_cast<QPanGesture *>(gesture);
- QChart::scroll(-(pan->delta().x()), pan->delta().y());
- }
-
- if (QGesture *gesture = event->gesture(Qt::PinchGesture)) {
- QPinchGesture *pinch = static_cast<QPinchGesture *>(gesture);
- if (pinch->changeFlags() & QPinchGesture::ScaleFactorChanged)
- QChart::zoom(pinch->scaleFactor());
- }
-
- return true;
-}
-//![1]
diff --git a/client/chart.h b/client/chart.h
deleted file mode 100644
index 3ea7593..0000000
--- a/client/chart.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Charts module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CHART_H
-#define CHART_H
-
-#include <QtCharts/QChart>
-
-QT_BEGIN_NAMESPACE
-class QGestureEvent;
-QT_END_NAMESPACE
-
-QT_CHARTS_USE_NAMESPACE
-
-//![1]
-class Chart : public QChart
-//![1]
-{
-public:
- explicit Chart(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = {});
- ~Chart();
-
-protected:
- bool sceneEvent(QEvent *event);
-
-private:
- bool gestureEvent(QGestureEvent *event);
-
-private:
-
-};
-
-#endif // CHART_H
diff --git a/client/chartview.cpp b/client/chartview.cpp
deleted file mode 100644
index cb78034..0000000
--- a/client/chartview.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Charts module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "chartview.h"
-#include <QtGui/QMouseEvent>
-
-ChartView::ChartView(QChart *chart, QWidget *parent) :
- QChartView(chart, parent),
- m_isTouching(false)
-{
- setRubberBand(QChartView::RectangleRubberBand);
-}
-
-bool ChartView::viewportEvent(QEvent *event)
-{
- if (event->type() == QEvent::TouchBegin) {
- // By default touch events are converted to mouse events. So
- // after this event we will get a mouse event also but we want
- // to handle touch events as gestures only. So we need this safeguard
- // to block mouse events that are actually generated from touch.
- m_isTouching = true;
-
- // Turn off animations when handling gestures they
- // will only slow us down.
- chart()->setAnimationOptions(QChart::NoAnimation);
- }
- return QChartView::viewportEvent(event);
-}
-
-void ChartView::mousePressEvent(QMouseEvent *event)
-{
- if (m_isTouching)
- return;
- QChartView::mousePressEvent(event);
-}
-
-void ChartView::mouseMoveEvent(QMouseEvent *event)
-{
- if (m_isTouching)
- return;
- QChartView::mouseMoveEvent(event);
-}
-
-void ChartView::mouseReleaseEvent(QMouseEvent *event)
-{
- if (m_isTouching)
- m_isTouching = false;
-
- // Because we disabled animations when touch event was detected
- // we must put them back on.
- chart()->setAnimationOptions(QChart::SeriesAnimations);
-
- QChartView::mouseReleaseEvent(event);
-}
-
-//![1]
-void ChartView::keyPressEvent(QKeyEvent *event)
-{
- switch (event->key()) {
- case Qt::Key_Plus:
- chart()->zoomIn();
- break;
- case Qt::Key_Minus:
- chart()->zoomOut();
- break;
-//![1]
- case Qt::Key_Left:
- chart()->scroll(-10, 0);
- break;
- case Qt::Key_Right:
- chart()->scroll(10, 0);
- break;
- case Qt::Key_Up:
- chart()->scroll(0, 10);
- break;
- case Qt::Key_Down:
- chart()->scroll(0, -10);
- break;
- default:
- QGraphicsView::keyPressEvent(event);
- break;
- }
-}
diff --git a/client/chartview.h b/client/chartview.h
deleted file mode 100644
index 502b946..0000000
--- a/client/chartview.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Charts module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef CHARTVIEW_H
-#define CHARTVIEW_H
-
-#include <QtCharts/QChartView>
-#include <QtWidgets/QRubberBand>
-
-QT_CHARTS_USE_NAMESPACE
-
-//![1]
-class ChartView : public QChartView
-//![1]
-{
-public:
- ChartView(QChart *chart, QWidget *parent = 0);
-
-//![2]
-protected:
- bool viewportEvent(QEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void keyPressEvent(QKeyEvent *event);
-//![2]
-
-private:
- bool m_isTouching;
-};
-
-#endif
diff --git a/client/dbconnector.cpp b/client/dbconnector.cpp
index 186f8f7..256ed53 100644
--- a/client/dbconnector.cpp
+++ b/client/dbconnector.cpp
@@ -9,6 +9,9 @@ dbConnector::dbConnector(QWidget *parent) :
ui(new Ui::dbConnector)
{
ui->setupUi(this);
+ ui->lineEdit_espAdress->setText(_espHost);
+ ui->lineEdit_database->setText(_dbName);
+ ui->lineEdit_adress->setText(_dbHost);
}
dbConnector::~dbConnector()
@@ -18,29 +21,33 @@ dbConnector::~dbConnector()
void dbConnector::on_pushButton_cancel_clicked()
{
- dbConnector::~dbConnector();
+ close();
}
void dbConnector::on_pushButton_login_clicked()
{
- QString hostname = ui->lineEdit_adress->text();
+ _espHost = ui->lineEdit_espAdress->text();
+ _dbHost = ui->lineEdit_adress->text();
+ _dbName = ui->lineEdit_database->text();
QString username = ui->lineEdit_username->text();
QString password = ui->lineEdit_password->text();
- QString databaseName = ui->lineEdit_database->text();
- dbRef.setHostName(hostname);
+ // Extract possible port (default if not provided)
+ QStringList dbAdress = _dbHost.split(":");
+ if (dbAdress.size() > 1){
+ dbRef.setPort(dbAdress[1].toInt());
+ qDebug() << dbAdress[1];
+ }
+
+ dbRef.setHostName(dbAdress[0]);
dbRef.setUserName(username);
dbRef.setPassword(password);
- dbRef.setDatabaseName(databaseName);
+ dbRef.setDatabaseName(_dbName);
if(dbRef.open()){
QMessageBox::information(this, "Connection", "GREAT SUCCES!");
- dbConnector::~dbConnector();
+ close();
} else {
QMessageBox::warning(this, "No connection", "Failed to connect");
}
}
-
-
-
-
diff --git a/client/dbconnector.h b/client/dbconnector.h
index b989e57..5b9b1cf 100644
--- a/client/dbconnector.h
+++ b/client/dbconnector.h
@@ -6,6 +6,8 @@
//#include <QtSql>
//#include <QSqlDatabase>
+#define WS_ESP8266_WLAN_IP "129.168.0.1"
+
namespace Ui {
class dbConnector;
}
@@ -26,4 +28,8 @@ private slots:
private:
Ui::dbConnector *ui;
+
+ QString _dbHost = "localhost";
+ QString _dbName = "WSdb";
+ QString _espHost = WS_ESP8266_WLAN_IP;
};
diff --git a/client/dbconnector.ui b/client/dbconnector.ui
index 5c5b326..fe9c05e 100644
--- a/client/dbconnector.ui
+++ b/client/dbconnector.ui
@@ -11,70 +11,87 @@
</rect>
</property>
<property name="windowTitle">
- <string>Dialog</string>
+ <string>Settings</string>
</property>
<widget class="QWidget" name="formLayoutWidget">
<property name="geometry">
<rect>
- <x>60</x>
- <y>60</y>
- <width>270</width>
- <height>171</height>
+ <x>30</x>
+ <y>30</y>
+ <width>301</width>
+ <height>211</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Router</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="lineEdit_espAdress">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="placeholderText">
+ <string>IP-Adress</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Adress</string>
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_adress">
<property name="text">
- <string>localhost</string>
+ <string/>
</property>
<property name="placeholderText">
<string>Hostname/IP-Adress</string>
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Database</string>
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_database">
<property name="text">
- <string>WSdb</string>
+ <string/>
</property>
<property name="placeholderText">
<string>Database name</string>
</property>
</widget>
</item>
- <item row="2" column="0" colspan="2">
+ <item row="3" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
- <item row="3" column="0">
+ <item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_username">
<property name="text">
- <string>root</string>
+ <string/>
</property>
<property name="echoMode">
<enum>QLineEdit::PasswordEchoOnEdit</enum>
@@ -84,14 +101,14 @@
</property>
</widget>
</item>
- <item row="4" column="0">
+ <item row="5" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="5" column="1">
<widget class="QLineEdit" name="lineEdit_password">
<property name="font">
<font>
@@ -111,19 +128,19 @@
</property>
</widget>
</item>
- <item row="5" column="0">
+ <item row="6" column="0">
<widget class="QLabel" name="connectLabel">
<property name="text">
<string>Connect</string>
</property>
</widget>
</item>
- <item row="5" column="1">
+ <item row="6" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButton_login">
<property name="text">
- <string>Login</string>
+ <string>Save</string>
</property>
</widget>
</item>
diff --git a/client/main.cpp b/client/main.cpp
index 157abe6..b70733d 100644
--- a/client/main.cpp
+++ b/client/main.cpp
@@ -24,7 +24,21 @@ int main(int argc, char *argv[])
dbRef = QSqlDatabase::addDatabase("QMYSQL");
- w.show();
+// QString input = "000e,1d,2f,28\n000d,1d,2f,28\n000c,1d,2f,29\n000b,1d,2f,28\n000a,1d,2f,2a";
+// CSV_Import import;
+
+
+// QString output = "INSERT INTO `WSdb`.`tblMain` () VALUES ";
+// QVector<QString> list = input.split("\n");
+// for (int i = 0; i < list.size(); ++i) {
+// output.append(import.csvToSql(list[i]));
+// if (i+1 < list.size()){
+// output.append(",");
+// }
+// }
+// qDebug() << output;
+
+ w.show();
return a.exec();
}
diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp
index 49fcc26..5f76ad8 100644
--- a/client/mainwindow.cpp
+++ b/client/mainwindow.cpp
@@ -12,11 +12,13 @@ MainWindow::MainWindow(QWidget *parent)
{
ui->setupUi(this);
client.ClientEcho();
+ _dbConenctor = new dbConnector(this);
}
MainWindow::~MainWindow()
{
dbRef.close();
+ delete _dbConenctor;
delete ui;
}
@@ -27,7 +29,7 @@ void MainWindow::timeFunction()
void MainWindow::on_actionConnection_triggered()
{
- _dbConenctor = new dbConnector(this);
+// _dbConenctor->preLoadUi();
_dbConenctor->show();
}
@@ -48,7 +50,6 @@ void MainWindow::drawGraph(){
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;");
@@ -57,16 +58,11 @@ void MainWindow::drawGraph(){
for (int i = 0; queryGraphData.next(); ++i) {
// 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());
-// 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));
@@ -107,9 +103,6 @@ void MainWindow::drawGraph(){
layout->setContentsMargins(0,0,0,0);
-
-// window->show();
-
MainWindow::setCentralWidget(window);
} else {
diff --git a/client/mainwindow.ui b/client/mainwindow.ui
index bbcdf9c..e89be1f 100644
--- a/client/mainwindow.ui
+++ b/client/mainwindow.ui
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
- <string>MainWindow</string>
+ <string>Weather Station</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QLabel" name="label">
@@ -34,7 +34,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
- <height>26</height>
+ <height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuAbouy">
@@ -42,16 +42,9 @@
<string>Home</string>
</property>
<addaction name="actionRefresh"/>
- </widget>
- <widget class="QMenu" name="menuDatabase">
- <property name="title">
- <string>Database</string>
- </property>
<addaction name="actionConnection"/>
- <addaction name="actionDisconnenct"/>
</widget>
<addaction name="menuAbouy"/>
- <addaction name="menuDatabase"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionRefresh">
@@ -74,7 +67,7 @@
</action>
<action name="actionConnection">
<property name="text">
- <string>Connect</string>
+ <string>Settings</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>