Skip to content

Absence edit #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b93524a
still not runnable
VWasser Feb 4, 2025
cc46e0d
Merge branch 'main' into absence_edit
VWasser Feb 4, 2025
1bebf2f
Working
VWasser Feb 4, 2025
ea44a02
Merge branch 'main' into absence_edit
RomanPodymov Feb 4, 2025
94b33e5
Remove commented code
RomanPodymov Feb 4, 2025
f0c14c0
Improvements
RomanPodymov Feb 4, 2025
2b4fee6
Remove the code that is never called
RomanPodymov Feb 13, 2025
57b7545
Now it's calling
RomanPodymov Feb 13, 2025
8189d49
Improvements
RomanPodymov Feb 13, 2025
8334c6f
Remove function that was not added (yet?)
RomanPodymov Feb 15, 2025
f3aed82
Shared pointer
RomanPodymov Feb 15, 2025
a9c3fd3
enum and renames
VWasser Feb 15, 2025
854351e
Merge remote-tracking branch 'origin/absence_edit' into absence_edit
VWasser Feb 15, 2025
d2b97c3
hideAllWindows()
VWasser Feb 18, 2025
df1aada
menuBar implemented and moved to Coordinaator
VWasser Feb 19, 2025
40bad53
inputAbsence layout
VWasser Feb 19, 2025
f927f81
Implemented hideAllSceens() everywhere
VWasser Feb 20, 2025
9fec5b9
runnable
VWasser Feb 21, 2025
615953d
ScreenWidget
RomanPodymov Feb 23, 2025
1998022
All screens are ScreenWidget
RomanPodymov Feb 23, 2025
7c90652
Passing intial data
RomanPodymov Feb 23, 2025
11c90fc
runnable and halfway done
VWasser Feb 24, 2025
c1a0f2b
More improvements
RomanPodymov Mar 2, 2025
2d864d6
runnable, crashes while running in one instance
VWasser Mar 7, 2025
b318dfd
Merge commit '2d864d623f420304dc1dabf13f4829001e9c2e3f' into absence_…
RomanPodymov Mar 9, 2025
c005cfa
Build errors
RomanPodymov Mar 9, 2025
1d6bc3e
No INCLUDEPATH
RomanPodymov Mar 10, 2025
69d97f7
QSharedPointer
RomanPodymov Mar 10, 2025
c51de3b
so it is actualy the hour not the index
VWasser Mar 11, 2025
103fde3
Less params
RomanPodymov Mar 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions MyBachelor.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 15.0.0, 2025-02-03T08:37:44. -->
<!-- Written by QtCreator 15.0.1, 2025-02-19T11:03:49. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -86,9 +86,6 @@
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
</valuemap>
<valuemap type="QVariantMap" key="CppEditor.QuickFix">
<value type="bool" key="UseGlobalSettings">true</value>
</valuemap>
</valuemap>
</data>
<data>
Expand Down
6 changes: 4 additions & 2 deletions absencewindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ absenceWindow::absenceWindow(QWidget *parent): QWidget(parent) {
QObject::connect(addAbsence, &QPushButton::clicked, this, [&](){
coordinator->showSchedule();
emit scheduleAbsenceOpened();
hide();

// This SHOULD be hidden, but not sure, if I break something here now(
// hide();
});
absenceLayout->setFixedSize(315, 600);

Expand All @@ -28,6 +28,8 @@ absenceWindow::absenceWindow(QWidget *parent): QWidget(parent) {
absenceLayout->setHorizontalHeaderItem(4,late);
absenceLayout->setHorizontalHeaderItem(5,school);

coordinator->implementMenuBar(mainLayout);


mainLayout->addWidget(addAbsence);
mainLayout->addWidget(absenceLayout);
Expand Down
130 changes: 41 additions & 89 deletions coordinator.cpp
Original file line number Diff line number Diff line change
@@ -1,129 +1,81 @@
#include "coordinator.hpp"
#include "absencewindow.hpp"
#include "BackendlessQt/StandardNetworkManager.hpp"
#include "httpclient.hpp"
#include "menubar.hpp"
#include <QObject>

Coordinator::Coordinator(QObject *parent) : QObject(parent) {
myWindow = new SignInScreen();
myWindow2 = new registerscreen();
myWindow3 = new Schedule();
signInWindow = new SignInScreen();
registerWindow = new registerscreen();
popUpWindow = new settingsWindow();
menuWin = new menuWindow();
gradeWin = new gradesWindow();
abscWin = new absenceWindow();
//abscWin = QSharedPointer<absenceWindow>(new absenceWindow, &QObject::deleteLater);
absencePopUp = new inputAbsence();

QObject::connect(abscWin, &absenceWindow::scheduleAbsenceOpened, this, [&](){
emit scheduleAbsenceSend();
});
windows[Screen::SignIn] = signInWindow;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, looks cool

windows[Screen::Register] = registerWindow;
windows[Screen::Settings] = popUpWindow;
windows[Screen::Absence] = abscWin;
windows[Screen::Grades] = gradeWin;
windows[Screen::InputAbsence] = absencePopUp;

QObject::connect(abscWin.get(), &absenceWindow::scheduleAbsenceOpened, this, &Coordinator::sendScheduleAbsence);
}

Coordinator::~Coordinator() {}

void Coordinator::showSignInScreen() {
/*if (!signInScreen) {
signInScreen = new SignInScreen();
QObject::connect(signInScreen, &SignInScreen::goToMenu, this, []() {
auto coordinator = static_cast<Coordinator*>(QObject::sender()->parent());
coordinator->showMenuWindow();
coordinator->signInScreen->hide();
});
}*/
myWindow->show();
hideAllScreens(Screen::SignIn);
}


void Coordinator::showMenuWindow() {
if (!menuWin) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VWasser Found out that this code was never called. Why? Because menuWin is never NULL, you initialise it in Coordinator::Coordinator and never delete it.

menuWin = new ::menuWindow();
QObject::connect(menuWin, &menuWindow::absencePressed, this, [this]() {
auto coordinator = static_cast<Coordinator*>(QObject::sender()->parent());
coordinator->showAbsenceWindow();
coordinator->menuWin->hide();
});
QObject::connect(menuWin, &menuWindow::gradesPressed, this, [this]() {
auto coordinator = static_cast<Coordinator*>(QObject::sender()->parent());
coordinator->showGradesWindow();
coordinator->menuWin->hide();
});
QObject::connect(menuWin, &menuWindow::settingsPressed, this, [this]() {
auto coordinator = static_cast<Coordinator*>(QObject::sender()->parent());
coordinator->showSettingsWindow();
coordinator->menuWin->hide();
});
menuWin = new menuWindow();
windows[Screen::Menu] = menuWin;
}
menuWin->show();
hideAllScreens(Screen::Menu);
}

void Coordinator::showAbsenceWindow() {
/*if (!absenceWindow) {
absenceWindow = new ::absenceWindow();
QObject::connect(absenceWindow, &AbsenceWindow::goBackToMenu, this, [this]() {
auto coordinator = static_cast<Coordinator*>(QObject::sender()->parent());
coordinator->showMenuWindow();
coordinator->absenceWindow->hide();
});
}*/
abscWin->show();
hideAllScreens(Screen::Absence);
}

void Coordinator::showGradesWindow() {
/*if (!gradesWindow) {
gradesWindow = new GradesWindow();
QObject::connect(gradesWindow, &GradesWindow::goBackToMenu, this, []() {
auto coordinator = static_cast<Coordinator*>(QObject::sender()->parent());
coordinator->showMenuWindow();
coordinator->gradesWindow->hide();
});
}*/
gradeWin->show();
hideAllScreens(Screen::Grades);
}

void Coordinator::showInputAbsence() {
/*if (!inputAbsence) {
inputAbsence = new InputAbsence();
QObject::connect(inputAbsence, &InputAbsence::goBackToAbsence, this, []() {
auto coordinator = static_cast<Coordinator*>(QObject::sender()->parent());
coordinator->showAbsenceWindow();
coordinator->inputAbsence->hide();
});
}*/
absencePopUp->show();
hideAllScreens(Screen::InputAbsence);
}

void Coordinator::showRegisterScreen() {
/*if (!registerScreen) {
registerScreen = new RegisterScreen();
QObject::connect(registerScreen, &RegisterScreen::goBackToSignIn, this, []() {
auto coordinator = static_cast<Coordinator*>(QObject::sender()->parent());
coordinator->showSignInScreen();
coordinator->registerScreen->hide();
});
}*/
myWindow2->show();
hideAllScreens(Screen::Register);
}

void Coordinator::showSettingsWindow() {
/*if (!settingsWindow) {
settingsWindow = new SettingsWindow();
QObject::connect(settingsWindow, &SettingsWindow::goBackToMenu, this, []() {
auto coordinator = static_cast<Coordinator*>(QObject::sender()->parent());
coordinator->showMenuWindow();
coordinator->settingsWindow->hide();
});
}*/
popUpWindow->show();
hideAllScreens(Screen::Settings);
}

void Coordinator::showSchedule() {
/*if (!schedule) {
schedule = new Schedule();
QObject::connect(schedule, &Schedule::goBackToMenu, this, []() {
auto coordinator = static_cast<Coordinator*>(QObject::sender()->parent());
coordinator->showMenuWindow();
coordinator->schedule->hide();
});
}*/
myWindow3->show();
if (!scheduleWindow) {
scheduleWindow = new Schedule();
windows[Screen::Schedule] = scheduleWindow;
}
hideAllScreens(Screen::Schedule);
}
void Coordinator::hideAllScreens(Screen exeption){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VWasser Any questions regarding this function?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, nor really, just maybe if there is a way to print out the name of enum elemet so i dont have to print out its adress in the debug SHOWING/HIDING.

for(auto i = windows.begin(); i != windows.end(); ++i ){
if(i.key() == exeption){
i.value()->show();
qDebug() << "SHOWING" << &i.key();
}else if(i.key() != exeption){
i.value()->hide();
qDebug()<< "HIDING" << &i.key();
}
}
}
void Coordinator::implementMenuBar(QBoxLayout *layout){
auto bar = new menuBar();
bar->menuBarStup(layout);
}
29 changes: 24 additions & 5 deletions coordinator.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef COORDINATOR_HPP
#define COORDINATOR_HPP

#include "BackendlessQt/BackendlessAPI.hpp"
#include "absencewindow.hpp"
#include "gradeswindow.hpp"
#include "httpclient.hpp"
Expand All @@ -11,6 +10,17 @@
#include <QObject>
#include <QPointer>

enum class Screen {
SignIn,
Register,
Schedule,
Menu,
Absence,
InputAbsence,
Grades,
Settings
};

class Coordinator : public QObject {
Q_OBJECT

Expand All @@ -27,19 +37,28 @@ class Coordinator : public QObject {
void showSettingsWindow();
void showSchedule();
void sendAbsenceSchedule();
void hideAllScreens(Screen exeption);
void implementMenuBar(QBoxLayout *layout);

private:
QMap<Screen, QWidget*>windows;

private:
//had to refrain from using shared pointer,
//it was making an error while making hide all function
QPointer<absenceWindow> abscWin;
QPointer<gradesWindow> gradeWin;
QPointer<inputAbsence> absencePopUp;
QPointer<menuWindow> menuWin;
QPointer<registerscreen> myWindow2;
QPointer<registerscreen> registerWindow;
QPointer<settingsWindow> popUpWindow;
QPointer<Schedule> myWindow3;
QPointer<SignInScreen> myWindow;
QPointer<Schedule> scheduleWindow;
QPointer<SignInScreen> signInWindow;

signals:
void scheduleAbsenceSend();
void sendScheduleAbsence();


};

#endif // COORDINATOR_HPP
9 changes: 8 additions & 1 deletion gradeswindow.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include "gradeswindow.hpp"
#include "coordinator.hpp"

gradesWindow::gradesWindow(QWidget *parent):QWidget(parent) {}
extern Coordinator *coordinator;

gradesWindow::gradesWindow(QWidget *parent):QWidget(parent) {
coordinator->implementMenuBar(mainLayout);
setLayout(mainLayout);

}


gradesWindow::~gradesWindow(){}
3 changes: 3 additions & 0 deletions gradeswindow.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef GRADESWINDOW_HPP
#define GRADESWINDOW_HPP

#include "qboxlayout.h"
#include <QWidget>

class gradesWindow : public QWidget
Expand All @@ -9,6 +10,8 @@ class gradesWindow : public QWidget
public:
gradesWindow(QWidget *parent = nullptr);
~gradesWindow();
private:
QVBoxLayout *mainLayout = new QVBoxLayout;
};


Expand Down
31 changes: 30 additions & 1 deletion inputabsence.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,33 @@
#include "inputabsence.hpp"
#include "coordinator.hpp"

inputAbsence::inputAbsence(QWidget *parent): QWidget(parent) {}
extern Coordinator *coordinator;

inputAbsence::inputAbsence(QWidget *parent): QWidget(parent) {

QObject::connect(addAbsence, &QPushButton::clicked,this, [](){
coordinator->showSchedule();
});

setLayout(mainLayout);
nameLine->addWidget(nameLabel);
nameLine->addWidget(nameBox);

dateLine->addWidget(dateLabel);
dateLine->addWidget(dateBox);

classLine->addWidget(classLabel);
classLine->addWidget(classBox);

dayAndHourLine->addWidget(dayAndHourLabel);
dayAndHourLine->addWidget(dayBox);
dayAndHourLine->addWidget(hourBox);

mainLayout->addLayout(nameLine);
mainLayout->addLayout(dateLine);
mainLayout->addLayout(classLine);
mainLayout->addLayout(dayAndHourLine);
mainLayout->addWidget(addAbsence);

}
inputAbsence::~inputAbsence(){}
20 changes: 20 additions & 0 deletions inputabsence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ class inputAbsence : public QWidget
inputAbsence(QWidget *parent = nullptr);
~inputAbsence();
private:
QVBoxLayout *mainLayout = new QVBoxLayout;
QHBoxLayout *nameLine = new QHBoxLayout;
QHBoxLayout *dateLine = new QHBoxLayout;
QHBoxLayout *classLine = new QHBoxLayout;
QHBoxLayout *dayAndHourLine = new QHBoxLayout;

private:
QLabel *nameLabel = new QLabel(inputAbsence::tr("nameOfStudent"));
QLabel *dateLabel = new QLabel(inputAbsence::tr("dateOfAbsence"));
QLabel *classLabel = new QLabel(inputAbsence::tr("className"));
QLabel *dayAndHourLabel = new QLabel(inputAbsence::tr("DayAndHour"));

private:
QLineEdit *nameBox = new QLineEdit;
QLineEdit *dateBox = new QLineEdit;
QLineEdit *classBox = new QLineEdit;
QLineEdit *dayBox = new QLineEdit;
QLineEdit *hourBox = new QLineEdit;

QPushButton *addAbsence = new QPushButton(inputAbsence::tr("addAbsence"));


};
Expand Down
Loading