School Commit Init

This commit is contained in:
2024-08-31 12:07:21 +03:00
commit 0b130ee18c
2801 changed files with 4720552 additions and 0 deletions
@@ -0,0 +1,56 @@
#include "GUI.h"
GUI::GUI()
{
this->mainWindow = new QWidget;
this->sideWindow = new QWidget;
this->showBtn = new QPushButton("Show for current day");
this->dateEdit = new QLineEdit;
this->allTaskList = new QListWidget;
this->dateTaskList = new QListWidget;
this->mainLayout = new QVBoxLayout;
this->sideLayout = new QVBoxLayout;
this->durationLabel = new QLabel;
this->mainLayout->addWidget(this->allTaskList);
for (auto task : this->service.getTasks()) {
this->allTaskList->addItem(QString::fromStdString(task.getDescription() + " | " + std::to_string(task.getDuration()) + " | " + task.getDate()));
if (task.getDate() < "2023.05.22") {
this->allTaskList->item(this->allTaskList->count() - 1)->setForeground(Qt::red);
}
}
this->mainLayout->addWidget(this->dateEdit);
this->mainLayout->addWidget(this->showBtn);
this->mainWindow->setLayout(this->mainLayout);
this->sideLayout->addWidget(this->dateTaskList);
this->sideLayout->addWidget(this->durationLabel);
this->sideWindow->setLayout(this->sideLayout);
QObject::connect(this->showBtn, &QPushButton::clicked, [&]() {
std::string date = this->dateEdit->text().toStdString();
int duration = 0;
this->dateTaskList->clear();
std::vector<Task> tasks = this->service.getTasksForDate(date);
if (tasks.size() == 0) {
QMessageBox::warning(this->mainWindow, "Warning", "No tasks for this date!");
return;
}
for (auto task : tasks) {
this->dateTaskList->addItem(QString::fromStdString(task.getDescription() + " | " + std::to_string(task.getDuration()) + " | " + task.getDate()));
duration += task.getDuration();
}
this->durationLabel->setText(QString::fromStdString("Duration: " + std::to_string(duration)));
this->sideWindow->show();
});
}
GUI::~GUI()
{
delete this->mainWindow;
delete this->sideWindow;
}
void GUI::show()
{
this->mainWindow->show();
}