did a lot of fixed and stuff
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
int LoginFrameController::tryLogin(QString id, QString password) {
|
||||
DBLogin* loginHandler = new DBLogin(m_connectionString);
|
||||
|
||||
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);
|
||||
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(weekdays[i], times[j]), temp);
|
||||
}
|
||||
|
||||
QLabel* temp = new QLabel(name + "\n" + mitarbeiter + "\n" + ort);
|
||||
temp->setObjectName("temp");
|
||||
temp->setStyleSheet(R"(
|
||||
#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;
|
||||
}
|
||||
)");
|
||||
temp->setFixedSize(240, 100);
|
||||
planMap->insert(qMakePair(tag, anfang), temp);
|
||||
)");
|
||||
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( );
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user