did a lot of fixed and stuff
This commit is contained in:
25
script.sql
25
script.sql
@@ -84,8 +84,8 @@ CREATE TABLE Veranstalter (
|
||||
CREATE TABLE Veranstalter_Veranstaltung_Uhrzeit (
|
||||
uhrzeit_ID INTEGER REFERENCES Uhrzeit(ID),
|
||||
tag INTEGER NOT NULL,
|
||||
veranstalter_ID INTEGER REFERENCES Veranstalter(ID),
|
||||
veranstaltung_ID INTEGER REFERENCES Veranstaltung(ID),
|
||||
veranstalter_ID INTEGER REFERENCES Veranstalter(ID) ON DELETE CASCADE,
|
||||
veranstaltung_ID INTEGER REFERENCES Veranstaltung(ID) ON DELETE CASCADE,
|
||||
PRIMARY KEY(uhrzeit_ID, tag)
|
||||
);
|
||||
|
||||
@@ -106,17 +106,16 @@ CREATE TABLE Veranstalter (
|
||||
|
||||
|
||||
INSERT INTO Veranstaltung (ort, raum, name, dauer) VALUES
|
||||
('A', '101', 'Grundlagen der Programmierung', 2),
|
||||
('B', '202', 'Algorithmen und Datenstrukturen', 4),
|
||||
('A', '103', 'Netzwerkgrundlagen', 2),
|
||||
('B', '204', 'Betriebssystemkonzepte', 4),
|
||||
('A', '105', 'Softwareentwicklung', 2),
|
||||
('B', '206', 'Intelligente Systeme', 4),
|
||||
('A', '107', 'Datenbanksysteme', 2),
|
||||
('B', '208', 'Webtechnologien', 2),
|
||||
('A', '109', 'Computergrafikgrundlagen', 2),
|
||||
('B', '210', 'Maschinelles Lernen', 2);
|
||||
|
||||
('A', '101', 'WIN', 2),
|
||||
('B', '202', 'ALD', 4),
|
||||
('A', '103', 'GDI', 2),
|
||||
('B', '204', 'BSY', 4),
|
||||
('A', '105', 'SWE', 2),
|
||||
('B', '206', 'ITS', 4),
|
||||
('A', '107', 'DBS', 2),
|
||||
('B', '208', 'WEB', 2),
|
||||
('A', '109', 'BVA', 2),
|
||||
('B', '210', 'THI', 2);
|
||||
|
||||
INSERT INTO Veranstalter_Veranstaltung_Uhrzeit (uhrzeit_ID, tag, veranstaltung_ID) VALUES
|
||||
(1, 1, 1),
|
||||
|
||||
@@ -32,5 +32,5 @@ void EinsatzplanFrameController::createMember(QString name, QString email, QStri
|
||||
|
||||
void EinsatzplanFrameController::createVeranstaltung(QString name, QString raum, QString campus, QString time) {
|
||||
DBPlan* db = new DBPlan(m_connectionString);
|
||||
db->hinzufuegenVeranstaltung(name.toStdString( ), time.toStdString( ), campus.toStdString( ), raum.toStdString( ));
|
||||
db->hinzufuegenVeranstaltung(name.toStdString( ), std::to_string((char)time.toStdString( ).at(0) - 48), campus.toStdString( ), raum.toStdString( ));
|
||||
}
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
#include "LoginFrameController.hpp"
|
||||
|
||||
LoginFrameController::LoginFrameController()
|
||||
{
|
||||
LoginFrameController::LoginFrameController( ) {
|
||||
auto config = load_config("../config.cfg");
|
||||
|
||||
m_connectionString = fmt::format(
|
||||
"host={} port={} dbname={} user={} password={}",
|
||||
config.at("DB_HOST"),
|
||||
config.at("DB_PORT"),
|
||||
config.at("DB_NAME"),
|
||||
config.at("DB_USER"),
|
||||
config.at("DB_PASSWORD")
|
||||
);
|
||||
}
|
||||
|
||||
bool LoginFrameController::tryLogin(QString id, QString password){
|
||||
//DatabaseHandler dbHandler = new Databasehandler();
|
||||
//dbHandler.CheckValidLogin();
|
||||
int LoginFrameController::tryLogin(QString id, QString password) {
|
||||
DBLogin* loginHandler = new DBLogin(m_connectionString);
|
||||
|
||||
|
||||
return true;
|
||||
return loginHandler->checkValidLogin(id.toStdString( ), password.toStdString( ));
|
||||
}
|
||||
@@ -1,10 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <QString>
|
||||
#include <fmt/core.h>
|
||||
|
||||
class LoginFrameController{
|
||||
#include "../../Core/DBHandler/DBLogin/DBLogin.hpp"
|
||||
#include "../../Core/config/config.hpp"
|
||||
|
||||
class LoginFrameController {
|
||||
private:
|
||||
std::string m_connectionString;
|
||||
public:
|
||||
LoginFrameController();
|
||||
bool tryLogin(QString id, QString password);
|
||||
LoginFrameController( );
|
||||
int tryLogin(QString id, QString password);
|
||||
};
|
||||
@@ -7,13 +7,13 @@ PlanGridController::PlanGridController( ) {
|
||||
weekdays[3] = "Donnerstag";
|
||||
weekdays[4] = "Freitag";
|
||||
|
||||
times[0] = "8:00 - 10:00";
|
||||
times[1] = "10:00 - 12:00";
|
||||
times[2] = "12:00 - 14:00";
|
||||
times[3] = "14:00 - 16:00";
|
||||
times[4] = "16:00 - 18:00";
|
||||
times[0] = "08:00";
|
||||
times[1] = "10:00";
|
||||
times[2] = "12:00";
|
||||
times[3] = "14:00";
|
||||
times[4] = "16:00";
|
||||
|
||||
planMap = new QMap<QPair<QString, QString>, QLabel*>( );
|
||||
planMap = new QMap<QPair<QString, QString>, QWidget*>( );
|
||||
|
||||
const std::map<std::string, std::string> config = load_config("../config.cfg");
|
||||
|
||||
@@ -27,43 +27,98 @@ PlanGridController::PlanGridController( ) {
|
||||
);
|
||||
}
|
||||
|
||||
QMap<QPair<QString, QString>, QLabel*>* PlanGridController::getVeranstaltungen( ) {
|
||||
QMap<QPair<QString, QString>, QWidget*>* PlanGridController::getVeranstaltungen( ) {
|
||||
DBPlan* db = new DBPlan(m_connectionString);
|
||||
|
||||
// stringFormat = tag , anfangszeit , Ort , Veranstaltung , Mitarbeiter , mitarbeiterID
|
||||
std::vector<std::string> planData = db->getPlan( );
|
||||
|
||||
QString tag;
|
||||
QString anfang;
|
||||
QString ort;
|
||||
QString name;
|
||||
QString mitarbeiter;
|
||||
QString mitarbeiterId;
|
||||
std::string temp;
|
||||
for (const auto& veranstaltung : planData) {
|
||||
std::istringstream f(veranstaltung);
|
||||
std::getline(f, temp, ',');
|
||||
tag.fromStdString(temp);
|
||||
std::getline(f, temp, ',');
|
||||
anfang.fromStdString(temp);
|
||||
std::getline(f, temp, ',');
|
||||
ort.fromStdString(temp);
|
||||
std::getline(f, temp, ',');
|
||||
name.fromStdString(temp);
|
||||
std::getline(f, temp, ',');
|
||||
mitarbeiter.fromStdString(temp);
|
||||
std::getline(f, temp, ',');
|
||||
mitarbeiterId.fromStdString(temp);
|
||||
|
||||
QLabel* temp = new QLabel(name + "\n" + mitarbeiter + "\n" + ort);
|
||||
for (int i = 0; i < 5; ++i)
|
||||
for (int j = 0; j < 5; ++j) {
|
||||
QLabel* temp = new QLabel( );
|
||||
temp->setObjectName("temp");
|
||||
temp->setStyleSheet(R"(
|
||||
#temp{
|
||||
|
||||
background-color: #313131;
|
||||
}
|
||||
)");
|
||||
temp->setFixedSize(240, 100);
|
||||
planMap->insert(qMakePair(tag, anfang), temp);
|
||||
planMap->insert(qMakePair(weekdays[i], times[j]), temp);
|
||||
}
|
||||
|
||||
std::string color;
|
||||
|
||||
for (const auto& veranstaltung : planData) {
|
||||
|
||||
std::vector<std::string> infoVector;
|
||||
std::stringstream ss(veranstaltung);
|
||||
std::string str;
|
||||
|
||||
while (std::getline(ss, str, ','))
|
||||
infoVector.push_back(str);
|
||||
|
||||
//Wochentag, Uhrzeit,Uhrzeitende, Campus, Veranstaltung, ProfName,raum, veranstaltungs dauer
|
||||
QFrame* container = new QFrame( );
|
||||
|
||||
container->setObjectName("container");
|
||||
container->setStyleSheet(R"(
|
||||
#container{
|
||||
background-color: #313131;
|
||||
}
|
||||
)");
|
||||
auto layout = new QVBoxLayout(container);
|
||||
container->setLayout(layout);
|
||||
|
||||
QPushButton* widget = new QPushButton(QString::fromStdString(infoVector.at(4) + " - " + infoVector.at(5) + "\n" + infoVector.at(3) + infoVector.at(6)));
|
||||
layout->addWidget(widget);
|
||||
//widget->setAlignment(Qt::AlignCenter);
|
||||
widget->setObjectName("widget");
|
||||
widget->setFixedSize(210, 70);
|
||||
layout->setAlignment(Qt::AlignCenter);
|
||||
connect(widget, &QPushButton::clicked, this, [infoVector]( ) {
|
||||
fmt::print("clicked on " + infoVector.at(4) + '\n');
|
||||
});
|
||||
|
||||
if (infoVector.at(4) == "THI") {
|
||||
color = "#9FA8DA";
|
||||
} else if (infoVector.at(4) == "DBS") {
|
||||
color = "#EF9A9A";
|
||||
} else if (infoVector.at(4) == "WIN") {
|
||||
color = "#FFCC80";
|
||||
} else if (infoVector.at(4) == "ALD") {
|
||||
color = "#E6EE9C";
|
||||
} else if (infoVector.at(4) == "GDI") {
|
||||
color = "#90CAF9";
|
||||
} else if (infoVector.at(4) == "BSY") {
|
||||
color = "#FFF59D";
|
||||
} else if (infoVector.at(4) == "ITS") {
|
||||
color = "#9FA8DA";
|
||||
} else if (infoVector.at(4) == "WEB") {
|
||||
color = "#A5D6A7";
|
||||
} else if (infoVector.at(4) == "BVA") {
|
||||
color = "#80CBC4";
|
||||
} else if (infoVector.at(4) == "SWE") {
|
||||
color = "#80DEEA";
|
||||
} else {
|
||||
color = "#313131";
|
||||
}
|
||||
|
||||
widget->setStyleSheet(QString::fromStdString(R"(
|
||||
#widget{
|
||||
border: 0px solid #313131;
|
||||
background-color: )" + color + R"(;
|
||||
color: #212121;
|
||||
font-weight: 900;
|
||||
font-size: 18px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
)"));
|
||||
|
||||
container->setFixedSize(240, 100);
|
||||
planMap->insert(qMakePair(
|
||||
weekdays[std::stoi(infoVector.at(0)) - 1],
|
||||
QString::fromStdString(infoVector.at(1).erase(5, 8))),
|
||||
container);
|
||||
}
|
||||
|
||||
return planMap;
|
||||
|
||||
@@ -3,21 +3,24 @@
|
||||
#include <QLabel>
|
||||
#include <sstream>
|
||||
#include <fmt/format.h>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "../../Core/config/config.hpp"
|
||||
#include "../../Core/DBHandler/DBPlan/DBPlan.hpp"
|
||||
|
||||
class PlanGridController {
|
||||
class PlanGridController : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::string m_connectionString;
|
||||
|
||||
protected:
|
||||
QString weekdays[5];
|
||||
QString times[5];
|
||||
QMap<QPair<QString, QString>, QLabel*>* planMap;
|
||||
QMap<QPair<QString, QString>, QWidget*>* planMap;
|
||||
|
||||
public:
|
||||
PlanGridController( );
|
||||
|
||||
QMap<QPair<QString, QString>, QLabel*>* getVeranstaltungen( );
|
||||
QMap<QPair<QString, QString>, QWidget*>* getVeranstaltungen( );
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma onc
|
||||
#pragma once
|
||||
|
||||
#include <pqxx/pqxx>
|
||||
#include <string>
|
||||
|
||||
@@ -11,11 +11,7 @@ int DBLogin::checkValidLogin(std::string id, std::string pw) {
|
||||
|
||||
pqxx::result response = worker.exec_params(query, id, pw);
|
||||
|
||||
if (response.affected_rows( ) > 0) {
|
||||
if (response[0][0].is_null( ))
|
||||
return 0;
|
||||
return response[0][0].as<bool>( );
|
||||
}
|
||||
return response.affected_rows( ) > 0 ? response[0][0].as<bool>( ) : -1;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
fmt::printf("ERROR: %s", e.what( ));
|
||||
|
||||
@@ -13,7 +13,6 @@ void DBPlan::vertretung(std::string tag, std::string stunde, std::string dauer)
|
||||
nextStunde = std::to_string(std::stoi(stunde) + 2);
|
||||
else
|
||||
nextStunde = std::to_string(std::stoi(stunde) + 1);
|
||||
fmt::print(nextStunde);
|
||||
|
||||
if (prevStunde == "0") {
|
||||
prevStunde = "5";
|
||||
@@ -95,12 +94,12 @@ void DBPlan::deleteVeranstalterForeign(std::string id) {
|
||||
}
|
||||
|
||||
void DBPlan::deleteVeranstalter(std::string id) {
|
||||
try {
|
||||
deleteVeranstalterForeign(id);
|
||||
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("DELETE FROM Veranstalter WHERE ID = $1", id);
|
||||
worker.exec_params("DELETE FROM Veranstalter WHERE ID = $1;", id);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
@@ -108,12 +107,13 @@ void DBPlan::deleteVeranstalter(std::string id) {
|
||||
}
|
||||
}
|
||||
|
||||
void DBPlan::deleteVeranstaltungForeign(std::string id) {
|
||||
void DBPlan::deleteVeranstaltungForeign(std::string name) {
|
||||
try {
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstaltung_ID = NULL WHERE Veranstalter_ID = $1;", id);
|
||||
worker.exec_params("DELETE FROM Veranstalter_Veranstaltung_Uhrzeit WHERE Veranstaltung_ID = (SELECT ID FROM Veranstaltung WHERE name = '$1');", name);
|
||||
worker.commit( );
|
||||
|
||||
versendeEmails( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
@@ -122,12 +122,12 @@ void DBPlan::deleteVeranstaltungForeign(std::string id) {
|
||||
}
|
||||
|
||||
void DBPlan::deleteVeranstaltung(std::string id) {
|
||||
deleteVeranstaltungForeign(id);
|
||||
|
||||
try {
|
||||
//deleteVeranstaltungForeign(id);
|
||||
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
worker.exec_params("DELETE FROM Veranstaltung WHERE ID = $1", id);
|
||||
worker.exec_params("DELETE FROM Veranstaltung WHERE name = $1;", id);
|
||||
worker.commit( );
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
@@ -219,7 +219,6 @@ void DBPlan::addTwoHour(std::string tag, std::string stunde) {
|
||||
try {
|
||||
std::string prevStunde = std::to_string(std::stoi(stunde) - 1);
|
||||
|
||||
fmt::printf("PrevStunde: %s\n Tag: %s\n Stunde: %s \n", prevStunde, tag, stunde);
|
||||
pqxx::work worker(connectionObject);
|
||||
std::string query =
|
||||
R"(UPDATE Veranstalter_Veranstaltung_Uhrzeit SET Veranstalter_id = (SELECT ID FROM Veranstalter
|
||||
@@ -319,7 +318,6 @@ void DBPlan::createPlan( ) {
|
||||
std::string tagStr = std::to_string(tag);
|
||||
for (int stunde = 1; stunde < 6; stunde++) {
|
||||
std::string stundeStr = std::to_string(stunde);
|
||||
//get dauer of next class
|
||||
|
||||
if (std::stoi(getDauer(tagStr, stundeStr)) == 2) {
|
||||
stunde == 1 ? addFirstOfDayTwo(tagStr) : addTwoHour(tagStr, stundeStr);
|
||||
@@ -341,15 +339,17 @@ void DBPlan::createPlan( ) {
|
||||
}
|
||||
|
||||
std::vector<std::string> DBPlan::getPlan( ) {
|
||||
createPlan( );
|
||||
try {
|
||||
std::vector<std::string> plan;
|
||||
|
||||
pqxx::work worker(connectionObject);
|
||||
|
||||
std::string query =
|
||||
R"(SELECT tag, u.anfangszeit, u.endzeit, o.ort, o.name, v.name, v.ID FROM Veranstalter_Veranstaltung_Uhrzeit LEFT JOIN Veranstalter v ON Veranstalter_Veranstaltung_Uhrzeit.veranstalter_ID = v.ID
|
||||
LEFT JOIN Uhrzeit u ON Veranstalter_Veranstaltung_Uhrzeit.uhrzeit_ID = u.ID
|
||||
LEFT JOIN Veranstaltung o ON Veranstalter_Veranstaltung_Uhrzeit.veranstaltung_ID = o.ID
|
||||
R"(SELECT tag, u.anfangszeit, u.endzeit, o.ort, o.name, v.name, o.raum, v.ID FROM Veranstalter_Veranstaltung_Uhrzeit
|
||||
JOIN Veranstalter v ON Veranstalter_Veranstaltung_Uhrzeit.veranstalter_ID = v.ID
|
||||
JOIN Uhrzeit u ON Veranstalter_Veranstaltung_Uhrzeit.uhrzeit_ID = u.ID
|
||||
JOIN Veranstaltung o ON Veranstalter_Veranstaltung_Uhrzeit.veranstaltung_ID = o.ID
|
||||
ORDER BY tag, uhrzeit_ID;)";
|
||||
|
||||
pqxx::result response = worker.exec(query);
|
||||
@@ -359,7 +359,7 @@ std::vector<std::string> DBPlan::getPlan( ) {
|
||||
std::string rowstring;
|
||||
for (const auto& col : row) {
|
||||
rowstring.append(col.c_str( ));
|
||||
rowstring.append(" , ");
|
||||
rowstring.append(",");
|
||||
}
|
||||
plan.push_back(rowstring);
|
||||
}
|
||||
|
||||
@@ -190,9 +190,10 @@ void EinsatzplanFrame::deleteVeranstaltung( ) {
|
||||
QString text = QInputDialog::getText(this, tr("Veranstaltung Entfernen"),
|
||||
tr("Bitte geben sie den Veranstaltungskürzel ein:"), QLineEdit::Normal,
|
||||
"", &ok);
|
||||
(ok && text.size( ) == 3) ?
|
||||
QMessageBox::information(this, "Veranstaltung Entfernen", "Veranstaltungskürzel besteht aus 3 Zeichen!") :
|
||||
if (ok && text.size( ) == 3) {
|
||||
m_controller->deleteVeranstaltung(text);
|
||||
QMessageBox::information(this, "Veranstaltung entfernen", "Veranstaltung wird entfernt!");
|
||||
}
|
||||
}
|
||||
|
||||
void EinsatzplanFrame::createVeranstaltung( ) {
|
||||
@@ -212,9 +213,10 @@ void EinsatzplanFrame::deleteMember( ) {
|
||||
tr("Bitte geben sie die Mitarbeiter ID ein:"), QLineEdit::Normal,
|
||||
"", &ok);
|
||||
|
||||
(ok && text.size( ) == 7) ?
|
||||
QMessageBox::information(this, "Mitarbeiter entfernen", "Mitarbeiter wird entfernt!") :
|
||||
QMessageBox::information(this, "Mitarbeiter Entfernen", "Mitarbeiter ID besteht aus 7 Zahlen!");
|
||||
if (ok && text.size( ) == 7) {
|
||||
m_controller->deleteMember(text);
|
||||
QMessageBox::information(this, "Mitarbeiter entfernen", "Mitarbeiter wird entfernt!");
|
||||
}
|
||||
}
|
||||
|
||||
void EinsatzplanFrame::createMember( ) {
|
||||
|
||||
@@ -12,12 +12,11 @@ LoginFrame::LoginFrame(QWidget* parent)
|
||||
)");
|
||||
setFrameStyle(QFrame::Box);
|
||||
|
||||
|
||||
//create QWidgets and add LoginFrame as parent
|
||||
header_m = new QLabel("Einsatzplan", this);
|
||||
header_m->setFrameStyle(QFrame::Box);
|
||||
header_m->setObjectName("Header");
|
||||
header_m->setStyleSheet(R"(
|
||||
m_header = new QLabel("Einsatzplan", this);
|
||||
m_header->setFrameStyle(QFrame::Box);
|
||||
m_header->setObjectName("Header");
|
||||
m_header->setStyleSheet(R"(
|
||||
#Header{
|
||||
color: #93F8FF;
|
||||
font-size: 36px;
|
||||
@@ -25,14 +24,13 @@ LoginFrame::LoginFrame(QWidget* parent)
|
||||
border: none;
|
||||
}
|
||||
)");
|
||||
header_m->show( );
|
||||
m_header->show( );
|
||||
|
||||
|
||||
id_m = new QLineEdit(this);
|
||||
id_m->setPlaceholderText("ID...");
|
||||
id_m->setObjectName("ID");
|
||||
id_m->setFixedSize(300, 40);
|
||||
id_m->setStyleSheet(R"(
|
||||
m_id = new QLineEdit(this);
|
||||
m_id->setPlaceholderText("ID...");
|
||||
m_id->setObjectName("ID");
|
||||
m_id->setFixedSize(300, 40);
|
||||
m_id->setStyleSheet(R"(
|
||||
#ID{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
@@ -42,15 +40,14 @@ LoginFrame::LoginFrame(QWidget* parent)
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
id_m->show( );
|
||||
m_id->show( );
|
||||
|
||||
|
||||
password_m = new QLineEdit(this);
|
||||
password_m->setPlaceholderText("Passwort...");
|
||||
password_m->setObjectName("Password");
|
||||
password_m->setEchoMode(QLineEdit::Password);
|
||||
password_m->setFixedSize(300, 40);
|
||||
password_m->setStyleSheet(R"(
|
||||
m_password = new QLineEdit(this);
|
||||
m_password->setPlaceholderText("Passwort...");
|
||||
m_password->setObjectName("Password");
|
||||
m_password->setEchoMode(QLineEdit::Password);
|
||||
m_password->setFixedSize(300, 40);
|
||||
m_password->setStyleSheet(R"(
|
||||
#Password{
|
||||
color: #DADADA;
|
||||
font-size: 16px;
|
||||
@@ -60,12 +57,12 @@ LoginFrame::LoginFrame(QWidget* parent)
|
||||
border: 2px solid #414141;
|
||||
}
|
||||
)");
|
||||
password_m->show( );
|
||||
m_password->show( );
|
||||
|
||||
loginButton_m = new QPushButton("Login", this);
|
||||
loginButton_m->setObjectName("loginButton");
|
||||
loginButton_m->setFixedSize(QSize(150, 50));
|
||||
loginButton_m->setStyleSheet(R"(
|
||||
m_loginButton = new QPushButton("Login", this);
|
||||
m_loginButton->setObjectName("loginButton");
|
||||
m_loginButton->setFixedSize(QSize(150, 50));
|
||||
m_loginButton->setStyleSheet(R"(
|
||||
#loginButton{
|
||||
color: #212121;
|
||||
font-size: 24px;
|
||||
@@ -77,47 +74,50 @@ LoginFrame::LoginFrame(QWidget* parent)
|
||||
background-color: #43DC77;
|
||||
}
|
||||
)");
|
||||
loginButton_m->show( );
|
||||
m_loginButton->show( );
|
||||
|
||||
//create layout
|
||||
QVBoxLayout* layout = new QVBoxLayout( );
|
||||
|
||||
//layout->setContentsMargins(50, 20, 50, 20);
|
||||
layout->addWidget(header_m, 3, Qt::AlignCenter);
|
||||
layout->addWidget(id_m, 1, Qt::AlignCenter);
|
||||
layout->addWidget(password_m, 1, Qt::AlignCenter);
|
||||
layout->addWidget(loginButton_m, 3, Qt::AlignCenter);
|
||||
layout->addWidget(m_header, 3, Qt::AlignCenter);
|
||||
layout->addWidget(m_id, 1, Qt::AlignCenter);
|
||||
layout->addWidget(m_password, 1, Qt::AlignCenter);
|
||||
layout->addWidget(m_loginButton, 3, Qt::AlignCenter);
|
||||
|
||||
//add Layout to LoginFrame
|
||||
setLayout(layout);
|
||||
|
||||
//connect loginButton with function
|
||||
connect(loginButton_m, &QPushButton::clicked, this, &LoginFrame::loginButtonClicked);
|
||||
connect(m_loginButton, &QPushButton::clicked, this, &LoginFrame::loginButtonClicked);
|
||||
}
|
||||
|
||||
//try Login if Button clicked
|
||||
void LoginFrame::loginButtonClicked( ) {
|
||||
QString id = id_m->text( );
|
||||
QString password = password_m->text( );
|
||||
QString id = m_id->text( );
|
||||
QString password = m_password->text( );
|
||||
|
||||
//check if Contents Valid
|
||||
if (id.isEmpty( ) || password.isEmpty( )) {
|
||||
QMessageBox::warning(this, "Error", "Bitte füllen Sie sowohl die ID als auch das Passwort aus.");
|
||||
} else {
|
||||
LoginFrameController* controller = new LoginFrameController( );
|
||||
if (!controller->tryLogin(id, password)) {
|
||||
int res = controller->tryLogin(id, password);
|
||||
if (res == -1) {
|
||||
QMessageBox::warning(this, "Error", "ID und Passwort stimmen nicht überein!");
|
||||
} else {
|
||||
((QWidget*)(this->parent( )))->hide( );
|
||||
//TODO: Create new window
|
||||
EinsatzplanWindow* win = new EinsatzplanWindow(nullptr, id, res);
|
||||
win->show( );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LoginFrame::~LoginFrame( ) {
|
||||
header_m->~QLabel( );
|
||||
id_m->~QLineEdit( );
|
||||
password_m->~QLineEdit( );
|
||||
loginButton_m->~QPushButton( );
|
||||
parent_m->~QMainWindow( );
|
||||
m_header->~QLabel( );
|
||||
m_id->~QLineEdit( );
|
||||
m_password->~QLineEdit( );
|
||||
m_loginButton->~QPushButton( );
|
||||
m_parent->~QMainWindow( );
|
||||
}
|
||||
|
||||
@@ -1,26 +1,29 @@
|
||||
# pragma once
|
||||
# include <QFrame>
|
||||
# include <QWidget>
|
||||
# include <QPushButton>
|
||||
# include <QInputDialog>
|
||||
# include <QLabel>
|
||||
# include <QVBoxLayout>
|
||||
# include <QMessageBox>
|
||||
# include <QMainWindow>
|
||||
# include "../../Controller/LoginFrameController/LoginFrameController.hpp"
|
||||
#pragma once
|
||||
|
||||
class LoginFrame : public QFrame{
|
||||
#include <QFrame>
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QInputDialog>
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "../../Controller/LoginFrameController/LoginFrameController.hpp"
|
||||
#include "../../View/EinsatzplanWindow/EinsatzplanWindow.hpp"
|
||||
|
||||
class LoginFrame : public QFrame {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
QMainWindow* parent_m;
|
||||
QLabel* header_m;
|
||||
QLineEdit* id_m;
|
||||
QLineEdit* password_m;
|
||||
QPushButton* loginButton_m;
|
||||
QMainWindow* m_parent;
|
||||
QLabel* m_header;
|
||||
QLineEdit* m_id;
|
||||
QLineEdit* m_password;
|
||||
QPushButton* m_loginButton;
|
||||
|
||||
void loginButtonClicked();
|
||||
void loginButtonClicked( );
|
||||
|
||||
public:
|
||||
LoginFrame(QWidget* parent = nullptr);
|
||||
~LoginFrame();
|
||||
~LoginFrame( );
|
||||
};
|
||||
@@ -1,9 +1,8 @@
|
||||
#include "LoginWindow.hpp"
|
||||
|
||||
LoginWindow::LoginWindow(QWidget* parent)
|
||||
:QMainWindow(parent)
|
||||
{
|
||||
frame_m = new LoginFrame(this);
|
||||
setFixedSize(400,550);
|
||||
frame_m->setFixedSize(size());
|
||||
:QMainWindow(parent) {
|
||||
m_frame = new LoginFrame(this);
|
||||
setFixedSize(400, 550);
|
||||
m_frame->setFixedSize(size( ));
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
# pragma once
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "../LoginFrame/LoginFrame.hpp"
|
||||
|
||||
class LoginWindow : public QMainWindow{
|
||||
class LoginWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
private:
|
||||
LoginFrame* frame_m;
|
||||
|
||||
LoginFrame* m_frame;
|
||||
|
||||
public:
|
||||
LoginWindow(QWidget* parent = nullptr);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "PlanGrid.hpp"
|
||||
|
||||
PlanGrid::PlanGrid(QWidget* parent)
|
||||
:QWidget(parent) {
|
||||
:QWidget(parent),
|
||||
planGridController(new PlanGridController( )) {
|
||||
setObjectName("PlanGrid");
|
||||
setStyleSheet(R"(
|
||||
QWidget{
|
||||
@@ -16,31 +17,17 @@ PlanGrid::PlanGrid(QWidget* parent)
|
||||
m_weekdays[3] = "Donnerstag";
|
||||
m_weekdays[4] = "Freitag";
|
||||
|
||||
m_times[0] = "8:00 - 10:00";
|
||||
m_times[1] = "10:00 - 12:00";
|
||||
m_times[2] = "12:00 - 14:00";
|
||||
m_times[3] = "14:00 - 16:00";
|
||||
m_times[4] = "16:00 - 18:00";
|
||||
m_times[0] = "08:00";
|
||||
m_times[1] = "10:00";
|
||||
m_times[2] = "12:00";
|
||||
m_times[3] = "14:00";
|
||||
m_times[4] = "16:00";
|
||||
|
||||
planMap = new QMap<QPair<QString, QString>, QLabel*>( );
|
||||
planMap = new QMap<QPair<QString, QString>, QWidget*>( );
|
||||
|
||||
gridLayout = new QGridLayout(this);
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
for (int j = 0; j < 5; ++j) {
|
||||
QLabel* temp = new QLabel( );
|
||||
temp->setObjectName("temp");
|
||||
temp->setStyleSheet(R"(
|
||||
#temp{
|
||||
|
||||
}
|
||||
)");
|
||||
temp->setFixedSize(240, 100);
|
||||
planMap->insert(qMakePair(m_weekdays[i], m_times[j]), temp);
|
||||
}
|
||||
|
||||
populateGrid( );
|
||||
|
||||
// Empty top left corner
|
||||
QLabel* temp = new QLabel( );
|
||||
temp->setObjectName("temp");
|
||||
temp->setStyleSheet(R"(
|
||||
@@ -51,6 +38,7 @@ PlanGrid::PlanGrid(QWidget* parent)
|
||||
temp->setFixedSize(130, 80);
|
||||
gridLayout->addWidget(temp, 0, 0);
|
||||
|
||||
// Add Weekdays ontop of plan
|
||||
for (int i = 0; i < 5; i++) {
|
||||
QLabel* temp = new QLabel(m_weekdays[i]);
|
||||
temp->setFixedSize(240, 80);
|
||||
@@ -77,6 +65,7 @@ PlanGrid::PlanGrid(QWidget* parent)
|
||||
gridLayout->addWidget(temp, 0, i + 1);
|
||||
}
|
||||
|
||||
// Add times left to plan
|
||||
for (int i = 0; i < 5; i++) {
|
||||
QLabel* temp = new QLabel(m_times[i]);
|
||||
temp->setFixedSize(130, 100);
|
||||
@@ -103,6 +92,9 @@ PlanGrid::PlanGrid(QWidget* parent)
|
||||
gridLayout->addWidget(temp, i + 1, 0);
|
||||
}
|
||||
|
||||
planMap = planGridController->getVeranstaltungen( );
|
||||
populateGrid( );
|
||||
|
||||
gridLayout->setSpacing(0);
|
||||
setLayout(gridLayout);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ private:
|
||||
|
||||
protected:
|
||||
QGridLayout* gridLayout;
|
||||
QMap<QPair<QString, QString>, QLabel*>* planMap;
|
||||
QMap<QPair<QString, QString>, QWidget*>* planMap;
|
||||
PlanGridController* planGridController;
|
||||
|
||||
public:
|
||||
PlanGrid(QWidget* parent = nullptr);
|
||||
|
||||
14
src/main.cpp
14
src/main.cpp
@@ -1,10 +1,10 @@
|
||||
# include <QApplication>
|
||||
#include <QApplication>
|
||||
|
||||
# include "View/LoginWindow/LoginWindow.hpp"
|
||||
#include "View/LoginWindow/LoginWindow.hpp"
|
||||
|
||||
int main(int argc, char* argv[]){
|
||||
QApplication app(argc,argv);
|
||||
LoginWindow* loginWindow = new LoginWindow();
|
||||
loginWindow->show();
|
||||
return app.exec();
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
LoginWindow* loginWindow = new LoginWindow( );
|
||||
loginWindow->show( );
|
||||
return app.exec( );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user