From d56f01dec7bbd32f88df92479618348f12dcc2e8 Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Thu, 29 Sep 2022 14:46:12 +0200 Subject: creating database build script --- createDB.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 createDB.sql diff --git a/createDB.sql b/createDB.sql new file mode 100644 index 0000000..4c4c4d4 --- /dev/null +++ b/createDB.sql @@ -0,0 +1,9 @@ +CREATE SCHEMA `WSdb`; +CREATE TABLE `DAB1Pract1`.`tblMain` ( + `ID` INT GENERATED ALWAYS AS (), + `temperature` DECIMAL(5,2) NULL, + `humidity` DECIMAL(5,2) NULL, + `pressure` DECIMAL(5,2) NULL, + `time` DATETIME NULL, + PRIMARY KEY (`ID`), + UNIQUE INDEX `ID_UNIQUE` (`ID` ASC) VISIBLE); -- cgit v1.2.3 From 9f294f60c90bae4ee77c585e7da06f957858a71c Mon Sep 17 00:00:00 2001 From: UnavailableDev <69792062+UnavailableDev@users.noreply.github.com> Date: Thu, 29 Sep 2022 14:54:58 +0200 Subject: moved file --- MySqlDatabaseScript/build.sql | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 MySqlDatabaseScript/build.sql diff --git a/MySqlDatabaseScript/build.sql b/MySqlDatabaseScript/build.sql new file mode 100644 index 0000000..4c4c4d4 --- /dev/null +++ b/MySqlDatabaseScript/build.sql @@ -0,0 +1,9 @@ +CREATE SCHEMA `WSdb`; +CREATE TABLE `DAB1Pract1`.`tblMain` ( + `ID` INT GENERATED ALWAYS AS (), + `temperature` DECIMAL(5,2) NULL, + `humidity` DECIMAL(5,2) NULL, + `pressure` DECIMAL(5,2) NULL, + `time` DATETIME NULL, + PRIMARY KEY (`ID`), + UNIQUE INDEX `ID_UNIQUE` (`ID` ASC) VISIBLE); -- cgit v1.2.3 From 40e937f75dee1e612710730b6d281a21131cc159 Mon Sep 17 00:00:00 2001 From: UnavailableDev Date: Wed, 5 Oct 2022 20:16:11 +0200 Subject: First merge Qt App --- Qt/dbconnector.cpp | 49 +++++++++ Qt/dbconnector.h | 34 ++++++ Qt/dbconnector.ui | 141 +++++++++++++++++++++++++ Qt/main.cpp | 27 +++++ Qt/main.h | 7 ++ Qt/mainwindow.cpp | 48 +++++++++ Qt/mainwindow.h | 42 ++++++++ Qt/mainwindow.ui | 128 +++++++++++++++++++++++ Qt/whetherOrNot.pro | 30 ++++++ Qt/whetherOrNot.pro.user | 262 +++++++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 768 insertions(+) create mode 100644 Qt/dbconnector.cpp create mode 100644 Qt/dbconnector.h create mode 100644 Qt/dbconnector.ui create mode 100644 Qt/main.cpp create mode 100644 Qt/main.h create mode 100644 Qt/mainwindow.cpp create mode 100644 Qt/mainwindow.h create mode 100644 Qt/mainwindow.ui create mode 100644 Qt/whetherOrNot.pro create mode 100644 Qt/whetherOrNot.pro.user diff --git a/Qt/dbconnector.cpp b/Qt/dbconnector.cpp new file mode 100644 index 0000000..188ae6c --- /dev/null +++ b/Qt/dbconnector.cpp @@ -0,0 +1,49 @@ +#include "dbconnector.h" +#include "ui_dbconnector.h" +#include "main.h" + +//#include "mainwindow.h" + +dbConnector::dbConnector(QWidget *parent) : + QDialog(parent), + ui(new Ui::dbConnector) +{ + ui->setupUi(this); +} + +dbConnector::~dbConnector() +{ + delete ui; +} + +void dbConnector::on_pushButton_cancel_clicked() +{ + dbConnector::~dbConnector(); +} + +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"; + +// QSqlDatabase db = MainWindow.loginDb(adress, username, password); + +// QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); +// return; + dbRef.setHostName(adress); + dbRef.setUserName(username); + dbRef.setPassword(password); + dbRef.setDatabaseName("thecrapbox"); + + if(dbRef.open()){ + QMessageBox::information(this, "Connection", "GREAT SUCCES!"); + } else { + QMessageBox::warning(this, "No connection", "Failed to connect"); + } +} + + + + diff --git a/Qt/dbconnector.h b/Qt/dbconnector.h new file mode 100644 index 0000000..b0f9a7e --- /dev/null +++ b/Qt/dbconnector.h @@ -0,0 +1,34 @@ +#pragma once + +#include + +#include +//#include +//#include + +#include "database.h" + +namespace Ui { +class dbConnector; +} + +class dbConnector : public QDialog +{ + Q_OBJECT + +public: + explicit dbConnector(QWidget *parent = nullptr); + ~dbConnector(); + +private slots: +// void on_pushButton_clicked(); + + void on_pushButton_cancel_clicked(); + + void on_pushButton_login_clicked(); + +private: + Ui::dbConnector *ui; + +// Database database; +}; diff --git a/Qt/dbconnector.ui b/Qt/dbconnector.ui new file mode 100644 index 0000000..21d241f --- /dev/null +++ b/Qt/dbconnector.ui @@ -0,0 +1,141 @@ + + + dbConnector + + + + 0 + 0 + 362 + 273 + + + + Dialog + + + + + 60 + 60 + 241 + 173 + + + + + + + Adress + + + + + + + localhost + + + Hostname/IP-Adress + + + + + + + Database + + + + + + + Database name + + + + + + + Qt::Horizontal + + + + + + + Username + + + + + + + root + + + QLineEdit::PasswordEchoOnEdit + + + Username + + + + + + + Password + + + + + + + + false + false + true + + + + + + + QLineEdit::Password + + + Password + + + + + + + Connect + + + + + + + + + Login + + + + + + + Cancel + + + + + + + + + + + diff --git a/Qt/main.cpp b/Qt/main.cpp new file mode 100644 index 0000000..6de43ac --- /dev/null +++ b/Qt/main.cpp @@ -0,0 +1,27 @@ +#include "mainwindow.h" +#include "main.h" +#include "./ui_mainwindow.h" + +#include +#include +#include +#include + +QSqlDatabase dbRef = QSqlDatabase(); + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; +// dbRef = new QSqlDatabase(); + dbRef = QSqlDatabase::addDatabase("QMYSQL"); + + + + w.show(); +// QMessageBox::information(NULL, "AAAAAAAAA", dbRef.driverName().toStdString()); + std::cout << "AAAAAAAA: \"" << dbRef.driverName().toStdString() << "\"\n"; + fflush(0); + return a.exec(); + +} diff --git a/Qt/main.h b/Qt/main.h new file mode 100644 index 0000000..6c7c5c9 --- /dev/null +++ b/Qt/main.h @@ -0,0 +1,7 @@ +#pragma once + +#include +#include + +int main(int argc, char *argv[]); +extern QSqlDatabase dbRef; diff --git a/Qt/mainwindow.cpp b/Qt/mainwindow.cpp new file mode 100644 index 0000000..c475414 --- /dev/null +++ b/Qt/mainwindow.cpp @@ -0,0 +1,48 @@ +#include "mainwindow.h" +#include "./ui_mainwindow.h" +#include "main.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ +// db = QSqlDatabase::addDatabase("QMYSQL"); + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + dbRef.close(); + delete ui; +} + +void MainWindow::on_actionAbout_triggered() +{ + QMessageBox::warning(this, "Oops..", "Task Failed succesfully ;)"); +} + + +void MainWindow::on_pushButton_clicked() +{ +// dbRef = QSqlDatabase::addDatabase("QMYSQL"); +// dbRef.setHostName("localhost"); +// dbRef.setUserName("root"); +// dbRef.setPassword("Ab12345!"); +// dbRef.setDatabaseName("thecrapbox"); + + if(dbRef.open()){ + QMessageBox::information(this, "Connection", "GREAT SUCCES!"); + pQueryModel = new QSqlQueryModel(); + pQueryModel->setQuery("SELECT * FROM opleiding;"); + ui->tableView->setModel(pQueryModel); + } else { + QMessageBox::warning(this, "No connection", "Failed to connect"); + } +} + +void MainWindow::on_actionConnection_triggered() +{ + _dbConenctor = new dbConnector(this); + _dbConenctor->show(); +} + diff --git a/Qt/mainwindow.h b/Qt/mainwindow.h new file mode 100644 index 0000000..b7374a1 --- /dev/null +++ b/Qt/mainwindow.h @@ -0,0 +1,42 @@ +#pragma once + +#include + +#include "database.h" +#include "dbconnector.h" + +#include +#include +#include +#include "main.h" + + +QT_BEGIN_NAMESPACE +namespace Ui { class MainWindow; } +QT_END_NAMESPACE + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + +private slots: + void on_actionAbout_triggered(); + + void on_pushButton_clicked(); + + void on_actionConnection_triggered(); + +private: + Ui::MainWindow *ui; + + dbConnector *_dbConenctor; +// QSqlDatabase db; + +// QSqlQueryModel *pQueryModel; + + Database database; +}; diff --git a/Qt/mainwindow.ui b/Qt/mainwindow.ui new file mode 100644 index 0000000..f827c85 --- /dev/null +++ b/Qt/mainwindow.ui @@ -0,0 +1,128 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + true + + + + 310 + 0 + 121 + 41 + + + + DoesSomething + + + + + + -10 + 40 + 801 + 401 + + + + + + + + + + + + + 0 + 0 + 800 + 21 + + + + + Home + + + + + + + TEMP + + + + + + + Database + + + + + + + + + + + + + About + + + + + Refresh + + + + + Load + + + + + Query + + + + + Connect + + + + + Disconnenct + + + + + Querry + + + + + Status + + + + + + diff --git a/Qt/whetherOrNot.pro b/Qt/whetherOrNot.pro new file mode 100644 index 0000000..10dfa8a --- /dev/null +++ b/Qt/whetherOrNot.pro @@ -0,0 +1,30 @@ +QT += core gui sql charts + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +CONFIG += c++17 + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +SOURCES += \ + database.cpp \ + dbconnector.cpp \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + database.h \ + dbconnector.h \ + main.h \ + mainwindow.h + +FORMS += \ + dbconnector.ui \ + mainwindow.ui + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/Qt/whetherOrNot.pro.user b/Qt/whetherOrNot.pro.user new file mode 100644 index 0000000..4669d08 --- /dev/null +++ b/Qt/whetherOrNot.pro.user @@ -0,0 +1,262 @@ + + + + + + EnvironmentId + {ea03b890-8d0a-4e25-9c8a-4324595ed9f6} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + false + true + false + 0 + true + true + 0 + 8 + true + false + 1 + true + true + true + *.md, *.MD, Makefile + false + true + + + + ProjectExplorer.Project.PluginSettings + + + true + false + true + true + true + true + + + 0 + true + + true + true + Builtin.DefaultTidyAndClazy + 4 + + + + true + + + + + ProjectExplorer.Project.Target.0 + + Desktop + degoede + degoede + {1e436ae3-d7a2-4102-aca0-911720324ec1} + 0 + 0 + 0 + + 0 + /Users/jregnier/gitOnline/newqt/build-whetherOrNot-degoede-Debug + /Users/jregnier/gitOnline/newqt/build-whetherOrNot-degoede-Debug + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + + + /Users/jregnier/gitOnline/newqt/build-whetherOrNot-degoede-Release + /Users/jregnier/gitOnline/newqt/build-whetherOrNot-degoede-Release + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + + + 0 + /Users/jregnier/gitOnline/newqt/build-whetherOrNot-degoede-Profile + /Users/jregnier/gitOnline/newqt/build-whetherOrNot-degoede-Profile + + + true + QtProjectManager.QMakeBuildStep + false + + + + true + Qt4ProjectManager.MakeStep + + 2 + Build + Build + ProjectExplorer.BuildSteps.Build + + + + true + Qt4ProjectManager.MakeStep + clean + + 1 + Clean + Clean + ProjectExplorer.BuildSteps.Clean + + 2 + false + + false + + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + 0 + 0 + + 3 + + + 0 + Deploy + Deploy + ProjectExplorer.BuildSteps.Deploy + + 1 + + false + ProjectExplorer.DefaultDeployConfiguration + + 1 + + true + true + true + + 2 + + Qt4ProjectManager.Qt4RunConfiguration:/Users/jregnier/gitOnline/newqt/wheather/whetherOrNot.pro + /Users/jregnier/gitOnline/newqt/wheather/whetherOrNot.pro + false + true + true + false + true + /Users/jregnier/gitOnline/newqt/build-whetherOrNot-degoede-Debug/whetherOrNot.app/Contents/MacOS + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 22 + + + Version + 22 + + -- cgit v1.2.3