diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-10-05 20:57:10 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-10-05 20:57:10 +0200 |
commit | 4625b939aad3537bd130617944e01f5da693b23d (patch) | |
tree | 8cd4b9c94d9ca70b7386b369e16d81c659d01c6f /client | |
parent | 9c7f4e157f10aa58e4b78636a2f8556be4637a07 (diff) |
initial merge of qt client
Diffstat (limited to 'client')
-rw-r--r-- | client/client.pro | 21 | ||||
-rw-r--r-- | client/dbconnector.cpp | 49 | ||||
-rw-r--r-- | client/dbconnector.h | 34 | ||||
-rw-r--r-- | client/dbconnector.ui | 141 | ||||
-rw-r--r-- | client/main.cpp | 57 | ||||
-rw-r--r-- | client/main.h | 8 | ||||
-rw-r--r-- | client/mainwindow.cpp | 50 | ||||
-rw-r--r-- | client/mainwindow.h | 42 | ||||
-rw-r--r-- | client/mainwindow.ui | 128 |
9 files changed, 491 insertions, 39 deletions
diff --git a/client/client.pro b/client/client.pro index cd0990a..0de0a33 100644 --- a/client/client.pro +++ b/client/client.pro @@ -1,14 +1,23 @@ -QT += charts +QT += core gui sql charts HEADERS += \ - chart.h \ - chartview.h + dbconnector.h \ + main.h \ + mainwindow.h +# chart.h \ +# chartview.h SOURCES += \ + dbconnector.cpp \ main.cpp \ - chart.cpp \ - chartview.cpp + mainwindow.cpp +# chart.cpp \ +# chartview.cpp + + +FORMS += \ + dbconnector.ui \ + mainwindow.ui -target.path = $$[QT_INSTALL_EXAMPLES]/charts/zoomlinechart INSTALLS += target CONFIG += force_debug_info diff --git a/client/dbconnector.cpp b/client/dbconnector.cpp new file mode 100644 index 0000000..5ed1efc --- /dev/null +++ b/client/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(hostname); + 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/client/dbconnector.h b/client/dbconnector.h new file mode 100644 index 0000000..cd722eb --- /dev/null +++ b/client/dbconnector.h @@ -0,0 +1,34 @@ +#pragma once + +#include <QDialog> + +#include <QMessageBox> +//#include <QtSql> +//#include <QSqlDatabase> + +//#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/client/dbconnector.ui b/client/dbconnector.ui new file mode 100644 index 0000000..21d241f --- /dev/null +++ b/client/dbconnector.ui @@ -0,0 +1,141 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>dbConnector</class> + <widget class="QDialog" name="dbConnector"> + <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="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/> + </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/main.cpp b/client/main.cpp index 28a3d91..84706bf 100644 --- a/client/main.cpp +++ b/client/main.cpp @@ -1,42 +1,33 @@ -/**************************************************************************** -** -** 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 "chartview.h" #include <QtWidgets/QApplication> #include <QtWidgets/QMainWindow> #include <QtCore/QtMath> #include <QtCore/QRandomGenerator> #include <QtCharts/QLineSeries> #include <QtCharts/QValueAxis> +#include <QApplication> +#include <QMessageBox> +#include <iostream> +#include <stdio.h> + +#include "chart.h" +#include "chartview.h" +#include "mainwindow.h" +#include "main.h" +#include "ui_mainwindow.h" -QT_CHARTS_USE_NAMESPACE +QSqlDatabase dbRef = QSqlDatabase(); + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + dbRef = QSqlDatabase::addDatabase("QMYSQL"); + + w.show(); + return a.exec(); +} + +/* QT_CHARTS_USE_NAMESPACE int main(int argc, char *argv[]) { @@ -69,4 +60,4 @@ int main(int argc, char *argv[]) window.show(); return a.exec(); -} +} */ diff --git a/client/main.h b/client/main.h new file mode 100644 index 0000000..010f2e6 --- /dev/null +++ b/client/main.h @@ -0,0 +1,8 @@ +#pragma once + +#include <QSql> +#include <QSqlDatabase> + +int main(int argc, char *argv[]); +extern QSqlDatabase dbRef; + diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp new file mode 100644 index 0000000..955307e --- /dev/null +++ b/client/mainwindow.cpp @@ -0,0 +1,50 @@ +#include <QSqlDatabase> + +#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/client/mainwindow.h b/client/mainwindow.h new file mode 100644 index 0000000..1e73657 --- /dev/null +++ b/client/mainwindow.h @@ -0,0 +1,42 @@ +#pragma once + +#include <QMainWindow> + +//#include "database.h" +#include "dbconnector.h" + +#include <QMessageBox> +#include <QtSql> +#include <QSqlDatabase> +#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/client/mainwindow.ui b/client/mainwindow.ui new file mode 100644 index 0000000..f827c85 --- /dev/null +++ b/client/mainwindow.ui @@ -0,0 +1,128 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>600</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <widget class="QPushButton" name="pushButton"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>310</x> + <y>0</y> + <width>121</width> + <height>41</height> + </rect> + </property> + <property name="text"> + <string>DoesSomething</string> + </property> + </widget> + <widget class="QWidget" name="verticalLayoutWidget"> + <property name="geometry"> + <rect> + <x>-10</x> + <y>40</y> + <width>801</width> + <height>401</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QTableView" name="tableView"/> + </item> + </layout> + </widget> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>800</width> + <height>21</height> + </rect> + </property> + <widget class="QMenu" name="menuAbouy"> + <property name="title"> + <string>Home</string> + </property> + <addaction name="actionAbout"/> + <addaction name="actionRefresh"/> + </widget> + <widget class="QMenu" name="menuTEMP"> + <property name="title"> + <string>TEMP</string> + </property> + <addaction name="actionLOAD"/> + <addaction name="actionQuerry"/> + </widget> + <widget class="QMenu" name="menuDatabase"> + <property name="title"> + <string>Database</string> + </property> + <addaction name="actionConnection"/> + <addaction name="actionDisconnenct"/> + <addaction name="actionStatus"/> + </widget> + <addaction name="menuAbouy"/> + <addaction name="menuTEMP"/> + <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> + </property> + </action> + <action name="actionLOAD"> + <property name="text"> + <string>Load</string> + </property> + </action> + <action name="actionQuerry"> + <property name="text"> + <string>Query</string> + </property> + </action> + <action name="actionConnection"> + <property name="text"> + <string>Connect</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/> +</ui> |