aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/csv_import.cpp32
-rw-r--r--client/csv_import.h12
-rw-r--r--client/dialog.cpp14
-rw-r--r--client/dialog.h22
-rw-r--r--client/dialog.ui18
-rw-r--r--client/main.cpp16
-rw-r--r--client/settingsmenu.cpp47
-rw-r--r--client/settingsmenu.h34
-rw-r--r--client/settingsmenu.ui144
9 files changed, 338 insertions, 1 deletions
diff --git a/client/csv_import.cpp b/client/csv_import.cpp
new file mode 100644
index 0000000..5507754
--- /dev/null
+++ b/client/csv_import.cpp
@@ -0,0 +1,32 @@
+#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
new file mode 100644
index 0000000..6998417
--- /dev/null
+++ b/client/csv_import.h
@@ -0,0 +1,12 @@
+#include <QString>
+#pragma once
+
+
+class CSV_Import
+{
+public:
+ CSV_Import();
+
+ virtual QString csvToSql(QString input);
+};
+
diff --git a/client/dialog.cpp b/client/dialog.cpp
new file mode 100644
index 0000000..58c3e72
--- /dev/null
+++ b/client/dialog.cpp
@@ -0,0 +1,14 @@
+#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
new file mode 100644
index 0000000..17537d1
--- /dev/null
+++ b/client/dialog.h
@@ -0,0 +1,22 @@
+#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
new file mode 100644
index 0000000..9fbffd2
--- /dev/null
+++ b/client/dialog.ui
@@ -0,0 +1,18 @@
+<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 157abe6..267248c 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/settingsmenu.cpp b/client/settingsmenu.cpp
new file mode 100644
index 0000000..139c616
--- /dev/null
+++ b/client/settingsmenu.cpp
@@ -0,0 +1,47 @@
+#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
new file mode 100644
index 0000000..881906d
--- /dev/null
+++ b/client/settingsmenu.h
@@ -0,0 +1,34 @@
+#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
new file mode 100644
index 0000000..0de180f
--- /dev/null
+++ b/client/settingsmenu.ui
@@ -0,0 +1,144 @@
+<?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>