diff options
author | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2022-10-30 12:05:26 +0100 |
---|---|---|
committer | UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> | 2022-10-30 12:05:26 +0100 |
commit | 2788f6d76bb9485bc800356424df210f0d6a86c7 (patch) | |
tree | d20cc0c2e516d1ec4c9a3b4658a3acb62aa04888 | |
parent | 8952e19f00e0930e53e3731fd30be5e2600d9fd6 (diff) |
changed dbConnector to settings window
-rw-r--r-- | client/chart.cpp | 72 | ||||
-rw-r--r-- | client/chart.h | 59 | ||||
-rw-r--r-- | client/chartview.cpp | 109 | ||||
-rw-r--r-- | client/chartview.h | 58 | ||||
-rw-r--r-- | client/client.pro.user | 22 | ||||
-rw-r--r-- | client/csv_import.cpp | 32 | ||||
-rw-r--r-- | client/csv_import.h | 12 | ||||
-rw-r--r-- | client/dbconnector.cpp | 27 | ||||
-rw-r--r-- | client/dbconnector.h | 6 | ||||
-rw-r--r-- | client/dbconnector.ui | 53 | ||||
-rw-r--r-- | client/dialog.cpp | 14 | ||||
-rw-r--r-- | client/dialog.h | 22 | ||||
-rw-r--r-- | client/dialog.ui | 18 | ||||
-rw-r--r-- | client/main.cpp | 22 | ||||
-rw-r--r-- | client/mainwindow.cpp | 13 | ||||
-rw-r--r-- | client/mainwindow.ui | 11 | ||||
-rw-r--r-- | client/settingsmenu.cpp | 47 | ||||
-rw-r--r-- | client/settingsmenu.h | 34 | ||||
-rw-r--r-- | client/settingsmenu.ui | 144 | ||||
-rw-r--r-- | client/ui_dbconnector.h | 163 | ||||
-rw-r--r-- | client/ui_mainwindow.h | 110 |
21 files changed, 85 insertions, 963 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/client.pro.user b/client/client.pro.user index 7ccbc7b..459f462 100644 --- a/client/client.pro.user +++ b/client/client.pro.user @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> -<!-- Written by QtCreator 8.0.1, 2022-10-29T18:40:37. --> +<!-- Written by QtCreator 8.0.1, 2022-10-30T12:04:23. --> <qtcreator> <data> <variable>EnvironmentId</variable> - <value type="QByteArray">{aa240e53-c124-4cf0-84a8-30bfe8a2cf83}</value> + <value type="QByteArray">{ea03b890-8d0a-4e25-9c8a-4324595ed9f6}</value> </data> <data> <variable>ProjectExplorer.Project.ActiveTarget</variable> @@ -86,16 +86,16 @@ <variable>ProjectExplorer.Project.Target.0</variable> <valuemap type="QVariantMap"> <value type="QString" key="DeviceType">Desktop</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 6.4.0 MinGW 64-bit</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 6.4.0 MinGW 64-bit</value> - <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt6.640.win64_mingw_kit</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">degoede</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">degoede</value> + <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{1e436ae3-d7a2-4102-aca0-911720324ec1}</value> <value type="qlonglong" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> <value type="qlonglong" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="qlonglong" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <value type="int" key="EnableQmlDebugging">0</value> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Github2\avans-whether-station\build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Debug</value> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Github2/avans-whether-station/build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Debug</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/jregnier/gitOnline/avans-whether-station-Qt/build-client-degoede-Debug</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/Users/jregnier/gitOnline/avans-whether-station-Qt/build-client-degoede-Debug</value> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> @@ -133,8 +133,8 @@ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value> </valuemap> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Github2\avans-whether-station\build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Release</value> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Github2/avans-whether-station/build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Release</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/jregnier/gitOnline/avans-whether-station-Qt/build-client-degoede-Release</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/Users/jregnier/gitOnline/avans-whether-station-Qt/build-client-degoede-Release</value> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> @@ -174,8 +174,8 @@ </valuemap> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> <value type="int" key="EnableQmlDebugging">0</value> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">D:\Github2\avans-whether-station\build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Profile</value> - <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">D:/Github2/avans-whether-station/build-client-Desktop_Qt_6_4_0_MinGW_64_bit-Profile</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/jregnier/gitOnline/avans-whether-station-Qt/build-client-degoede-Profile</value> + <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">/Users/jregnier/gitOnline/avans-whether-station-Qt/build-client-degoede-Profile</value> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> diff --git a/client/csv_import.cpp b/client/csv_import.cpp deleted file mode 100644 index 5507754..0000000 --- a/client/csv_import.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "csv_import.h" - -CSV_Import::CSV_Import() -{ - -} - - -#include <QString> -#include <QVector> - -QString CSV_Import::csvToSql(QString input){ - - QVector<QString> data; - QString output = "("; - - data = input.split(","); - - for (int i = 1; i < data.size(); ++i) { - - bool valid; - output.append(QString::number(data[i].toInt(&valid, 16))); - - if (i <= data[i].size()) { - output.append(","); - } - - } - output.append(")"); - - return output; -} diff --git a/client/csv_import.h b/client/csv_import.h deleted file mode 100644 index 6998417..0000000 --- a/client/csv_import.h +++ /dev/null @@ -1,12 +0,0 @@ -#include <QString> -#pragma once - - -class CSV_Import -{ -public: - CSV_Import(); - - virtual QString csvToSql(QString input); -}; - 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 db8ac4e..4737d6f 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; @@ -27,4 +29,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 1159faf..7cdd611 100644 --- a/client/dbconnector.ui +++ b/client/dbconnector.ui @@ -16,65 +16,82 @@ <widget class="QWidget" name="formLayoutWidget"> <property name="geometry"> <rect> - <x>60</x> - <y>60</y> - <width>241</width> - <height>173</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/dialog.cpp b/client/dialog.cpp deleted file mode 100644 index 58c3e72..0000000 --- a/client/dialog.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "dialog.h" -#include "ui_dialog.h" - -Dialog::Dialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog) -{ - ui->setupUi(this); -} - -Dialog::~Dialog() -{ - delete ui; -} diff --git a/client/dialog.h b/client/dialog.h deleted file mode 100644 index 17537d1..0000000 --- a/client/dialog.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef DIALOG_H -#define DIALOG_H - -#include <QDialog> - -namespace Ui { -class Dialog; -} - -class Dialog : public QDialog -{ - Q_OBJECT - -public: - explicit Dialog(QWidget *parent = nullptr); - ~Dialog(); - -private: - Ui::Dialog *ui; -}; - -#endif // DIALOG_H diff --git a/client/dialog.ui b/client/dialog.ui deleted file mode 100644 index 9fbffd2..0000000 --- a/client/dialog.ui +++ /dev/null @@ -1,18 +0,0 @@ -<ui version="4.0"> - <class>Dialog</class> - <widget name="Dialog" class="QDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - </widget> - <resources/> - <connections/> -</ui> diff --git a/client/main.cpp b/client/main.cpp index 267248c..b70733d 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -24,19 +24,19 @@ int main(int argc, char *argv[]) dbRef = QSqlDatabase::addDatabase("QMYSQL"); - 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 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; +// 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..f8c3a64 100644 --- a/client/mainwindow.ui +++ b/client/mainwindow.ui @@ -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> diff --git a/client/settingsmenu.cpp b/client/settingsmenu.cpp deleted file mode 100644 index 139c616..0000000 --- a/client/settingsmenu.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "settingsmenu.h" -//#include "ui_SettingsMenu.h" -#include "main.h" - -#include "mainwindow.h" - -SettingsMenu::SettingsMenu(QWidget *parent) : - QDialog(parent), - ui(new Ui::SettingsMenu) -{ - _dbip = "localhost"; - ui->setupUi(this); -} - -SettingsMenu::~SettingsMenu() -{ - delete ui; -} - -void SettingsMenu::on_pushButton_cancel_clicked() -{ - SettingsMenu::~SettingsMenu(); -} - -void SettingsMenu::on_pushButton_login_clicked() -{ - _dbip = ui->lineEdit_adress->text(); - _dbName = ui->lineEdit_database->text(); - QString username = ui->lineEdit_username->text(); - QString password = ui->lineEdit_password->text(); - - dbRef.setHostName(_dbip); - dbRef.setUserName(username); - dbRef.setPassword(password); - dbRef.setDatabaseName(_dbName); - - if(dbRef.open()){ - QMessageBox::information(this, "Connection", "GREAT SUCCES!"); - SettingsMenu::~SettingsMenu(); - } else { - QMessageBox::warning(this, "No connection", "Failed to connect"); - } -} - - - - diff --git a/client/settingsmenu.h b/client/settingsmenu.h deleted file mode 100644 index 881906d..0000000 --- a/client/settingsmenu.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include <QDialog> - -#include <QMessageBox> -//#include <QtSql> -//#include <QSqlDatabase> - - -namespace Ui { -class SettingsMenu; -} - -class SettingsMenu : public QDialog -{ - Q_OBJECT - -public: - explicit SettingsMenu(QWidget *parent = nullptr); - ~SettingsMenu(); - -private slots: - - void on_pushButton_cancel_clicked(); - - void on_pushButton_login_clicked(); - -private: - Ui::SettingsMenu *ui; - - QString _dbName = ""; - QString _dbip = ""; - QString _ESPip = ""; -}; diff --git a/client/settingsmenu.ui b/client/settingsmenu.ui deleted file mode 100644 index 0de180f..0000000 --- a/client/settingsmenu.ui +++ /dev/null @@ -1,144 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>SettingsMenu</class> - <widget class="QDialog" name="SettingsMenu"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>362</width> - <height>273</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <widget class="QWidget" name="formLayoutWidget"> - <property name="geometry"> - <rect> - <x>60</x> - <y>60</y> - <width>241</width> - <height>173</height> - </rect> - </property> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Adress</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="lineEdit_adress"> - <property name="text"> - <string>localhost</string> - </property> - <property name="placeholderText"> - <string>Hostname/IP-Adress</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Database</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="lineEdit_database"> - <property name="text"> - <string>WSdb</string> - </property> - <property name="placeholderText"> - <string>Database name</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="2"> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Username</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="lineEdit_username"> - <property name="text"> - <string>root</string> - </property> - <property name="echoMode"> - <enum>QLineEdit::PasswordEchoOnEdit</enum> - </property> - <property name="placeholderText"> - <string>Username</string> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Password</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLineEdit" name="lineEdit_password"> - <property name="font"> - <font> - <underline>false</underline> - <strikeout>false</strikeout> - <kerning>true</kerning> - </font> - </property> - <property name="text"> - <string>Ab12345!</string> - </property> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - <property name="placeholderText"> - <string>Password</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="connectLabel"> - <property name="text"> - <string>Connect</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="pushButton_login"> - <property name="text"> - <string>Login</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_cancel"> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </widget> - <resources/> - <connections/> -</ui> diff --git a/client/ui_dbconnector.h b/client/ui_dbconnector.h deleted file mode 100644 index dec4d7b..0000000 --- a/client/ui_dbconnector.h +++ /dev/null @@ -1,163 +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 <QtCore/QVariant> -#include <QtWidgets/QApplication> -#include <QtWidgets/QDialog> -#include <QtWidgets/QFormLayout> -#include <QtWidgets/QFrame> -#include <QtWidgets/QHBoxLayout> -#include <QtWidgets/QLabel> -#include <QtWidgets/QLineEdit> -#include <QtWidgets/QPushButton> -#include <QtWidgets/QWidget> - -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->setText(QCoreApplication::translate("dbConnector", "WSdb", 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(QCoreApplication::translate("dbConnector", "Ab12345!", nullptr)); - 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 69c476b..0000000 --- a/client/ui_mainwindow.h +++ /dev/null @@ -1,110 +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 <QtCore/QVariant> -// #include <QtWidgets/QAction> -#include <QtWidgets/QApplication> -#include <QtWidgets/QLabel> -#include <QtWidgets/QMainWindow> -#include <QtWidgets/QMenu> -#include <QtWidgets/QMenuBar> -#include <QtWidgets/QStatusBar> -#include <QtWidgets/QWidget> - -QT_BEGIN_NAMESPACE - -class Ui_MainWindow -{ -public: - QAction *actionRefresh; - QAction *actionLOAD; - QAction *actionQuerry; - QAction *actionConnection; - QAction *actionDisconnenct; - QWidget *centralwidget; - QLabel *label; - QMenuBar *menubar; - QMenu *menuAbouy; - QMenu *menuDatabase; - QStatusBar *statusbar; - - void setupUi(QMainWindow *MainWindow) - { - if (MainWindow->objectName().isEmpty()) - MainWindow->setObjectName(QString::fromUtf8("MainWindow")); - MainWindow->resize(800, 600); - 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")); - centralwidget = new QWidget(MainWindow); - centralwidget->setObjectName(QString::fromUtf8("centralwidget")); - label = new QLabel(centralwidget); - label->setObjectName(QString::fromUtf8("label")); - label->setGeometry(QRect(270, 190, 181, 51)); - MainWindow->setCentralWidget(centralwidget); - menubar = new QMenuBar(MainWindow); - menubar->setObjectName(QString::fromUtf8("menubar")); - menubar->setGeometry(QRect(0, 0, 800, 24)); - menuAbouy = new QMenu(menubar); - menuAbouy->setObjectName(QString::fromUtf8("menuAbouy")); - 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(menuDatabase->menuAction()); - menuAbouy->addAction(actionRefresh); - menuDatabase->addAction(actionConnection); - menuDatabase->addAction(actionDisconnenct); - - retranslateUi(MainWindow); - - QMetaObject::connectSlotsByName(MainWindow); - } // setupUi - - void retranslateUi(QMainWindow *MainWindow) - { - MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr)); - actionRefresh->setText(QCoreApplication::translate("MainWindow", "Refresh", nullptr)); -#if QT_CONFIG(shortcut) - actionRefresh->setShortcut(QCoreApplication::translate("MainWindow", "Ctrl+R", nullptr)); -#endif // QT_CONFIG(shortcut) - actionLOAD->setText(QCoreApplication::translate("MainWindow", "Load", nullptr)); - actionQuerry->setText(QCoreApplication::translate("MainWindow", "Query", nullptr)); - actionConnection->setText(QCoreApplication::translate("MainWindow", "Connect", nullptr)); -#if QT_CONFIG(shortcut) - actionConnection->setShortcut(QCoreApplication::translate("MainWindow", "Ctrl+O", nullptr)); -#endif // QT_CONFIG(shortcut) - actionDisconnenct->setText(QCoreApplication::translate("MainWindow", "Disconnenct", nullptr)); - label->setText(QCoreApplication::translate("MainWindow", "Please load data first", nullptr)); - menuAbouy->setTitle(QCoreApplication::translate("MainWindow", "Home", 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 |