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