diff --git a/src/DatabaseHandler/databasehandler.cpp b/src/DatabaseHandler/databasehandler.cpp new file mode 100644 index 0000000..7e05e79 --- /dev/null +++ b/src/DatabaseHandler/databasehandler.cpp @@ -0,0 +1,31 @@ +#include "databasehandler.h" +#include +#include +#include + +DatabaseHandler::DatabaseHandler(QObject *parent) + : QObject{parent} +{ + networkManager = new QNetworkAccessManager(this); +} + +DatabaseHandler::~DatabaseHandler() +{ + networkManager->deleteLater(); +} + +void DatabaseHandler::replyNetworkReadyRead() +{ + qDebug() << QString(networkReply->readAll()); +} + +QByteArray DatabaseHandler::getReply(const QString &url) +{ + QNetworkReply *reply = networkManager->get(QNetworkRequest(QUrl(url))); + QEventLoop loop; + connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit); + loop.exec(); + QByteArray data = reply->readAll(); + reply->deleteLater(); + return data; +} diff --git a/src/DatabaseHandler/databasehandler.h b/src/DatabaseHandler/databasehandler.h new file mode 100644 index 0000000..1a729dc --- /dev/null +++ b/src/DatabaseHandler/databasehandler.h @@ -0,0 +1,26 @@ +#ifndef DATABASEHANDLER_H +#define DATABASEHANDLER_H + +#include +#include +#include + +class DatabaseHandler : public QObject +{ + Q_OBJECT +public: + explicit DatabaseHandler(QObject *parent = nullptr); + ~DatabaseHandler(); + +signals: + +private: + QNetworkAccessManager *networkManager; + QNetworkReply *networkReply; + +public slots: + void replyNetworkReadyRead(); + QByteArray getReply(const QString &url); +}; + +#endif // DATABASEHANDLER_H diff --git a/src/Gradify.pro b/src/Gradify.pro index 9bf5e02..c7a14c5 100644 --- a/src/Gradify.pro +++ b/src/Gradify.pro @@ -1,24 +1,27 @@ -QT += core gui sql printsupport charts +QT += core gui printsupport charts network sql greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 app_bundle +QMAKE_CXXFLAGS += -pedantic -Wextra -Wall + # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ - aboutapp.cpp \ - appsetting.cpp \ - authorizationform.cpp \ + DatabaseHandler/databasehandler.cpp \ + aboutappwindow.cpp \ + appsettingswindow.cpp \ customWidgets/qlineeditwithbutton.cpp \ customWidgets/qsearchbar.cpp \ - filterform.cpp \ + filterwindow.cpp \ + loginwindow.cpp \ main.cpp \ mainwindow.cpp \ preloader.cpp \ - queryform.cpp \ + querywindow.cpp \ recordsForms/gradewindow.cpp \ recordsForms/groupwindow.cpp \ recordsForms/studentwindow.cpp \ @@ -31,15 +34,16 @@ SOURCES += \ statisticsForms/teacherstatistics.cpp HEADERS += \ - aboutapp.h \ - appsetting.h \ - authorizationform.h \ + DatabaseHandler/databasehandler.h \ + aboutappwindow.h \ + appsettingswindow.h \ customWidgets/qlineeditwithbutton.h \ customWidgets/qsearchbar.h \ - filterform.h \ + filterwindow.h \ + loginwindow.h \ mainwindow.h \ preloader.h \ - queryform.h \ + querywindow.h \ recordsForms/gradewindow.h \ recordsForms/groupwindow.h \ recordsForms/studentwindow.h \ @@ -52,13 +56,13 @@ HEADERS += \ statisticsForms/teacherstatistics.h FORMS += \ - aboutapp.ui \ - appsetting.ui \ - authorizationform.ui \ - filterform.ui \ + aboutappwindow.ui \ + appsettingswindow.ui \ + filterwindow.ui \ + loginwindow.ui \ mainwindow.ui \ preloader.ui \ - queryform.ui \ + querywindow.ui \ recordsForms/gradewindow.ui \ recordsForms/groupwindow.ui \ recordsForms/studentwindow.ui \ diff --git a/src/aboutapp.cpp b/src/aboutapp.cpp deleted file mode 100644 index 028c1b7..0000000 --- a/src/aboutapp.cpp +++ /dev/null @@ -1,85 +0,0 @@ -#include "aboutapp.h" -#include "ui_aboutapp.h" - -#include -#include - -aboutApp::aboutApp(QWidget *parent) : - QWidget(parent), - ui(new Ui::aboutApp) -{ - ui->setupUi(this); - setWindowTitle("Про Gradify"); - setFixedSize(width(), height()); -} - - -aboutApp::~aboutApp() -{ - delete ui; -} - - -void aboutApp::changeEvent(QEvent *event) -{ - QWidget::changeEvent(event); - if (event->type() == QEvent::ActivationChange) - { - if (not isActiveWindow()) - { - close(); - } - } -} - - -void aboutApp::setBlackUI() -{ - QFile file(":/styles/black/aboutApp/aboutApp.qss"); - file.open(QFile::ReadOnly); - setStyleSheet(QLatin1String(file.readAll())); - file.close(); -} - - -void aboutApp::setWhiteUI() -{ - QFile file(":/styles/white/aboutApp/aboutApp.qss"); - file.open(QFile::ReadOnly); - setStyleSheet(QLatin1String(file.readAll())); - file.close(); -} - - -void aboutApp::setSystemUI() -{ - QPalette basePalette; - QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); - - if (newBase.name() == "#000000") - { - setWhiteUI(); - } - else - { - setBlackUI(); - } -} - - -void aboutApp::setTheme(const QString &style) -{ - if (style == "black") - { - setBlackUI(); - } - else if (style == "white") - { - setWhiteUI(); - } - else - { - setSystemUI(); - } -} diff --git a/src/aboutappwindow.cpp b/src/aboutappwindow.cpp new file mode 100644 index 0000000..73ecbec --- /dev/null +++ b/src/aboutappwindow.cpp @@ -0,0 +1,72 @@ +#include "aboutappwindow.h" +#include "ui_aboutappwindow.h" + +#include +#include + +AboutAppWindow::AboutAppWindow(QWidget *parent) + : QWidget(parent) + , ui(new Ui::aboutApp) +{ + ui->setupUi(this); + setWindowTitle("Про Gradify"); + setFixedSize(width(), height()); + setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); +} + +AboutAppWindow::~AboutAppWindow() +{ + delete ui; +} + +void AboutAppWindow::changeEvent(QEvent *event) +{ + QWidget::changeEvent(event); + if (event->type() == QEvent::ActivationChange) { + if (not isActiveWindow()) { + close(); + } + } +} + +void AboutAppWindow::setBlackUI() +{ + QFile file(":/styles/black/aboutApp/aboutApp.qss"); + file.open(QFile::ReadOnly); + setStyleSheet(QLatin1String(file.readAll())); + file.close(); +} + +void AboutAppWindow::setWhiteUI() +{ + QFile file(":/styles/white/aboutApp/aboutApp.qss"); + file.open(QFile::ReadOnly); + setStyleSheet(QLatin1String(file.readAll())); + file.close(); +} + +void AboutAppWindow::setSystemUI() +{ + QPalette basePalette; + QColor baseColor = basePalette.base().color(); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); + + if (newBase.name() == "#000000") { + setWhiteUI(); + } else { + setBlackUI(); + } +} + +void AboutAppWindow::setTheme(const QString &style) +{ + if (style == "black") { + setBlackUI(); + } else if (style == "white") { + setWhiteUI(); + } else { + setSystemUI(); + } +} diff --git a/src/aboutapp.h b/src/aboutappwindow.h similarity index 60% rename from src/aboutapp.h rename to src/aboutappwindow.h index 38c2593..6a7a0e4 100644 --- a/src/aboutapp.h +++ b/src/aboutappwindow.h @@ -1,5 +1,5 @@ -#ifndef ABOUTAPP_H -#define ABOUTAPP_H +#ifndef ABOUTAPPWINDOW_H +#define ABOUTAPPWINDOW_H #include @@ -7,13 +7,13 @@ namespace Ui { class aboutApp; } -class aboutApp : public QWidget +class AboutAppWindow : public QWidget { Q_OBJECT public: - explicit aboutApp(QWidget *parent = nullptr); - ~aboutApp(); + explicit AboutAppWindow(QWidget *parent = nullptr); + ~AboutAppWindow(); void changeEvent(QEvent *event) override; private slots: @@ -26,7 +26,6 @@ private slots: public slots: void setTheme(const QString &style); - }; -#endif // ABOUTAPP_H +#endif // ABOUTAPPWINDOW_H diff --git a/src/aboutapp.ui b/src/aboutappwindow.ui similarity index 91% rename from src/aboutapp.ui rename to src/aboutappwindow.ui index e98552e..f7ada4e 100644 --- a/src/aboutapp.ui +++ b/src/aboutappwindow.ui @@ -26,7 +26,7 @@ - :/img/iconSets/icon_256x256.png + :/img/iconSets/icon_256x256.png true @@ -61,7 +61,7 @@ - <html><head/><body><p>Простота та зручність<br/>використання баз даних</p></body></html> + <html><head/><body><p>Простота та зручність<br/>в навчанні</p></body></html> Qt::AlignCenter @@ -100,6 +100,8 @@ - + + + diff --git a/src/appsetting.cpp b/src/appsettingswindow.cpp similarity index 55% rename from src/appsetting.cpp rename to src/appsettingswindow.cpp index 23d3898..20dba40 100644 --- a/src/appsetting.cpp +++ b/src/appsettingswindow.cpp @@ -1,13 +1,13 @@ -#include "appsetting.h" -#include "ui_appsetting.h" +#include "appsettingswindow.h" +#include "ui_appsettingswindow.h" -#include #include #include +#include -appSetting::appSetting(QWidget *parent) : - QWidget(parent), - ui(new Ui::appSetting) +AppSettingsWindow::AppSettingsWindow(QWidget *parent) + : QWidget(parent) + , ui(new Ui::AppSettingsWindow) { ui->setupUi(this); setWindowTitle("Налаштування"); @@ -20,71 +20,62 @@ appSetting::appSetting(QWidget *parent) : ui->succSaveSettings->setVisible(false); - QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", QSettings::IniFormat); - if (settingsConfig.contains("hostname") and - settingsConfig.contains("username") and - settingsConfig.contains("password") and - settingsConfig.contains("databasename")) - { - ui->dbhostnameLineEdit->setText(settingsConfig.value("hostname").toString()); + QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", + QSettings::IniFormat); + if (settingsConfig.contains("url") and settingsConfig.contains("username") + and settingsConfig.contains("password") and settingsConfig.contains("databasename")) { + ui->dburlLineEdit->setText(settingsConfig.value("url").toString()); ui->dbloginLineEdit->setText(settingsConfig.value("username").toString()); ui->dbpasswordLineEdit->setText(settingsConfig.value("password").toString()); ui->dbnameLineEdit->setText(settingsConfig.value("databasename").toString()); } } -appSetting::~appSetting() +AppSettingsWindow::~AppSettingsWindow() { delete ui; } - -void appSetting::changeEvent(QEvent *event) +void AppSettingsWindow::changeEvent(QEvent *event) { QWidget::changeEvent(event); - if (event->type() == QEvent::ActivationChange) - { - if (not isActiveWindow()) - { + if (event->type() == QEvent::ActivationChange) { + if (not isActiveWindow()) { ui->succSaveSettings->setVisible(false); } } } - -void appSetting::setBlackUI() +void AppSettingsWindow::setBlackUI() { - QFile file(":/styles/black/appSetting/appSetting.qss"); + QFile file(":/styles/black/AppSettingsWindow/AppSettingsWindow.qss"); file.open(QFile::ReadOnly); setStyleSheet(QLatin1String(file.readAll())); file.close(); ui->selectBlackUIRadioButton->setChecked(true); } - -void appSetting::setWhiteUI() +void AppSettingsWindow::setWhiteUI() { - QFile file(":/styles/white/appSetting/appSetting.qss"); + QFile file(":/styles/white/AppSettingsWindow/AppSettingsWindow.qss"); file.open(QFile::ReadOnly); setStyleSheet(QLatin1String(file.readAll())); file.close(); ui->selectWhiteUIRadioButton->setChecked(true); } - -void appSetting::setSystemUI() +void AppSettingsWindow::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { setWhiteUI(); emit changeThemeApp("white"); - } - else - { + } else { setBlackUI(); emit changeThemeApp("black"); } @@ -92,95 +83,80 @@ void appSetting::setSystemUI() ui->selectSystemUIRadioButton->setChecked(true); } - -void appSetting::on_selectWhiteUIButton_clicked() +void AppSettingsWindow::on_selectWhiteUIButton_clicked() { emit changeThemeApp("white"); setWhiteUI(); ui->selectWhiteUIRadioButton->setChecked(true); } - -void appSetting::on_selectBlackUIButton_clicked() +void AppSettingsWindow::on_selectBlackUIButton_clicked() { emit changeThemeApp("black"); setBlackUI(); ui->selectBlackUIRadioButton->setChecked(true); } - -void appSetting::on_selectWhiteUIRadioButton_clicked() +void AppSettingsWindow::on_selectWhiteUIRadioButton_clicked() { emit changeThemeApp("white"); setWhiteUI(); } - -void appSetting::on_selectBlackUIRadioButton_clicked() +void AppSettingsWindow::on_selectBlackUIRadioButton_clicked() { emit changeThemeApp("black"); setBlackUI(); } - -void appSetting::on_selectSystemUIButton_clicked() +void AppSettingsWindow::on_selectSystemUIButton_clicked() { setSystemUI(); ui->selectSystemUIRadioButton->setChecked(true); } - -void appSetting::on_selectSystemUIRadioButton_clicked() +void AppSettingsWindow::on_selectSystemUIRadioButton_clicked() { setSystemUI(); } - -void appSetting::setTheme(const QString &style) +void AppSettingsWindow::setTheme(const QString &style) { - if (style == "black") - { + if (style == "black") { setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { setWhiteUI(); - } - else - { + } else { setSystemUI(); } } -void appSetting::on_saveDBSettings_clicked() +void AppSettingsWindow::on_saveDBSettings_clicked() { - if (ui->dbhostnameLineEdit->text().isEmpty()) - { - QMessageBox::information(this, "Хост", "Введіть хост!"); - ui->dbhostnameLineEdit->setFocus(); + if (ui->dburlLineEdit->text().isEmpty()) { + QMessageBox::information(this, "URL", "Введіть URL бази даних!"); + ui->dburlLineEdit->setFocus(); return; } - if (ui->dbloginLineEdit->text().isEmpty()) - { + if (ui->dbloginLineEdit->text().isEmpty()) { QMessageBox::information(this, "Логін", "Введіть логін!"); ui->dbloginLineEdit->setFocus(); return; } - if (ui->dbpasswordLineEdit->text().isEmpty()) - { + if (ui->dbpasswordLineEdit->text().isEmpty()) { QMessageBox::information(this, "Пароль", "Введіть пароль!"); ui->dbpasswordLineEdit->setFocus(); return; } - if (ui->dbnameLineEdit->text().isEmpty()) - { + if (ui->dbnameLineEdit->text().isEmpty()) { QMessageBox::information(this, "Назва БД", "Введіть назву БД!"); ui->dbnameLineEdit->setFocus(); return; } - QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", QSettings::IniFormat); - settingsConfig.setValue("hostname", ui->dbhostnameLineEdit->text()); + QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", + QSettings::IniFormat); + settingsConfig.setValue("url", ui->dburlLineEdit->text()); settingsConfig.setValue("username", ui->dbloginLineEdit->text()); settingsConfig.setValue("password", ui->dbpasswordLineEdit->text()); settingsConfig.setValue("databasename", ui->dbnameLineEdit->text()); @@ -189,4 +165,3 @@ void appSetting::on_saveDBSettings_clicked() emit logoutSignal(); } - diff --git a/src/appsetting.h b/src/appsettingswindow.h similarity index 72% rename from src/appsetting.h rename to src/appsettingswindow.h index a50bf2d..44b097d 100644 --- a/src/appsetting.h +++ b/src/appsettingswindow.h @@ -1,22 +1,22 @@ -#ifndef APPSETTING_H -#define APPSETTING_H +#ifndef APPSETTINGSWINDOW_H +#define APPSETTINGSWINDOW_H -#include -#include #include +#include #include +#include namespace Ui { -class appSetting; +class AppSettingsWindow; } -class appSetting : public QWidget +class AppSettingsWindow : public QWidget { Q_OBJECT public: - explicit appSetting(QWidget *parent = nullptr); - ~appSetting(); + explicit AppSettingsWindow(QWidget *parent = nullptr); + ~AppSettingsWindow(); void changeEvent(QEvent *event) override; private slots: @@ -33,7 +33,7 @@ private slots: void on_saveDBSettings_clicked(); private: - Ui::appSetting *ui; + Ui::AppSettingsWindow *ui; signals: void changeThemeApp(const QString); @@ -41,7 +41,6 @@ private slots: public slots: void setTheme(const QString &style); - }; -#endif // APPSETTING_H +#endif // APPSETTINGSWINDOW_H diff --git a/src/appsetting.ui b/src/appsettingswindow.ui similarity index 98% rename from src/appsetting.ui rename to src/appsettingswindow.ui index cb0a62b..1469c62 100644 --- a/src/appsetting.ui +++ b/src/appsettingswindow.ui @@ -1,7 +1,7 @@ - appSetting - + AppSettingsWindow + 0 @@ -476,7 +476,7 @@ border-radius: 8px; <html><head/><body><p>Назва БД</p></body></html> - + 45 @@ -495,7 +495,7 @@ border-radius: 8px; - <html><head/><body><p>Хост (ip)</p></body></html> + <html><head/><body><p>URL бази даних</p></body></html> @@ -542,7 +542,7 @@ border-radius: 8px; <html><head/><body><p>Пароль</p></body></html> - + 190 diff --git a/src/customWidgets/qlineeditwithbutton.cpp b/src/customWidgets/qlineeditwithbutton.cpp index 0ff79e0..42dbdf1 100644 --- a/src/customWidgets/qlineeditwithbutton.cpp +++ b/src/customWidgets/qlineeditwithbutton.cpp @@ -15,26 +15,22 @@ QLineEditWithButton::QLineEditWithButton(QWidget *parent) connect(button, SIGNAL(clicked()), this, SLOT(buttonClick())); } - void QLineEditWithButton::resizeEvent(QResizeEvent *event) { int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); button->move(rect().right() - frameWidth - button->sizeHint().width(), 2); } - void QLineEditWithButton::buttonClick() { emit buttonClicked(); } - void QLineEditWithButton::setIconButton(QIcon icon) { button->setIcon(icon); } - void QLineEditWithButton::setIconSize(QSize size) { button->setIconSize(size); diff --git a/src/customWidgets/qlineeditwithbutton.h b/src/customWidgets/qlineeditwithbutton.h index 41c9fce..f3b7af6 100644 --- a/src/customWidgets/qlineeditwithbutton.h +++ b/src/customWidgets/qlineeditwithbutton.h @@ -24,8 +24,6 @@ public slots: signals: void buttonClicked(); - }; #endif // QLINEEDITWITHBUTTON_H - diff --git a/src/customWidgets/qsearchbar.cpp b/src/customWidgets/qsearchbar.cpp index 397efc8..6f64717 100644 --- a/src/customWidgets/qsearchbar.cpp +++ b/src/customWidgets/qsearchbar.cpp @@ -1,8 +1,8 @@ #include "qsearchbar.h" +#include #include #include -#include QSearchBar::QSearchBar(QWidget *parent) : QLineEdit{parent} @@ -25,22 +25,22 @@ QSearchBar::QSearchBar(QWidget *parent) connect(searchButton, SIGNAL(clicked()), this, SLOT(buttonClick())); connect(clearButton, SIGNAL(clicked()), this, SLOT(clearText())); - connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateClearButton(const QString))); + connect(this, + SIGNAL(textChanged(const QString &)), + this, + SLOT(updateClearButton(const QString))); } - void QSearchBar::resizeEvent(QResizeEvent *event) { int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); clearButton->move(rect().right() - frameWidth - searchButton->sizeHint().width() - 10, 2); - if (not hasFocus()) - { - searchButton->move(width()/2 - font->horizontalAdvance(placeholderText()) - 6, 2); + if (not hasFocus()) { + searchButton->move(width() / 2 - font->horizontalAdvance(placeholderText()) - 6, 2); } } - void QSearchBar::focusInEvent(QFocusEvent *event) { QLineEdit::focusInEvent(event); @@ -50,14 +50,12 @@ void QSearchBar::focusInEvent(QFocusEvent *event) emit haveFocus(true); } - void QSearchBar::focusOutEvent(QFocusEvent *event) { QLineEdit::focusOutEvent(event); playAnimationSearchButton(); - if (text().isEmpty()) - { + if (text().isEmpty()) { searchButton->setCursor(Qt::IBeamCursor); setAlignment(Qt::AlignCenter); } @@ -65,14 +63,12 @@ void QSearchBar::focusOutEvent(QFocusEvent *event) emit(haveFocus(false)); } - void QSearchBar::updateClearButton(const QString &text) { clearButton->setVisible(not text.isEmpty()); buttonClick(); } - void QSearchBar::buttonClick() { emit buttonSearchClick(); @@ -84,34 +80,32 @@ void QSearchBar::clearText() emit clickedClearButton(); } - void QSearchBar::playAnimationSearchButton() { - if (hasFocus() or not text().isEmpty()) - { + if (hasFocus() or not text().isEmpty()) { animationSearchButton->setDuration(this->width() / 1.85); animationSearchButton->setStartValue(searchButton->geometry()); - animationSearchButton->setEndValue(QRect(2, 2, searchButton->width(), searchButton->height())); + animationSearchButton->setEndValue( + QRect(2, 2, searchButton->width(), searchButton->height())); animationSearchButton->start(); - } - else - { + } else { animationSearchButton->setDuration(this->width() / 1.85); animationSearchButton->setStartValue(searchButton->geometry()); - animationSearchButton->setEndValue(QRect(width()/2 - font->horizontalAdvance(placeholderText()) - 6, 2, - searchButton->width(), searchButton->height())); + animationSearchButton->setEndValue( + QRect(width() / 2 - font->horizontalAdvance(placeholderText()) - 6, + 2, + searchButton->width(), + searchButton->height())); animationSearchButton->start(); } } - void QSearchBar::setIconSearchButton(QIcon icon, QSize size) { searchButton->setIcon(icon); searchButton->setIconSize(size); } - void QSearchBar::setIconClearButton(QIcon icon, QSize size) { clearButton->setIcon(icon); diff --git a/src/filterform.cpp b/src/filterwindow.cpp similarity index 68% rename from src/filterform.cpp rename to src/filterwindow.cpp index 28c3dce..7dab665 100644 --- a/src/filterform.cpp +++ b/src/filterwindow.cpp @@ -1,12 +1,12 @@ -#include "filterform.h" -#include "ui_filterform.h" +#include "filterwindow.h" +#include "ui_filterwindow.h" #include #include -filterForm::filterForm(QWidget *parent) : - QWidget(parent), - ui(new Ui::filterForm) +FilterWindow::FilterWindow(QWidget *parent) + : QWidget(parent) + , ui(new Ui::FilterWindow) { ui->setupUi(this); setWindowFlag(Qt::FramelessWindowHint, true); @@ -23,28 +23,20 @@ filterForm::filterForm(QWidget *parent) : close(); } - -filterForm::~filterForm() +FilterWindow::~FilterWindow() { delete ui; } - -bool filterForm::eventFilter(QObject *obj, QEvent *event) +bool FilterWindow::eventFilter(QObject *obj, QEvent *event) { - if (event->type() == QEvent::FocusIn) - { - if (ui->conditionComboBox->hasFocus()) - { + if (event->type() == QEvent::FocusIn) { + if (ui->conditionComboBox->hasFocus()) { ui->conditionComboBox->setGraphicsEffect(paintDropRedShadowEffect()); - } - else if (ui->tableComboBox->hasFocus()) - { + } else if (ui->tableComboBox->hasFocus()) { ui->tableComboBox->setGraphicsEffect(paintDropRedShadowEffect()); } - } - else if (event->type() == QEvent::FocusOut and not hasFocus()) - { + } else if (event->type() == QEvent::FocusOut and not hasFocus()) { ui->conditionComboBox->setGraphicsEffect(nullptr); ui->tableComboBox->setGraphicsEffect(nullptr); } @@ -52,8 +44,7 @@ bool filterForm::eventFilter(QObject *obj, QEvent *event) return false; } - -void filterForm::setListTable(const QMap colsNameAndType) +void FilterWindow::setListTable(const QMap colsNameAndType) { ui->clearFilterPushButton->setEnabled(false); ui->conditionComboBox->setEnabled(false); @@ -74,53 +65,40 @@ void filterForm::setListTable(const QMap colsNameAndType) ui->conditionLineEdit->setValidator(nullptr); } - -void filterForm::on_filterPushButton_clicked() +void FilterWindow::on_filterPushButton_clicked() { - if (ui->tableComboBox->currentIndex() > 0 - and ui->conditionComboBox->currentIndex() > 0 - and not ui->conditionLineEdit->text().isEmpty() - and currentPlaceHolderText not_eq "Дата") - { + if (ui->tableComboBox->currentIndex() > 0 and ui->conditionComboBox->currentIndex() > 0 + and not ui->conditionLineEdit->text().isEmpty() and currentPlaceHolderText not_eq "Дата") { strSqlFilter = "`" + ui->tableComboBox->currentText() + "` "; - if (currentPlaceHolderText == "Число") - { - if (ui->conditionComboBox->currentText() not_eq "between") - { - strSqlFilter += ui->conditionComboBox->currentText() + " " + ui->conditionLineEdit->text(); - } - else if (ui->conditionComboBox->currentText() == "between" and not ui->conditionLineEdit_2->text().isEmpty() - and ui->conditionLineEdit->text().toInt() < ui->conditionLineEdit_2->text().toInt()) - { - strSqlFilter += "BETWEEN " + ui->conditionLineEdit->text() + " AND " + ui->conditionLineEdit_2->text(); - } - else if (ui->conditionComboBox->currentText() == "between" and ui->conditionLineEdit_2->text().isEmpty()) - { + if (currentPlaceHolderText == "Число") { + if (ui->conditionComboBox->currentText() not_eq "between") { + strSqlFilter += ui->conditionComboBox->currentText() + " " + + ui->conditionLineEdit->text(); + } else if (ui->conditionComboBox->currentText() == "between" + and not ui->conditionLineEdit_2->text().isEmpty() + and ui->conditionLineEdit->text().toInt() + < ui->conditionLineEdit_2->text().toInt()) { + strSqlFilter += "BETWEEN " + ui->conditionLineEdit->text() + " AND " + + ui->conditionLineEdit_2->text(); + } else if (ui->conditionComboBox->currentText() == "between" + and ui->conditionLineEdit_2->text().isEmpty()) { QMessageBox::critical(this, "", "Введіть значення умови фільтрування!"); ui->conditionLineEdit_2->setFocus(); return; - } - else if (ui->conditionComboBox->currentText() == "between" - and ui->conditionLineEdit->text().toInt() >= ui->conditionLineEdit_2->text().toInt()) - { + } else if (ui->conditionComboBox->currentText() == "between" + and ui->conditionLineEdit->text().toInt() + >= ui->conditionLineEdit_2->text().toInt()) { QMessageBox::critical(this, "", "Перше значення повине бути меншим за друге!"); ui->conditionLineEdit->setFocus(); return; } - } - else if (currentPlaceHolderText == "Текст") - { - if (ui->conditionComboBox->currentText() == "like%") - { + } else if (currentPlaceHolderText == "Текст") { + if (ui->conditionComboBox->currentText() == "like%") { strSqlFilter += "LIKE '" + ui->conditionLineEdit->text() + "%'"; - } - else if (ui->conditionComboBox->currentText() == "%like") - { + } else if (ui->conditionComboBox->currentText() == "%like") { strSqlFilter += "LIKE '%" + ui->conditionLineEdit->text() + "'"; - } - else if (ui->conditionComboBox->currentText() == "%like%") - { + } else if (ui->conditionComboBox->currentText() == "%like%") { strSqlFilter += "LIKE '%" + ui->conditionLineEdit->text() + "%'"; } } @@ -129,47 +107,37 @@ void filterForm::on_filterPushButton_clicked() ui->clearFilterPushButton->setEnabled(true); } - else if (ui->tableComboBox->currentIndex() > 0 - and ui->conditionComboBox->currentIndex() > 0 - and currentPlaceHolderText == "Дата") - { - strSqlFilter = "`" + ui->tableComboBox->currentText() + "` " + - ui->conditionComboBox->currentText() - + " '" + QString::number(ui->conditionDataEdit->date().year()) + "-" + else if (ui->tableComboBox->currentIndex() > 0 and ui->conditionComboBox->currentIndex() > 0 + and currentPlaceHolderText == "Дата") { + strSqlFilter = "`" + ui->tableComboBox->currentText() + "` " + + ui->conditionComboBox->currentText() + " '" + + QString::number(ui->conditionDataEdit->date().year()) + "-" + QString::number(ui->conditionDataEdit->date().month()) + "-" + QString::number(ui->conditionDataEdit->date().day()) + "'"; emit sendFilter(strSqlFilter, ui->tableComboBox->currentText()); ui->clearFilterPushButton->setEnabled(true); show(); - } - else if (ui->tableComboBox->currentIndex() == 0) - { + } else if (ui->tableComboBox->currentIndex() == 0) { QMessageBox::critical(this, "", "Оберіть потрібну колонку!"); ui->tableComboBox->setFocus(); show(); - } - else if (ui->conditionComboBox->currentIndex() == 0) - { + } else if (ui->conditionComboBox->currentIndex() == 0) { QMessageBox::critical(this, "", "Оберіть умову!"); ui->conditionComboBox->setFocus(); show(); - } - else - { + } else { QMessageBox::critical(this, "", "Введіть значення умови фільтрування"); ui->conditionLineEdit->setFocus(); show(); } } - -void filterForm::on_conditionComboBox_currentTextChanged(const QString &arg1) +void FilterWindow::on_conditionComboBox_currentTextChanged(const QString &arg1) { ui->conditionComboBox->clearFocus(); - if (ui->conditionComboBox->currentText() == "between" and currentPlaceHolderText not_eq "Дата") - { + if (ui->conditionComboBox->currentText() == "between" and currentPlaceHolderText not_eq "Дата") { ui->conditionLineEdit_2->setVisible(true); ui->conditionLineEdit->setPlaceholderText("1"); @@ -181,15 +149,12 @@ void filterForm::on_conditionComboBox_currentTextChanged(const QString &arg1) ui->conditionLineEdit->resize(ui->conditionLineEdit->height() + 18, ui->conditionLineEdit->height()); - ui->conditionLineEdit_2->move(ui->conditionLineEdit->x() + 46, - ui->conditionLineEdit->y()); + ui->conditionLineEdit_2->move(ui->conditionLineEdit->x() + 46, ui->conditionLineEdit->y()); ui->conditionLineEdit_2->resize(ui->conditionLineEdit->height() + 18, ui->conditionLineEdit->height()); - } - else if (currentPlaceHolderText not_eq "Дата") - { + } else if (currentPlaceHolderText not_eq "Дата") { ui->conditionComboBox->resize(QSize(160, 21)); ui->conditionLineEdit->setPlaceholderText(currentPlaceHolderText); ui->conditionLineEdit->resize(70, ui->conditionLineEdit->height()); @@ -199,39 +164,32 @@ void filterForm::on_conditionComboBox_currentTextChanged(const QString &arg1) } } - -void filterForm::on_conditionLineEdit_editingFinished() +void FilterWindow::on_conditionLineEdit_editingFinished() { ui->conditionLineEdit->clearFocus(); } - -void filterForm::on_tableComboBox_currentTextChanged(const QString &arg1) +void FilterWindow::on_tableComboBox_currentTextChanged(const QString &arg1) { ui->tableComboBox->clearFocus(); - if ((typeColumnsMap.value(arg1) == "text" or typeColumnsMap.value(arg1) == "set") and typeColumnsMap.value(oldColumnSelect) not_eq typeColumnsMap.value(arg1)) - { + if ((typeColumnsMap.value(arg1) == "text" or typeColumnsMap.value(arg1) == "set") + and typeColumnsMap.value(oldColumnSelect) not_eq typeColumnsMap.value(arg1)) { setStringTypeComboBox(); - } - else if (typeColumnsMap.value(arg1) == "int" and typeColumnsMap.value(oldColumnSelect) not_eq typeColumnsMap.value(arg1)) - { + } else if (typeColumnsMap.value(arg1) == "int" + and typeColumnsMap.value(oldColumnSelect) not_eq typeColumnsMap.value(arg1)) { setIntTypeComboBox(); - } - else if (typeColumnsMap.value(arg1) == "date" and typeColumnsMap.value(oldColumnSelect) not_eq typeColumnsMap.value(arg1)) - { + } else if (typeColumnsMap.value(arg1) == "date" + and typeColumnsMap.value(oldColumnSelect) not_eq typeColumnsMap.value(arg1)) { setDateTypeComboBox(); - } - else if (ui->tableComboBox->currentIndex() == 0) - { + } else if (ui->tableComboBox->currentIndex() == 0) { setDisabledComboBox(); } oldColumnSelect = arg1; } - -void filterForm::setIntTypeComboBox() +void FilterWindow::setIntTypeComboBox() { ui->conditionComboBox->setEnabled(true); ui->conditionComboBox->clear(); @@ -250,12 +208,9 @@ void filterForm::setIntTypeComboBox() currentPlaceHolderText = "Число"; ui->conditionLineEdit->setPlaceholderText(currentPlaceHolderText); - if (not ui->conditionLineEdit->text().toInt()) - { + if (not ui->conditionLineEdit->text().toInt()) { ui->conditionLineEdit->clear(); - } - else if (not ui->conditionLineEdit_2->text().toInt()) - { + } else if (not ui->conditionLineEdit_2->text().toInt()) { ui->conditionLineEdit_2->clear(); } @@ -268,8 +223,7 @@ void filterForm::setIntTypeComboBox() ui->conditionLineEdit->resize(QSize(70, 21)); } - -void filterForm::setStringTypeComboBox() +void FilterWindow::setStringTypeComboBox() { ui->conditionComboBox->setEnabled(true); ui->conditionComboBox->clear(); @@ -294,8 +248,7 @@ void filterForm::setStringTypeComboBox() ui->conditionLineEdit->resize(QSize(70, 21)); } - -void filterForm::setDateTypeComboBox() +void FilterWindow::setDateTypeComboBox() { ui->conditionComboBox->setEnabled(true); ui->conditionComboBox->clear(); @@ -318,8 +271,7 @@ void filterForm::setDateTypeComboBox() ui->conditionComboBox->resize(QSize(150, 21)); } - -void filterForm::setDisabledComboBox() +void FilterWindow::setDisabledComboBox() { ui->conditionComboBox->setEnabled(false); ui->conditionComboBox->setCurrentIndex(0); @@ -328,8 +280,7 @@ void filterForm::setDisabledComboBox() ui->conditionLineEdit_2->clear(); } - -QGraphicsDropShadowEffect *filterForm::paintDropRedShadowEffect() +QGraphicsDropShadowEffect *FilterWindow::paintDropRedShadowEffect() { QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this); effect->setBlurRadius(25); @@ -338,10 +289,8 @@ QGraphicsDropShadowEffect *filterForm::paintDropRedShadowEffect() return effect; } - -void filterForm::on_clearFilterPushButton_clicked() +void FilterWindow::on_clearFilterPushButton_clicked() { ui->clearFilterPushButton->setEnabled(false); emit clearFilter(); } - diff --git a/src/filterform.h b/src/filterwindow.h similarity index 81% rename from src/filterform.h rename to src/filterwindow.h index 3276408..687eed0 100644 --- a/src/filterform.h +++ b/src/filterwindow.h @@ -1,20 +1,20 @@ -#ifndef FILTERFORM_H -#define FILTERFORM_H +#ifndef FILTERWINDOW_H +#define FILTERWINDOW_H -#include #include +#include namespace Ui { -class filterForm; +class FilterWindow; } -class filterForm : public QWidget +class FilterWindow : public QWidget { Q_OBJECT public: - explicit filterForm(QWidget *parent = nullptr); - ~filterForm(); + explicit FilterWindow(QWidget *parent = nullptr); + ~FilterWindow(); bool eventFilter(QObject *obj, QEvent *event); private slots: @@ -33,7 +33,7 @@ private slots: QGraphicsDropShadowEffect *paintDropRedShadowEffect(); private: - Ui::filterForm *ui; + Ui::FilterWindow *ui; QString currentTabelSelect; QString currentPlaceHolderText; @@ -50,4 +50,4 @@ public slots: void clearFilter(); }; -#endif // FILTERFORM_H +#endif // FILTERWINDOW_H diff --git a/src/filterform.ui b/src/filterwindow.ui similarity index 98% rename from src/filterform.ui rename to src/filterwindow.ui index 1d7d161..884944e 100644 --- a/src/filterform.ui +++ b/src/filterwindow.ui @@ -1,7 +1,7 @@ - filterForm - + FilterWindow + 0 diff --git a/src/img/blackActionsIcon/raitingIco.png b/src/img/blackActionsIcon/gradesIco.png similarity index 100% rename from src/img/blackActionsIcon/raitingIco.png rename to src/img/blackActionsIcon/gradesIco.png diff --git a/src/img/blackActionsIcon/groupIco.png b/src/img/blackActionsIcon/groupsIco.png similarity index 100% rename from src/img/blackActionsIcon/groupIco.png rename to src/img/blackActionsIcon/groupsIco.png diff --git a/src/img/blackActionsIcon/reportRaiting.png b/src/img/blackActionsIcon/reportGrades.png similarity index 100% rename from src/img/blackActionsIcon/reportRaiting.png rename to src/img/blackActionsIcon/reportGrades.png diff --git a/src/img/blackActionsIcon/reportGroup.png b/src/img/blackActionsIcon/reportGroups.png similarity index 100% rename from src/img/blackActionsIcon/reportGroup.png rename to src/img/blackActionsIcon/reportGroups.png diff --git a/src/img/blackActionsIcon/reportStudent.png b/src/img/blackActionsIcon/reportStudents.png similarity index 100% rename from src/img/blackActionsIcon/reportStudent.png rename to src/img/blackActionsIcon/reportStudents.png diff --git a/src/img/blackActionsIcon/reportItem.png b/src/img/blackActionsIcon/reportSubjects.png similarity index 100% rename from src/img/blackActionsIcon/reportItem.png rename to src/img/blackActionsIcon/reportSubjects.png diff --git a/src/img/blackActionsIcon/subjectIco.png b/src/img/blackActionsIcon/subjectsIco.png similarity index 100% rename from src/img/blackActionsIcon/subjectIco.png rename to src/img/blackActionsIcon/subjectsIco.png diff --git a/src/img/blackMenuIcon/raitingIco.png b/src/img/blackMenuIcon/gradesIco.png similarity index 100% rename from src/img/blackMenuIcon/raitingIco.png rename to src/img/blackMenuIcon/gradesIco.png diff --git a/src/img/blackMenuIcon/groupIco.png b/src/img/blackMenuIcon/groupsIco.png similarity index 100% rename from src/img/blackMenuIcon/groupIco.png rename to src/img/blackMenuIcon/groupsIco.png diff --git a/src/img/blackMenuIcon/subjectIco.png b/src/img/blackMenuIcon/subjectsIco.png similarity index 100% rename from src/img/blackMenuIcon/subjectIco.png rename to src/img/blackMenuIcon/subjectsIco.png diff --git a/src/img/blueMenuIcon/raitingIco.png b/src/img/blueMenuIcon/gradesIco.png similarity index 100% rename from src/img/blueMenuIcon/raitingIco.png rename to src/img/blueMenuIcon/gradesIco.png diff --git a/src/img/blueMenuIcon/groupIco.png b/src/img/blueMenuIcon/groupsIco.png similarity index 100% rename from src/img/blueMenuIcon/groupIco.png rename to src/img/blueMenuIcon/groupsIco.png diff --git a/src/img/blueMenuIcon/settingIco.png b/src/img/blueMenuIcon/settingsIco.png similarity index 100% rename from src/img/blueMenuIcon/settingIco.png rename to src/img/blueMenuIcon/settingsIco.png diff --git a/src/img/blueMenuIcon/subjectIco.png b/src/img/blueMenuIcon/subjectsIco.png similarity index 100% rename from src/img/blueMenuIcon/subjectIco.png rename to src/img/blueMenuIcon/subjectsIco.png diff --git a/src/img/reportsIcon/reportRaiting.png b/src/img/reportsIcon/reportGrades.png similarity index 100% rename from src/img/reportsIcon/reportRaiting.png rename to src/img/reportsIcon/reportGrades.png diff --git a/src/img/reportsIcon/reportGroup.png b/src/img/reportsIcon/reportGroups.png similarity index 100% rename from src/img/reportsIcon/reportGroup.png rename to src/img/reportsIcon/reportGroups.png diff --git a/src/img/reportsIcon/reportStudent.png b/src/img/reportsIcon/reportStudents.png similarity index 100% rename from src/img/reportsIcon/reportStudent.png rename to src/img/reportsIcon/reportStudents.png diff --git a/src/img/reportsIcon/reportItem.png b/src/img/reportsIcon/reportSubjects.png similarity index 100% rename from src/img/reportsIcon/reportItem.png rename to src/img/reportsIcon/reportSubjects.png diff --git a/src/img/whiteActionsIcon/raitingIco.png b/src/img/whiteActionsIcon/gradesIco.png similarity index 100% rename from src/img/whiteActionsIcon/raitingIco.png rename to src/img/whiteActionsIcon/gradesIco.png diff --git a/src/img/whiteActionsIcon/groupIco.png b/src/img/whiteActionsIcon/groupsIco.png similarity index 100% rename from src/img/whiteActionsIcon/groupIco.png rename to src/img/whiteActionsIcon/groupsIco.png diff --git a/src/img/whiteActionsIcon/reportRaiting.png b/src/img/whiteActionsIcon/reportGrades.png similarity index 100% rename from src/img/whiteActionsIcon/reportRaiting.png rename to src/img/whiteActionsIcon/reportGrades.png diff --git a/src/img/whiteActionsIcon/reportGroup.png b/src/img/whiteActionsIcon/reportGroups.png similarity index 100% rename from src/img/whiteActionsIcon/reportGroup.png rename to src/img/whiteActionsIcon/reportGroups.png diff --git a/src/img/whiteActionsIcon/reportStudent.png b/src/img/whiteActionsIcon/reportStudents.png similarity index 100% rename from src/img/whiteActionsIcon/reportStudent.png rename to src/img/whiteActionsIcon/reportStudents.png diff --git a/src/img/whiteActionsIcon/reportItem.png b/src/img/whiteActionsIcon/reportSubjects.png similarity index 100% rename from src/img/whiteActionsIcon/reportItem.png rename to src/img/whiteActionsIcon/reportSubjects.png diff --git a/src/img/whiteActionsIcon/subjectIco.png b/src/img/whiteActionsIcon/subjectsIco.png similarity index 100% rename from src/img/whiteActionsIcon/subjectIco.png rename to src/img/whiteActionsIcon/subjectsIco.png diff --git a/src/img/whiteMenuIcon/raitingIco.png b/src/img/whiteMenuIcon/gradesIco.png similarity index 100% rename from src/img/whiteMenuIcon/raitingIco.png rename to src/img/whiteMenuIcon/gradesIco.png diff --git a/src/img/whiteMenuIcon/groupIco.png b/src/img/whiteMenuIcon/groupsIco.png similarity index 100% rename from src/img/whiteMenuIcon/groupIco.png rename to src/img/whiteMenuIcon/groupsIco.png diff --git a/src/img/whiteMenuIcon/settingIco.png b/src/img/whiteMenuIcon/settingsIco.png similarity index 100% rename from src/img/whiteMenuIcon/settingIco.png rename to src/img/whiteMenuIcon/settingsIco.png diff --git a/src/img/whiteMenuIcon/subjectIco.png b/src/img/whiteMenuIcon/subjectsIco.png similarity index 100% rename from src/img/whiteMenuIcon/subjectIco.png rename to src/img/whiteMenuIcon/subjectsIco.png diff --git a/src/authorizationform.cpp b/src/loginwindow.cpp similarity index 57% rename from src/authorizationform.cpp rename to src/loginwindow.cpp index e4e5966..1370e6b 100644 --- a/src/authorizationform.cpp +++ b/src/loginwindow.cpp @@ -1,26 +1,40 @@ -#include "authorizationform.h" -#include "ui_authorizationform.h" +#include "loginwindow.h" +#include "ui_loginwindow.h" #include -#include #include -authorizationForm::authorizationForm(QWidget *parent) : - QWidget(parent), - ui(new Ui::authorizationForm) +LoginWindow::LoginWindow(QWidget *parent) + : QWidget(parent) + , ui(new Ui::LoginWindow) { ui->setupUi(this); - setWindowTitle("Авторизація"); + setWindowTitle("Вхід"); setFixedSize(width(), height()); setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); connect(ui->loginLineEdit, SIGNAL(QLineEdit::focusInEvent), this, SLOT(clearLineLogin(bool))); - connect(ui->loginLineEdit, &QLineEdit::returnPressed, this, &authorizationForm::startAuthozation); - connect(ui->loginLineEdit, &QLineEditWithButton::buttonClicked, this, &authorizationForm::loginClearButtonCliked); - - connect(ui->passwordLineEdit, SIGNAL(QLineEdit::focusInEvent), this, SLOT(clearLinePassword(bool))); - connect(ui->passwordLineEdit, &QLineEdit::returnPressed, this, &authorizationForm::startAuthozation); - connect(ui->passwordLineEdit, &QLineEditWithButton::buttonClicked, this, &authorizationForm::passwordVisibilityButtonClicked); + connect(ui->loginLineEdit, + &QLineEdit::returnPressed, + this, + &LoginWindow::startAuthozation); + connect(ui->loginLineEdit, + &QLineEditWithButton::buttonClicked, + this, + &LoginWindow::loginClearButtonCliked); + + connect(ui->passwordLineEdit, + SIGNAL(QLineEdit::focusInEvent), + this, + SLOT(clearLinePassword(bool))); + connect(ui->passwordLineEdit, + &QLineEdit::returnPressed, + this, + &LoginWindow::startAuthozation); + connect(ui->passwordLineEdit, + &QLineEditWithButton::buttonClicked, + this, + &LoginWindow::passwordVisibilityButtonClicked); show(); close(); @@ -31,94 +45,75 @@ authorizationForm::authorizationForm(QWidget *parent) : ui->passwordLineEdit->setPlaceholderText("Пароль"); } - -authorizationForm::~authorizationForm() +LoginWindow::~LoginWindow() { delete ui; } - -void authorizationForm::startAuthozation() +void LoginWindow::startAuthozation() { on_loginButton_clicked(); } - -void authorizationForm::on_forgotPasswordButton_clicked() +void LoginWindow::on_forgotPasswordButton_clicked() { - QMessageBox::information(this, "Увага", "У випадку якщо ви забулі пароль або логін зверніться по пошті:" - "\nsupport@gradify.online"); + QMessageBox::information(this, + "Увага", + "У випадку якщо ви забулі пароль або логін зверніться по пошті:" + "\nsupport@gradify.online"); } - -void authorizationForm::loginClearButtonCliked() +void LoginWindow::loginClearButtonCliked() { ui->loginLineEdit->clear(); } - -void authorizationForm::passwordVisibilityButtonClicked() +void LoginWindow::passwordVisibilityButtonClicked() { - if (not isPasswordHidden) - { + if (not isPasswordHidden) { isPasswordHidden = true; ui->passwordLineEdit->setEchoMode(QLineEdit::Normal); - if (styleType == "white") - { + if (styleType == "white") { ui->passwordLineEdit->setIconButton(QIcon(":/img/blackMenuIcon/noWatchPass.png")); - } - else - { + } else { ui->passwordLineEdit->setIconButton(QIcon(":/img/whiteMenuIcon/noWatchPass.png")); } - } - else - { + } else { isPasswordHidden = false; ui->passwordLineEdit->setEchoMode(QLineEdit::Password); - if (styleType == "white") - { + if (styleType == "white") { ui->passwordLineEdit->setIconButton(QIcon(":/img/blackMenuIcon/watchPass.png")); - } - else - { + } else { ui->passwordLineEdit->setIconButton(QIcon(":/img/whiteMenuIcon/watchPass.png")); } } } - -void authorizationForm::setTheme(const QString &style) +void LoginWindow::setTheme(const QString &style) { - if (style == "black") - { + if (style == "black") { styleType = "black"; setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { styleType = "white"; setWhiteUI(); - } - else - { + } else { setSystemUI(); } } - -void authorizationForm::on_loginButton_clicked() +void LoginWindow::on_loginButton_clicked() { - if (ui->loginLineEdit->text().isEmpty()) - { + // TEST!!! + QString login = ui->loginLineEdit->text(); + emit signalLogin(login); + close(); + /* + if (ui->loginLineEdit->text().isEmpty()) { ui->loginLineEdit->setFocus(); - } - else if (ui->passwordLineEdit->text().isEmpty()) - { + } else if (ui->passwordLineEdit->text().isEmpty()) { ui->passwordLineEdit->setFocus(); - } - else - { + } else { authorizationDB = QSqlDatabase::addDatabase("QMYSQL"); // https://gradify.online/ authorizationDB.setHostName("141.136.44.252"); @@ -126,8 +121,7 @@ void authorizationForm::on_loginButton_clicked() authorizationDB.setPassword("P433w0rD!"); authorizationDB.setDatabaseName("accounts_db"); - if (not authorizationDB.open()) - { + if (not authorizationDB.open()) { QMessageBox::information(this, "Увага", "Перевірте інтернет з'єднання"); return; } @@ -139,26 +133,27 @@ void authorizationForm::on_loginButton_clicked() QTableView *tableView = new QTableView(this); queryModel->setQuery("SELECT * " "FROM Акаунти " - "WHERE Логін = '" + login + "'" - " AND Пароль = '" + password + "'"); + "WHERE Логін = '" + + login + + "'" + " AND Пароль = '" + + password + "'"); tableView->setModel(queryModel); - if (tableView->model()->rowCount() > 0) - { + if (tableView->model()->rowCount() > 0) { ui->loginLineEdit->clear(); ui->passwordLineEdit->clear(); ui->loginLineEdit->setFocus(); ui->authorizationErrorLabel->setVisible(false); - if (ui->rememberCheckBox->isChecked()) - { - QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", QSettings::IniFormat); + if (ui->rememberCheckBox->isChecked()) { + QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", + QSettings::IniFormat); settingsConfig.setValue("userlogin", login); - } - else - { - QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", QSettings::IniFormat); + } else { + QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", + QSettings::IniFormat); settingsConfig.remove("userlogin"); } @@ -166,18 +161,16 @@ void authorizationForm::on_loginButton_clicked() QSqlDatabase::removeDatabase(authorizationDB.connectionName()); emit signalLogin(login); close(); - } - else - { + } else { ui->authorizationErrorLabel->setVisible(true); } } + */ } - -void authorizationForm::setBlackUI() +void LoginWindow::setBlackUI() { - QFile file(":/styles/black/authorizationForm/authorizationForm.qss"); + QFile file(":/styles/black/LoginWindow/LoginWindow.qss"); file.open(QFile::ReadOnly); setStyleSheet(QLatin1String(file.readAll())); file.close(); @@ -194,10 +187,9 @@ void authorizationForm::setBlackUI() ui->passwordLineEdit->setEchoMode(QLineEdit::Password); } - -void authorizationForm::setWhiteUI() +void LoginWindow::setWhiteUI() { - QFile file(":/styles/white/authorizationForm/authorizationForm.qss"); + QFile file(":/styles/white/LoginWindow/LoginWindow.qss"); file.open(QFile::ReadOnly); setStyleSheet(QLatin1String(file.readAll())); file.close(); @@ -210,27 +202,23 @@ void authorizationForm::setWhiteUI() ui->loginLineEdit->setIconSize(QSize(13, 13)); ui->passwordLineEdit->setIconButton(QIcon(":/img/blackMenuIcon/watchPass.png")); - ui->passwordLineEdit->setIconSize(QSize(16, 16) ); + ui->passwordLineEdit->setIconSize(QSize(16, 16)); ui->passwordLineEdit->setEchoMode(QLineEdit::Password); } - -void authorizationForm::setSystemUI() +void LoginWindow::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { styleType = "white"; setWhiteUI(); - } - else - { + } else { styleType = "black"; setBlackUI(); } } - - diff --git a/src/authorizationform.h b/src/loginwindow.h similarity index 64% rename from src/authorizationform.h rename to src/loginwindow.h index 42ccf38..42cdf6f 100644 --- a/src/authorizationform.h +++ b/src/loginwindow.h @@ -1,23 +1,22 @@ -#ifndef AUTHORIZATIONFORM_H -#define AUTHORIZATIONFORM_H +#ifndef LOGINWINDOW_H +#define LOGINWINDOW_H -#include -#include #include -#include "customWidgets/qlineeditwithbutton.h" #include +#include +#include "customWidgets/qlineeditwithbutton.h" namespace Ui { -class authorizationForm; +class LoginWindow; } -class authorizationForm : public QWidget +class LoginWindow : public QWidget { Q_OBJECT public: - explicit authorizationForm(QWidget *parent = nullptr); - ~authorizationForm(); + explicit LoginWindow(QWidget *parent = nullptr); + ~LoginWindow(); private slots: void setBlackUI(); @@ -35,9 +34,7 @@ private slots: void on_loginButton_clicked(); private: - Ui::authorizationForm *ui; - - QSqlDatabase authorizationDB; + Ui::LoginWindow *ui; bool isPasswordHidden; @@ -51,4 +48,4 @@ public slots: void signalLogin(const QString); }; -#endif // AUTHORIZATIONFORM_H +#endif // LOGINWINDOW_H diff --git a/src/authorizationform.ui b/src/loginwindow.ui similarity index 98% rename from src/authorizationform.ui rename to src/loginwindow.ui index 9f86f21..a65f38d 100644 --- a/src/authorizationform.ui +++ b/src/loginwindow.ui @@ -1,7 +1,7 @@ - authorizationForm - + LoginWindow + 0 diff --git a/src/main.cpp b/src/main.cpp index 26d5885..2241f82 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,6 +9,7 @@ #include "preloader.h" #include +#include int main(int argc, char *argv[]) { @@ -17,6 +18,7 @@ int main(int argc, char *argv[]) preloader window; window.show(); return app.exec(); + #else qDebug() << "This application is designed specifically for macOS and is optimized for its use. " "Please make sure you have it installed on your macOS computer for future use."; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3414853..d7e206f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2,49 +2,48 @@ #include "ui_mainwindow.h" #include +#include #include -#include #include -#include #include +#include +#include +#include +#include #include -#include -#include #include -#include +#include +#include +#include +#include #include - MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); - mainWindowInit(); + initMainWindow(); } - MainWindow::~MainWindow() { delete ui; } - -void MainWindow::mainWindowInit() +void MainWindow::initMainWindow() { - // example of translate - // idk why you paste 2 spaces bro - ui->settingsButton->setText(tr(" Налаштування")); - setWindowTitle("Gradify"); + dbHandler = new DatabaseHandler(this); + // init obj's of windows classes - settingWindow = new appSetting(); - authorizationWindow = new authorizationForm(); - filterWindow = new filterForm(this); - queryWindow = new queryForm(this); - aboutAppWindow = new aboutApp(); + appSettingsWindow = new AppSettingsWindow(); + loginWindow = new LoginWindow(); + filterWindow = new FilterWindow(this); + queryWindow = new QueryWindow(this); + aboutAppWindow = new AboutAppWindow(); gradeForm = new gradeWindow(); groupForm = new groupWindow(); @@ -63,21 +62,21 @@ void MainWindow::mainWindowInit() queryWindow->setGraphicsEffect(paintDropShadowEffect()); // default inactive state on main window - currentSelectTable = -1; + currentSelectTable = TableType::None; setEnabledButtons(false); setEnabledActions(false); setEnabledEditButton(false); // tableview settings - ui->tableView->horizontalHeader()->setStretchLastSection(true); - ui->tableView->verticalHeader()->setDefaultAlignment(Qt::AlignHCenter); + ui->tableWidget->horizontalHeader()->setStretchLastSection(true); + ui->tableWidget->verticalHeader()->setDefaultAlignment(Qt::AlignHCenter); ui->centralwidget->layout()->setContentsMargins(0, 0, 0, 0); // theme change after config init - connect(this, &MainWindow::setThemeSettingsUI, settingWindow, &appSetting::setTheme); - connect(this, &MainWindow::setThemeSettingsUI, authorizationWindow, &authorizationForm::setTheme); - connect(this, &MainWindow::setThemeSettingsUI, aboutAppWindow, &aboutApp::setTheme); + connect(this, &MainWindow::setThemeSettingsUI, appSettingsWindow, &AppSettingsWindow::setTheme); + connect(this, &MainWindow::setThemeSettingsUI, loginWindow, &LoginWindow::setTheme); + connect(this, &MainWindow::setThemeSettingsUI, aboutAppWindow, &AboutAppWindow::setTheme); connect(this, &MainWindow::setThemeSettingsUI, gradeForm, &gradeWindow::setTheme); connect(this, &MainWindow::setThemeSettingsUI, groupForm, &groupWindow::setTheme); @@ -92,65 +91,117 @@ void MainWindow::mainWindowInit() connect(this, &MainWindow::setThemeSettingsUI, teacherStat, &teacherStatistics::setTheme); // update statistics - connect(this, &MainWindow::updateStatisticsSignal, studentStat, &studentStatistics::updateGroupComboBox); - connect(this, &MainWindow::updateStatisticsComboBoxSignal, groupStat, &groupStatistics::setGroupComboBox); + connect(this, + &MainWindow::updateStatisticsSignal, + studentStat, + &studentStatistics::updateGroupComboBox); + connect(this, + &MainWindow::updateStatisticsComboBoxSignal, + groupStat, + &groupStatistics::setGroupComboBox); + // config initialization configInit(); // login/logout - connect(authorizationWindow, &authorizationForm::signalLogin, this, &MainWindow::authorization); - connect(settingWindow, &appSetting::logoutSignal, this, &MainWindow::userLogout); + connect(loginWindow, &LoginWindow::signalLogin, this, &MainWindow::authorization); + connect(appSettingsWindow, &AppSettingsWindow::logoutSignal, this, &MainWindow::logoutUser); // theme change in settings window - connect(settingWindow, &appSetting::changeThemeApp, this, &MainWindow::setTheme); - connect(settingWindow, &appSetting::changeThemeApp, authorizationWindow, &authorizationForm::setTheme); - connect(settingWindow, &appSetting::changeThemeApp, aboutAppWindow, &aboutApp::setTheme); - - connect(settingWindow, &appSetting::changeThemeApp, gradeForm, &gradeWindow::setTheme); - connect(settingWindow, &appSetting::changeThemeApp, groupForm, &groupWindow::setTheme); - connect(settingWindow, &appSetting::changeThemeApp, studentForm, &studentWindow::setTheme); - connect(settingWindow, &appSetting::changeThemeApp, subjectForm, &subjectWindow::setTheme); - connect(settingWindow, &appSetting::changeThemeApp, teacherForm, &teacherWindow::setTheme); - - connect(settingWindow, &appSetting::changeThemeApp, gradeStat, &gradeStatistics::setTheme); - connect(settingWindow, &appSetting::changeThemeApp, groupStat, &groupStatistics::setTheme); - connect(settingWindow, &appSetting::changeThemeApp, studentStat, &studentStatistics::setTheme); - connect(settingWindow, &appSetting::changeThemeApp, subjectStat, &subjectStatistics::setTheme); - connect(settingWindow, &appSetting::changeThemeApp, teacherStat, &teacherStatistics::setTheme); + connect(appSettingsWindow, &AppSettingsWindow::changeThemeApp, this, &MainWindow::setTheme); + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + loginWindow, + &LoginWindow::setTheme); + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + aboutAppWindow, + &AboutAppWindow::setTheme); + + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + gradeForm, + &gradeWindow::setTheme); + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + groupForm, + &groupWindow::setTheme); + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + studentForm, + &studentWindow::setTheme); + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + subjectForm, + &subjectWindow::setTheme); + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + teacherForm, + &teacherWindow::setTheme); + + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + gradeStat, + &gradeStatistics::setTheme); + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + groupStat, + &groupStatistics::setTheme); + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + studentStat, + &studentStatistics::setTheme); + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + subjectStat, + &subjectStatistics::setTheme); + connect(appSettingsWindow, + &AppSettingsWindow::changeThemeApp, + teacherStat, + &teacherStatistics::setTheme); // filters and requests - connect(filterWindow, &filterForm::sendFilter, this, &MainWindow::setFilterForTable); - connect(filterWindow, &filterForm::clearFilter, this, &MainWindow::clearFilterForTable); - connect(this, &MainWindow::setTableForFilter, filterWindow, &filterForm::setListTable); - connect(queryWindow, &queryForm::sendQuery, this, &MainWindow::setQueryForTable); - connect(queryWindow, &queryForm::sendFilter, this, &MainWindow::setFilterForTable); - connect(queryWindow, &queryForm::clearFilter, this, &MainWindow::clearFilterForTable); - connect(this, &MainWindow::changedGradeTable, queryWindow, &queryForm::selectedGradeTable); + connect(filterWindow, &FilterWindow::sendFilter, this, &MainWindow::setFilterForTable); + connect(filterWindow, &FilterWindow::clearFilter, this, &MainWindow::clearFilterForTable); + connect(this, &MainWindow::setTableForFilter, filterWindow, &FilterWindow::setListTable); + connect(queryWindow, &QueryWindow::sendQuery, this, &MainWindow::setQueryForTable); + connect(queryWindow, &QueryWindow::sendFilter, this, &MainWindow::setFilterForTable); + connect(queryWindow, &QueryWindow::clearFilter, this, &MainWindow::clearFilterForTable); + connect(this, &MainWindow::changedGradeTable, queryWindow, &QueryWindow::selectedGradeTable); // clear searchbar & filter - connect(ui->searchLineEdit, &QSearchBar::clickedClearButton, this, &MainWindow::clearFilterForTable); + connect(ui->searchLineEdit, + &QSearchBar::clickedClearButton, + this, + &MainWindow::clearFilterForTable); // close pop-up windows on click tableView (need fix empty space) - connect(ui->tableView->horizontalHeader(), &QHeaderView::sectionClicked, this, &MainWindow::closeAllPopUpWindow); - connect(ui->tableView->verticalHeader(), &QHeaderView::sectionClicked, this, &MainWindow::closeAllPopUpWindow); - connect(ui->tableView, &QAbstractItemView::clicked, this, &MainWindow::closeAllPopUpWindow); - connect(ui->tableView, &QTableView::clicked, this, &MainWindow::closeAllPopUpWindow); + connect(ui->tableWidget->horizontalHeader(), + &QHeaderView::sectionClicked, + this, + &MainWindow::closeAllPopUpWindow); + connect(ui->tableWidget->verticalHeader(), + &QHeaderView::sectionClicked, + this, + &MainWindow::closeAllPopUpWindow); + connect(ui->tableWidget, &QAbstractItemView::clicked, this, &MainWindow::closeAllPopUpWindow); + connect(ui->tableWidget, &QTableWidget::clicked, this, &MainWindow::closeAllPopUpWindow); // close pop-up windows on click any buttons - for (QPushButton* button : findChildren()) - { + for (QPushButton *button : findChildren()) { // Добавлять в условие название кнопок форм привязаных к главному окну if (button->objectName() not_eq "filterButton" and button->objectName() not_eq "queryButton" - and button->objectName() not_eq "filterPushButton" and button->objectName() not_eq "succesStudentPushButton" - and button->objectName() not_eq "avgScorePushButton" and button->objectName() not_eq "clearFilterPushButton" - and button->objectName() not_eq "mySQLPushButton" and button->objectName() not_eq "searchGradeStudentButton") - { // ето тебе нада + and button->objectName() not_eq "filterPushButton" + and button->objectName() not_eq "succesStudentPushButton" + and button->objectName() not_eq "avgScorePushButton" + and button->objectName() not_eq "clearFilterPushButton" + and button->objectName() not_eq "mySQLPushButton" + and button->objectName() not_eq "searchGradeStudentButton") { connect(button, &QPushButton::clicked, this, &MainWindow::closeAllPopUpWindow); } if (button->objectName() not_eq "editRowButton" and button->objectName() not_eq "settingsButton" - and button->objectName() not_eq "addRowButton") - { + and button->objectName() not_eq "addRowButton") { connect(button, &QPushButton::clicked, this, &MainWindow::closeAllEditForm); } } @@ -178,253 +229,308 @@ void MainWindow::mainWindowInit() logoutMessageBox.setDefaultButton(yesButton); logoutMessageBox.setWindowTitle("Разлогін"); logoutMessageBox.setText("Ви дійсно хочете вийти з аккаунта?"); -} + // on_foo_bar naming fix: + connect(ui->studentsTableButton, &QPushButton::clicked, this, &MainWindow::openStudentsTable); + connect(ui->teachersTableButton, &QPushButton::clicked, this, &MainWindow::openTeachersTable); + connect(ui->gradesTableButton, &QPushButton::clicked, this, &MainWindow::openGradesTable); + connect(ui->groupsTableButton, &QPushButton::clicked, this, &MainWindow::openGroupsTable); + connect(ui->subjectsTableButton, &QPushButton::clicked, this, &MainWindow::openSubjectsTable); + + connect(ui->addRowAction, &QAction::triggered, this, &MainWindow::addRowToTable); + connect(ui->addRowButton, &QPushButton::clicked, this, &MainWindow::addRowToTable); + + connect(ui->authorizationButton, &QPushButton::clicked, this, &MainWindow::handleLogin); + connect(ui->deleteRowAction, &QAction::triggered, this, &MainWindow::deleteRowFromTable); + connect(ui->deleteRowButton, &QPushButton::clicked, this, &MainWindow::deleteRowFromTable); + + connect(ui->settingsButton, &QPushButton::clicked, this, &MainWindow::openSettingsWindow); + + connect(ui->editRowButton, &QPushButton::clicked, this, &MainWindow::editRowInTable); + connect(ui->editRowAction, &QAction::triggered, this, &MainWindow::editRowInTable); + + connect(ui->openTeachTabAction, &QAction::triggered, this, &MainWindow::openTeachersTable); + connect(ui->openStudTabAction, &QAction::triggered, this, &MainWindow::openStudentsTable); + connect(ui->openSubjTabAction, &QAction::triggered, this, &MainWindow::openSubjectsTable); + connect(ui->openGradesTabAction, &QAction::triggered, this, &MainWindow::openGradesTable); + connect(ui->openGroupTabAction, &QAction::triggered, this, &MainWindow::openGroupsTable); + + connect(ui->currentTableReportAction, + &QAction::triggered, + this, + &MainWindow::generateCurrentTableReport); + connect(ui->currentTableReportButton, + &QPushButton::clicked, + this, + &MainWindow::generateCurrentTableReport); + connect(ui->studentsReportAction, + &QAction::triggered, + this, + &MainWindow::generateStudentsGroupReport); + connect(ui->studentsReportButton, + &QPushButton::clicked, + this, + &MainWindow::generateStudentsGroupReport); + connect(ui->teachersReportAction, + &QAction::triggered, + this, + &MainWindow::generateTeachersReport); + connect(ui->teachersReportButton, + &QPushButton::clicked, + this, + &MainWindow::generateTeachersReport); + connect(ui->gradesReportAction, &QAction::triggered, this, &MainWindow::generateGradesReport); + connect(ui->gradesReportButton, &QPushButton::clicked, this, &MainWindow::generateGradesReport); + connect(ui->groupsReportAction, &QAction::triggered, this, &MainWindow::generateGroupsReport); + connect(ui->groupsReportButton, &QPushButton::clicked, this, &MainWindow::generateGroupsReport); + connect(ui->subjectsReportAction, + &QAction::triggered, + this, + &MainWindow::generateSubjectsReport); + connect(ui->subjectsReportButton, + &QPushButton::clicked, + this, + &MainWindow::generateSubjectsReport); + + connect(ui->openManual, &QAction::triggered, this, &MainWindow::openManual); + connect(ui->about, &QAction::triggered, this, &MainWindow::openAboutWindow); + connect(ui->filterButton, &QPushButton::clicked, this, &MainWindow::toggleFilterWindow); + connect(ui->queryButton, &QPushButton::clicked, this, &MainWindow::toggleQueryWindow); + connect(ui->statisticsButton, &QPushButton::clicked, this, &MainWindow::openStatisticsWindow); + + connect(ui->actionCSV, &QAction::triggered, this, &MainWindow::exportDataToCSV); + connect(ui->actionTXT, &QAction::triggered, this, &MainWindow::exportDataToTXT); + + // TEST!!! + setEnabledButtons(true); + setEnabledActions(true); + setEnabledEditButton(true); +} void MainWindow::configDefault() { - QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", QSettings::IniFormat); + QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", + QSettings::IniFormat); + settingsConfig + .setValue("url", "https://gradifydatabase-default-rtdb.europe-west1.firebasedatabase.app/"); settingsConfig.setValue("theme", "system"); - settingsConfig.setValue("hostname", "141.136.44.252"); - settingsConfig.setValue("username", "teacher"); - settingsConfig.setValue("password", "P433w0rD!"); - settingsConfig.setValue("databasename", "Gradify"); } - void MainWindow::configInit() { - QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", QSettings::IniFormat); + QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", + QSettings::IniFormat); - if (settingsConfig.allKeys().empty()) - { + if (settingsConfig.allKeys().empty()) { configDefault(); } - if (settingsConfig.contains("theme")) - { + if (settingsConfig.contains("theme")) { setTheme(settingsConfig.value("theme").toString()); emit setThemeSettingsUI(theme); } - if (settingsConfig.contains("userlogin")) - { + if (settingsConfig.contains("userlogin")) { authorization(settingsConfig.value("userlogin").toString()); } } - void MainWindow::configWrite(const QString &key, const QVariant &value) { - QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", QSettings::IniFormat); + QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", + QSettings::IniFormat); settingsConfig.setValue(key, value); } - void MainWindow::changeEvent(QEvent *event) { QWidget::changeEvent(event); - if (event->type() == QEvent::ActivationChange) - { - if (isActiveWindow()) - { + if (event->type() == QEvent::ActivationChange) { + if (isActiveWindow()) { setWindowOpacity(1); - } - else - { + } else { setWindowOpacity(0.97); } - } - else if (event->type() == QEvent::LanguageChange) - { + } else if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } } - void MainWindow::closeEvent(QCloseEvent *event) { - if (event->Close) - { + if (event->Close) { QApplication::closeAllWindows(); } } - void MainWindow::mousePressEvent(QMouseEvent *event) { - if (event->button() == Qt::LeftButton and filterWindow->isVisible() and not filterWindow->underMouse()) - { + if (event->button() == Qt::LeftButton and filterWindow->isVisible() + and not filterWindow->underMouse()) { filterWindow->close(); - } - else if (event->button() == Qt::LeftButton and queryWindow->isVisible() and not queryWindow->underMouse()) - { + } else if (event->button() == Qt::LeftButton and queryWindow->isVisible() + and not queryWindow->underMouse()) { queryWindow->close(); } } - -void MainWindow::on_studentsTableButton_clicked() +void MainWindow::fillTable(const QStringList &columns, const QJsonArray &data) { - /* - * - * Код реализации открытия таблицы студентов - * - */ - setWindowTitle("Gradify - (Студенти)"); - model->setTable("Студенти"); - model->select(); - currentSelectTable = 0; - - ui->tableView->setModel(model); - ui->tableView->resizeColumnsToContents(); - ui->tableView->sortByColumn(0, Qt::AscendingOrder); - - clearStyleButtonTable(); - - setEnabledEditButton(true); + qsizetype rowCount = data.size(); + qsizetype columnCount = columns.size(); - ui->studentsTableButton->setStyleSheet(selectButtonTableStyle); - ui->searchLineEdit->clear(); - - ui->studentsTableButton->setIcon(QIcon(":/img/" + theme + "MenuIcon/studentsIco.png")); + ui->tableWidget->clear(); + ui->tableWidget->setRowCount(rowCount); + ui->tableWidget->setColumnCount(columnCount); + ui->tableWidget->setHorizontalHeaderLabels(columns); - emit setTableForFilter(getColumnsNamesAndDatatypes("Студенти")); - emit changedGradeTable(0); + for (qsizetype i = 0; i < rowCount; ++i) { + QJsonObject item = data[i].toObject(); + for (qsizetype j = 0; j < columnCount; ++j) { + QString columnName = columns[j]; + QTableWidgetItem *tableItem = new QTableWidgetItem(item.value(columnName).toString()); + ui->tableWidget->setItem(i, j, tableItem); + } + } } - -void MainWindow::on_teachersTableButton_clicked() +void MainWindow::openTable(TableType tableType, const QString &tableName) { - /* - * - * Код реализации открытия таблицы преподавателей - * - */ - setWindowTitle("Gradify - (Викладачі)"); - model->setTable("Викладачі"); - model->select(); - currentSelectTable = 1; - - ui->tableView->setModel(model); - ui->tableView->resizeColumnsToContents(); - ui->tableView->sortByColumn(0, Qt::AscendingOrder); - + setWindowTitle("Gradify - (" + tableName + ")"); + currentSelectTable = tableType; clearStyleButtonTable(); - setEnabledEditButton(true); - ui->teachersTableButton->setStyleSheet(selectButtonTableStyle); ui->searchLineEdit->clear(); - ui->teachersTableButton->setIcon(QIcon(":/img/" + theme + "MenuIcon/teachersIco.png")); + QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", + QSettings::IniFormat); - emit setTableForFilter(getColumnsNamesAndDatatypes("Викладачі")); - emit changedGradeTable(1); -} + if (settingsConfig.value("url").isNull()) { + qDebug() << "Gradify - " << tableName << " - URL IS NULL"; + return; + } + QStringList headers; -void MainWindow::on_gradesTableButton_clicked() -{ - setWindowTitle("Gradify - (Оцінки)"); - model->setTable("Оцінки"); - model->select(); - currentSelectTable = 2; - - ui->tableView->setModel(model); - ui->tableView->resizeColumnsToContents(); - ui->tableView->sortByColumn(0, Qt::AscendingOrder); + switch (tableType) { + case TableType::Teachers: + ui->teachersTableButton->setIcon(QIcon(":/img/" + theme + "MenuIcon/teachersIco.png")); + ui->teachersTableButton->setStyleSheet(selectButtonTableStyle); + headers = {"Прізвище", + "Ім'я", + "По батькові", + "Номер телефона", + "Дата народження", + "Адреса проживання", + "Категорія", + "Спеціалізація"}; + break; + case TableType::Subjects: + ui->subjectsTableButton->setIcon(QIcon(":/img/" + theme + "MenuIcon/subjectsIco.png")); + ui->subjectsTableButton->setStyleSheet(selectButtonTableStyle); + headers = {"Назва", + "Тип", + "Викладач", + "Всього годин", + "Кількість лекційних годин", + "Кількість лабораторних годин", + "Кількість семінарних годин", + "Кількість годин на самостійні роботи", + "Семестр в якому вивчається", + "Семестровий контроль"}; + break; + case TableType::Students: + ui->studentsTableButton->setIcon(QIcon(":/img/" + theme + "MenuIcon/studentsIco.png")); + ui->studentsTableButton->setStyleSheet(selectButtonTableStyle); + headers = {"Прізвище", + "Ім'я", + "По батькові", + "Дата народження", + "Адреса проживання", + "Номер телефона", + "Номер паспорту", + "Група", + "ІНН"}; + break; + case TableType::Grades: + ui->gradesTableButton->setIcon(QIcon(":/img/" + theme + "MenuIcon/gradesIco.png")); + ui->gradesTableButton->setStyleSheet(selectButtonTableStyle); + headers = {"Предмет", + "Отримувач", + "Оцінка", + "Тип оцінки", + "Дата отримання"}; + break; + case TableType::Groups: + ui->groupsTableButton->setIcon(QIcon(":/img/" + theme + "MenuIcon/groupsIco.png")); + ui->groupsTableButton->setStyleSheet(selectButtonTableStyle); + headers = {"Назва", + "Спеціальність", + "Рік початку навчання", + "Рік закінчення навчання", + "Куратор", + "Староста"}; + break; + case TableType::None: + break; + } - clearStyleButtonTable(); + QByteArray answer = dbHandler->getReply(settingsConfig.value("url").toString() + "/" + tableName + + ".json"); - setEnabledEditButton(true); + QJsonDocument doc = QJsonDocument::fromJson(answer); - ui->gradesTableButton->setStyleSheet(selectButtonTableStyle); - ui->searchLineEdit->clear(); + if (!doc.isNull() && doc.isArray()) { + fillTable(headers, doc.array()); + } - ui->gradesTableButton->setIcon(QIcon(":/img/" + theme + "MenuIcon/raitingIco.png")); + ui->tableWidget->resizeColumnsToContents(); + ui->tableWidget->horizontalHeader()->setStretchLastSection(true); - emit setTableForFilter(getColumnsNamesAndDatatypes("Оцінки")); - emit changedGradeTable(2); + //emit setTableForFilter(getColumnsNamesAndDatatypes(tableName)); + //emit changedGradeTable(tableType); } - -void MainWindow::on_groupsTableButton_clicked() +void MainWindow::openTeachersTable() { - /* - * - * Код реализации открытия таблицы групп - * - */ - setWindowTitle("Gradify - (Групи)"); - model->setTable("Групи"); - model->select(); - currentSelectTable = 3; - - ui->tableView->setModel(model); - ui->tableView->resizeColumnsToContents(); - ui->tableView->sortByColumn(0, Qt::AscendingOrder); - - clearStyleButtonTable(); - - setEnabledEditButton(true); - - ui->groupsTableButton->setStyleSheet(selectButtonTableStyle); - ui->searchLineEdit->clear(); - - ui->groupsTableButton->setIcon(QIcon(":/img/" + theme + "MenuIcon/groupIco.png")); - - emit setTableForFilter(getColumnsNamesAndDatatypes("Групи")); - emit changedGradeTable(3); + openTable(TableType::Teachers, "Викладачі"); } - -void MainWindow::on_subjectsTableButton_clicked() +void MainWindow::openSubjectsTable() { - /* - * - * Код реализации открытия таблицы предметы - * - */ - setWindowTitle("Gradify - (Предмети)"); - model->setTable("Предмети"); - model->select(); - currentSelectTable = 4; - - ui->tableView->setModel(model); - ui->tableView->resizeColumnsToContents(); - ui->tableView->sortByColumn(0, Qt::AscendingOrder); - - clearStyleButtonTable(); - - setEnabledEditButton(true); - - ui->subjectsTableButton->setStyleSheet(selectButtonTableStyle); - ui->searchLineEdit->clear(); + openTable(TableType::Subjects, "Предмети"); +} - ui->subjectsTableButton->setIcon(QIcon(":/img/" + theme + "MenuIcon/subjectIco.png")); +void MainWindow::openStudentsTable() +{ + openTable(TableType::Students, "Студенти"); +} - emit setTableForFilter(getColumnsNamesAndDatatypes("Предмети")); - emit changedGradeTable(4); +void MainWindow::openGradesTable() +{ + openTable(TableType::Grades, "Оцінки"); } +void MainWindow::openGroupsTable() +{ + openTable(TableType::Groups, "Групи"); +} void MainWindow::clearSelectTable() { - ui->tableView->setModel(NULL); - currentSelectTable = -1; + ui->tableWidget->clear(); + currentSelectTable = TableType::None; closeAllPopUpWindow(); } - void MainWindow::closeAllPopUpWindow() { filterWindow->close(); queryWindow->close(); } - void MainWindow::closeAllEditForm() { gradeForm->close(); @@ -434,7 +540,6 @@ void MainWindow::closeAllEditForm() teacherForm->close(); } - void MainWindow::closeAllStatisticsForm() { gradeStat->close(); @@ -444,7 +549,6 @@ void MainWindow::closeAllStatisticsForm() teacherStat->close(); } - void MainWindow::setEnabledButtons(const bool &status) { ui->subjectsReportButton->setEnabled(status); @@ -461,7 +565,6 @@ void MainWindow::setEnabledButtons(const bool &status) ui->groupsTableButton->setEnabled(status); } - void MainWindow::setEnabledActions(const bool &status) { ui->openGradesTabAction->setEnabled(status); @@ -480,7 +583,6 @@ void MainWindow::setEnabledActions(const bool &status) ui->menu_2->setEnabled(status); } - void MainWindow::setEnabledEditButton(const bool &status) { ui->addRowAction->setEnabled(status); @@ -496,7 +598,6 @@ void MainWindow::setEnabledEditButton(const bool &status) ui->statisticsButton->setEnabled(status); } - void MainWindow::clearStyleButtonTable() { ui->studentsTableButton->setStyleSheet(""); @@ -507,26 +608,20 @@ void MainWindow::clearStyleButtonTable() ui->studentsTableButton->setIcon(QIcon(":/img/blueMenuIcon/studentsIco.png")); ui->teachersTableButton->setIcon(QIcon(":/img/blueMenuIcon/teachersIco.png")); - ui->gradesTableButton->setIcon(QIcon(":/img/blueMenuIcon/raitingIco.png")); - ui->groupsTableButton->setIcon(QIcon(":/img/blueMenuIcon/groupIco.png")); - ui->subjectsTableButton->setIcon(QIcon(":/img/blueMenuIcon/subjectIco.png")); + ui->gradesTableButton->setIcon(QIcon(":/img/blueMenuIcon/gradesIco.png")); + ui->groupsTableButton->setIcon(QIcon(":/img/blueMenuIcon/groupsIco.png")); + ui->subjectsTableButton->setIcon(QIcon(":/img/blueMenuIcon/subjectsIco.png")); } - void MainWindow::setTheme(const QString &style) { - if (style == "black") - { + if (style == "black") { theme = "black"; setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { theme = "white"; setWhiteUI(); - } - else - { + } else { theme = "system"; setSystemUI(); } @@ -534,12 +629,13 @@ void MainWindow::setTheme(const QString &style) configWrite("theme", theme); } - void MainWindow::authorization(const QString &login) { - QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", QSettings::IniFormat); - + // QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", + // QSettings::IniFormat); + // TEST!!! + /* db = QSqlDatabase::addDatabase("QMYSQL"); // https://gradify.online/ db.setHostName(settingsConfig.value("hostname").toString()); @@ -547,20 +643,22 @@ void MainWindow::authorization(const QString &login) db.setPassword(settingsConfig.value("password").toString()); db.setDatabaseName(settingsConfig.value("databasename").toString()); - if (not db.open()) - { - QMessageBox::critical(this, "Помилка з'єднання", "Перевірте статус серверу або параметри серверу в налаштуваннях!"); + if (not db.open()) { + QMessageBox::critical(this, + "Помилка з'єднання", + "Перевірте статус серверу або параметри серверу в налаштуваннях!"); return; } query = new QSqlQuery(db); model = new QSqlTableModel(this, db); queryModel = new QSqlQueryModel(this); + */ setEnabledButtons(true); setEnabledActions(true); - clearSelectTable(); + // clearSelectTable(); ui->authorizationButton->setText(" Привіт, " + login + "!"); ui->authorizationButton->setStyleSheet(selectButtonAuthStyle); @@ -568,17 +666,15 @@ void MainWindow::authorization(const QString &login) isLogin = true; } - void MainWindow::setFilterForTable(const QString &filterQuery, const QString ¤tColumnFilter) { model->setFilter(filterQuery); - ui->tableView->setModel(model); + //ui->tableWidget->setModel(model); - for(int i = 0; i < ui->tableView->model()->columnCount(); ++i) - { - if (ui->tableView->model()->headerData(i, Qt::Horizontal).toString() == currentColumnFilter) - { - ui->tableView->selectColumn(i); + for (int i = 0; i < ui->tableWidget->model()->columnCount(); ++i) { + if (ui->tableWidget->model()->headerData(i, Qt::Horizontal).toString() + == currentColumnFilter) { + ui->tableWidget->selectColumn(i); break; } } @@ -587,18 +683,16 @@ void MainWindow::setFilterForTable(const QString &filterQuery, const QString &cu //QMessageBox::information(this, "", filterQuery); } - -void MainWindow::on_settingsButton_clicked() +void MainWindow::openSettingsWindow() { - settingWindow->show(); + appSettingsWindow->show(); - if (settingWindow->isVisible()) - { - settingWindow->raise(); + if (appSettingsWindow->isVisible()) { + appSettingsWindow->raise(); } } -void MainWindow::userLogout() +void MainWindow::logoutUser() { isLogin = false; setEnabledButtons(false); @@ -610,35 +704,36 @@ void MainWindow::userLogout() ui->searchLineEdit->clear(); setWindowTitle("Gradify"); - ui->authorizationButton->setText("Авторизація"); + ui->authorizationButton->setText("Вхід"); ui->authorizationButton->setStyleSheet(""); - QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", QSettings::IniFormat); + QSettings settingsConfig(QCoreApplication::applicationDirPath() + "/gradify.conf", + QSettings::IniFormat); settingsConfig.remove("userlogin"); } -void MainWindow::on_authorizationButton_clicked() +void MainWindow::handleLogin() { - if (not isLogin) - { - authorizationWindow->show(); - } - else - { + qDebug() << QString("handleLogin()"); + // return; + + if (not isLogin) { + loginWindow->show(); + } else { logoutMessageBox.exec(); - if (logoutMessageBox.clickedButton() == yesButton) - { - userLogout(); + if (logoutMessageBox.clickedButton() == yesButton) { + logoutUser(); } } } - -void MainWindow::on_addRowButton_clicked() +void MainWindow::addRowToTable() { - switch (currentSelectTable) - { - case 0: + qDebug() << QString("addRowToTable()"); + return; + + switch (currentSelectTable) { + case TableType::Students: connect(this, &MainWindow::createNewRow, studentForm, &studentWindow::newRow); emit sendGroupsList(getGroupsNames()); @@ -647,7 +742,7 @@ void MainWindow::on_addRowButton_clicked() disconnect(this, &MainWindow::createNewRow, studentForm, &studentWindow::newRow); studentForm->show(); break; - case 1: + case TableType::Teachers: connect(this, &MainWindow::createNewRow, teacherForm, &teacherWindow::newRow); emit createNewRow(); @@ -655,168 +750,242 @@ void MainWindow::on_addRowButton_clicked() disconnect(this, &MainWindow::createNewRow, teacherForm, &teacherWindow::newRow); teacherForm->show(); break; - case 2: + case TableType::Grades: connect(this, &MainWindow::createNewRow, gradeForm, &gradeWindow::newRow); - connect(this, &MainWindow::sendStudentsList, gradeForm, &gradeWindow::setDataStudentComboBox); - connect(this, &MainWindow::sendSubjectsList, gradeForm, &gradeWindow::setDataSubjectComboBox); + connect(this, + &MainWindow::sendStudentsList, + gradeForm, + &gradeWindow::setDataStudentComboBox); + connect(this, + &MainWindow::sendSubjectsList, + gradeForm, + &gradeWindow::setDataSubjectComboBox); emit sendSubjectsList(getSubjectsNames()); emit sendStudentsList(getStudentsNames()); emit sendTeachersList(getTeachersNames()); emit createNewRow(); - disconnect(this, &MainWindow::sendSubjectsList, gradeForm, &gradeWindow::setDataSubjectComboBox); - disconnect(this, &MainWindow::sendStudentsList, gradeForm, &gradeWindow::setDataStudentComboBox); + disconnect(this, + &MainWindow::sendSubjectsList, + gradeForm, + &gradeWindow::setDataSubjectComboBox); + disconnect(this, + &MainWindow::sendStudentsList, + gradeForm, + &gradeWindow::setDataStudentComboBox); disconnect(this, &MainWindow::createNewRow, gradeForm, &gradeWindow::newRow); gradeForm->show(); break; - case 3: + case TableType::Groups: connect(this, &MainWindow::createNewRow, groupForm, &groupWindow::newRow); - connect(this, &MainWindow::sendTeachersList, groupForm, &groupWindow::setDataCuratorComboBox); - connect(this, &MainWindow::sendCurrentGroup, groupForm, &groupWindow::setDataHeadManComboBox); + connect(this, + &MainWindow::sendTeachersList, + groupForm, + &groupWindow::setDataCuratorComboBox); + connect(this, + &MainWindow::sendCurrentGroup, + groupForm, + &groupWindow::setDataHeadManComboBox); emit createNewRow(); emit sendTeachersList(getTeachersNames()); emit sendCurrentGroup("NULL"); - disconnect(this, &MainWindow::sendTeachersList, groupForm, &groupWindow::setDataCuratorComboBox); - disconnect(this, &MainWindow::sendCurrentGroup, groupForm, &groupWindow::setDataHeadManComboBox); + disconnect(this, + &MainWindow::sendTeachersList, + groupForm, + &groupWindow::setDataCuratorComboBox); + disconnect(this, + &MainWindow::sendCurrentGroup, + groupForm, + &groupWindow::setDataHeadManComboBox); disconnect(this, &MainWindow::createNewRow, groupForm, &groupWindow::newRow); groupForm->show(); break; - case 4: + case TableType::Subjects: connect(this, &MainWindow::createNewRow, subjectForm, &subjectWindow::newRow); - connect(this, &MainWindow::sendTeachersList, subjectForm, &subjectWindow::setTeacherComboBox); + connect(this, + &MainWindow::sendTeachersList, + subjectForm, + &subjectWindow::setTeacherComboBox); emit sendTeachersList(getTeachersNames()); emit createNewRow(); - disconnect(this, &MainWindow::sendTeachersList, subjectForm, &subjectWindow::setTeacherComboBox); + disconnect(this, + &MainWindow::sendTeachersList, + subjectForm, + &subjectWindow::setTeacherComboBox); disconnect(this, &MainWindow::createNewRow, subjectForm, &subjectWindow::newRow); subjectForm->show(); break; + case TableType::None: + QMessageBox::information(this, "Попередження", "Оберіть таблицю!"); + break; } } - -void MainWindow::on_deleteRowButton_clicked() +void MainWindow::deleteRowFromTable() { + qDebug() << QString("deleteRowFromTable()"); + return; + ui->searchLineEdit->clearFocus(); closeAllPopUpWindow(); - if (ui->tableView->model()->rowCount() > 0) - { + if (ui->tableWidget->model()->rowCount() > 0) { bool ok; - QString selectedItem = QInputDialog::getItem(this, tr("Видалення запису"), - tr("Оберіть запис для видалення:"), getCurrentItemTable(), - ui->tableView->currentIndex().row(), false, &ok); - - - if (ok) - { + QString selectedItem = QInputDialog::getItem(this, + tr("Видалення запису"), + tr("Оберіть запис для видалення:"), + getCurrentItemTable(), + ui->tableWidget->currentIndex().row(), + false, + &ok); + + if (ok) { model->removeRow(selectedItem.left(selectedItem.indexOf('.')).toInt() - 1); model->select(); } - } - else - { + } else { QMessageBox::critical(this, "", "Не знайдено записів для видалення!"); } } - -void MainWindow::on_editRowButton_clicked() +void MainWindow::editRowInTable() { + qDebug() << QString("editRowInTable()"); + return; + ui->searchLineEdit->clearFocus(); closeAllPopUpWindow(); - if (ui->tableView->model()->rowCount() > 0) - { + if (ui->tableWidget->model()->rowCount() > 0) { bool ok; - QString selectedItem = QInputDialog::getItem(this, tr("Редагування запису"), - tr("Оберіть запис для редагування:"), getCurrentItemTable(), - ui->tableView->currentIndex().row(), false, &ok); - - if (ok) - { - switch (currentSelectTable) - { - case 0: + QString selectedItem = QInputDialog::getItem(this, + tr("Редагування запису"), + tr("Оберіть запис для редагування:"), + getCurrentItemTable(), + ui->tableWidget->currentIndex().row(), + false, + &ok); + + if (ok) { + switch (currentSelectTable) { + case TableType::Students: connect(this, &MainWindow::setDataEditForm, studentForm, &studentWindow::setData); emit sendGroupsList(getGroupsNames()); - emit setDataEditForm(selectedItem, getRowData(selectedItem.QString::left(selectedItem.indexOf('.')).toInt())); + emit setDataEditForm(selectedItem, + getRowData( + selectedItem.QString::left(selectedItem.indexOf('.')) + .toInt())); disconnect(this, &MainWindow::setDataEditForm, studentForm, &studentWindow::setData); studentForm->show(); break; - case 1: + case TableType::Teachers: connect(this, &MainWindow::setDataEditForm, teacherForm, &teacherWindow::setData); - emit setDataEditForm(selectedItem, getRowData(selectedItem.left(selectedItem.indexOf('.')).toInt())); + emit setDataEditForm(selectedItem, + getRowData( + selectedItem.left(selectedItem.indexOf('.')).toInt())); disconnect(this, &MainWindow::setDataEditForm, teacherForm, &teacherWindow::setData); teacherForm->show(); break; - case 2: + case TableType::Grades: connect(this, &MainWindow::setDataEditForm, gradeForm, &gradeWindow::setData); - connect(this, &MainWindow::sendStudentsList, gradeForm, &gradeWindow::setDataStudentComboBox); - connect(this, &MainWindow::sendSubjectsList, gradeForm, &gradeWindow::setDataSubjectComboBox); + connect(this, + &MainWindow::sendStudentsList, + gradeForm, + &gradeWindow::setDataStudentComboBox); + connect(this, + &MainWindow::sendSubjectsList, + gradeForm, + &gradeWindow::setDataSubjectComboBox); emit sendSubjectsList(getSubjectsNames()); emit sendStudentsList(getStudentsNames()); - emit setDataEditForm(selectedItem, getRowData(selectedItem.left(selectedItem.indexOf('.')).toInt())); - - disconnect(this, &MainWindow::sendSubjectsList, gradeForm, &gradeWindow::setDataSubjectComboBox); - disconnect(this, &MainWindow::sendStudentsList, gradeForm, &gradeWindow::setDataStudentComboBox); + emit setDataEditForm(selectedItem, + getRowData( + selectedItem.left(selectedItem.indexOf('.')).toInt())); + + disconnect(this, + &MainWindow::sendSubjectsList, + gradeForm, + &gradeWindow::setDataSubjectComboBox); + disconnect(this, + &MainWindow::sendStudentsList, + gradeForm, + &gradeWindow::setDataStudentComboBox); disconnect(this, &MainWindow::setDataEditForm, gradeForm, &gradeWindow::setData); gradeForm->show(); break; - case 3: + case TableType::Groups: connect(this, &MainWindow::setDataEditForm, groupForm, &groupWindow::setData); - connect(this, &MainWindow::sendTeachersList, groupForm, &groupWindow::setDataCuratorComboBox); - connect(this, &MainWindow::sendCurrentGroup, groupForm, &groupWindow::setDataHeadManComboBox); + connect(this, + &MainWindow::sendTeachersList, + groupForm, + &groupWindow::setDataCuratorComboBox); + connect(this, + &MainWindow::sendCurrentGroup, + groupForm, + &groupWindow::setDataHeadManComboBox); emit sendTeachersList(getTeachersNames()); emit sendCurrentGroup(selectedItem); - emit setDataEditForm(selectedItem, getRowData(selectedItem.left(selectedItem.indexOf('.')).toInt())); + emit setDataEditForm(selectedItem, + getRowData( + selectedItem.left(selectedItem.indexOf('.')).toInt())); disconnect(this, &MainWindow::setDataEditForm, groupForm, &groupWindow::setData); - disconnect(this, &MainWindow::sendTeachersList, groupForm, &groupWindow::setDataCuratorComboBox); - disconnect(this, &MainWindow::sendCurrentGroup, groupForm, &groupWindow::setDataHeadManComboBox); + disconnect(this, + &MainWindow::sendTeachersList, + groupForm, + &groupWindow::setDataCuratorComboBox); + disconnect(this, + &MainWindow::sendCurrentGroup, + groupForm, + &groupWindow::setDataHeadManComboBox); groupForm->show(); break; - case 4: + case TableType::Subjects: connect(this, &MainWindow::setDataEditForm, subjectForm, &subjectWindow::setData); - connect(this, &MainWindow::sendTeachersList, subjectForm, &subjectWindow::setTeacherComboBox); + connect(this, + &MainWindow::sendTeachersList, + subjectForm, + &subjectWindow::setTeacherComboBox); emit sendTeachersList(getTeachersNames()); - emit setDataEditForm(selectedItem, getRowData(selectedItem.left(selectedItem.indexOf('.')).toInt())); - - disconnect(this, &MainWindow::sendTeachersList, subjectForm, &subjectWindow::setTeacherComboBox); + emit setDataEditForm(selectedItem, + getRowData( + selectedItem.left(selectedItem.indexOf('.')).toInt())); + + disconnect(this, + &MainWindow::sendTeachersList, + subjectForm, + &subjectWindow::setTeacherComboBox); disconnect(this, &MainWindow::setDataEditForm, subjectForm, &subjectWindow::setData); subjectForm->show(); break; + case TableType::None: + break; } } - } - else - { + } else { QMessageBox::critical(this, "", "Не знайдено записів для редагування!"); } } - -void MainWindow::on_filterButton_clicked() +void MainWindow::toggleFilterWindow() { ui->searchLineEdit->clearFocus(); - if (filterWindow->isVisible()) - { + if (filterWindow->isVisible()) { filterWindow->close(); - } - else - { + } else { queryWindow->close(); filterWindow->move(ui->filterButton->x() * 2, @@ -825,17 +994,13 @@ void MainWindow::on_filterButton_clicked() } } - -void MainWindow::on_queryButton_clicked() +void MainWindow::toggleQueryWindow() { ui->searchLineEdit->clearFocus(); - if (queryWindow->isVisible()) - { + if (queryWindow->isVisible()) { queryWindow->close(); - } - else - { + } else { filterWindow->close(); queryWindow->move(ui->queryButton->x() * 1.864, @@ -844,7 +1009,6 @@ void MainWindow::on_queryButton_clicked() } } - void MainWindow::printDocumentToPDF(const QString path, const QString html) { QTextDocument *document = new QTextDocument(); @@ -865,15 +1029,13 @@ void MainWindow::printDocumentToPDF(const QString path, const QString html) QDesktopServices::openUrl(QUrl("file://" + path, QUrl::TolerantMode)); } - void MainWindow::printDocumentToHTML(const QString path, const QString html) { QFile outputFile(path); outputFile.open(QIODevice::WriteOnly); - if(not outputFile.isOpen()) - { - QMessageBox::critical(this,"","Не вдалося зберегти звіт"); + if (not outputFile.isOpen()) { + QMessageBox::critical(this, "", "Не вдалося зберегти звіт"); return; } @@ -885,7 +1047,6 @@ void MainWindow::printDocumentToHTML(const QString path, const QString html) QDesktopServices::openUrl(QUrl("file://" + path, QUrl::TolerantMode)); } - QString MainWindow::getHeaderHTML() { QString htmlHeader; @@ -917,101 +1078,87 @@ QString MainWindow::getHeaderHTML() return htmlHeader; } - void MainWindow::goSearch() { - if (not ui->searchLineEdit->text().isEmpty()) - { + if (not ui->searchLineEdit->text().isEmpty()) { QString searchString; - for (int i = 0; i < ui->tableView->model()->columnCount(); ++i) - { - searchString += "`" + ui->tableView->model()->headerData(i, Qt::Horizontal).toString() + "` LIKE" + - "'%" + ui->searchLineEdit->text() + "%'"; + for (int i = 0; i < ui->tableWidget->model()->columnCount(); ++i) { + searchString += "`" + ui->tableWidget->model()->headerData(i, Qt::Horizontal).toString() + + "` LIKE" + "'%" + ui->searchLineEdit->text() + "%'"; - if (i not_eq ui->tableView->model()->columnCount() - 1) - { + if (i not_eq ui->tableWidget->model()->columnCount() - 1) { searchString += " OR "; } } model->setFilter(searchString); - ui->tableView->setModel(model); - } - else - { + //ui->tableWidget->setModel(model); + } else { clearFilterForTable(); } } - void MainWindow::setDataToModel(QStringList dataList, bool isNewRow) { - if (isNewRow) - { + if (isNewRow) { QString newRow = "INSERT INTO "; QSqlQueryModel *queryModel = new QSqlQueryModel(this); - QTableView *tableView = new QTableView(this); + QTableWidget *tableWidget = new QTableWidget(this); - switch (currentSelectTable) - { - case 0: + switch (currentSelectTable) { + case TableType::Students: newRow += "`Студенти`"; queryModel->setQuery("SELECT MAX(`Код`) " "FROM Студенти"); break; - case 1: + case TableType::Teachers: newRow += "`Викладачі` "; queryModel->setQuery("SELECT MAX(`Код`) " "FROM Викладачі"); break; - case 2: + case TableType::Grades: newRow += "`Оцінки` "; queryModel->setQuery("SELECT MAX(`Код`) " "FROM Оцінки"); break; - case 3: + case TableType::Groups: newRow += "`Групи` "; queryModel->setQuery("SELECT MAX(`Код`) " "FROM Групи"); break; - case 4: + case TableType::Subjects: newRow += "`Предмети` "; queryModel->setQuery("SELECT MAX(`Код`) " "FROM Предмети"); break; + case TableType::None: + break; } - tableView->setModel(queryModel); + //tableWidget->setModel(queryModel); newRow += "("; - for (int i = 0; i < model->columnCount(); ++i) - { + for (int i = 0; i < model->columnCount(); ++i) { newRow += "`" + model->headerData(i, Qt::Horizontal).toString(); - if (i not_eq model->columnCount() - 1) - { + if (i not_eq model->columnCount() - 1) { newRow += "`, "; - } - else - { + } else { newRow += "`)"; } } - newRow += "\nVALUES ('" + QString::number(tableView->model()->index(0, 0).data().toInt() + 1) + "',"; + newRow += "\nVALUES ('" + + QString::number(tableWidget->model()->index(0, 0).data().toInt() + 1) + "',"; - for (int i = 1; i < model->columnCount(); ++i) - { + for (int i = 1; i < model->columnCount(); ++i) { newRow += "'" + dataList[i]; - if (i not_eq model->columnCount() - 1) - { + if (i not_eq model->columnCount() - 1) { newRow += "', "; - } - else - { + } else { newRow += "')"; } } @@ -1019,41 +1166,37 @@ void MainWindow::setDataToModel(QStringList dataList, bool isNewRow) QSqlQueryModel *sqlModel = new QSqlQueryModel(); sqlModel->setQuery(newRow); model->select(); - } - else - { + } else { QString queryEdit = "UPDATE "; - switch (currentSelectTable) - { - case 0: + switch (currentSelectTable) { + case TableType::Students: queryEdit += "`Студенти`"; break; - case 1: + case TableType::Teachers: queryEdit += "`Викладачі` "; break; - case 2: + case TableType::Grades: queryEdit += "`Оцінки`"; break; - case 3: + case TableType::Groups: queryEdit += "`Групи`"; break; - case 4: + case TableType::Subjects: queryEdit += "`Предмети`"; break; + case None: + break; } queryEdit += " \nSET"; - for (int i = 1; i < model->columnCount(); ++i) - { - queryEdit += "`" + model->headerData(i, Qt::Horizontal).toString() + "` = '" + dataList[i]; + for (int i = 1; i < model->columnCount(); ++i) { + queryEdit += "`" + model->headerData(i, Qt::Horizontal).toString() + "` = '" + + dataList[i]; - if (i not_eq model->columnCount() - 1) - { + if (i not_eq model->columnCount() - 1) { queryEdit += "', \n"; - } - else - { + } else { queryEdit += "'"; } } @@ -1066,31 +1209,25 @@ void MainWindow::setDataToModel(QStringList dataList, bool isNewRow) } } - void MainWindow::setQueryForTable(QString query) { - if (query == "NULL") - { - ui->tableView->setModel(model); - ui->tableView->resizeColumnsToContents(); - ui->tableView->sortByColumn(0, Qt::AscendingOrder); - } - else - { + if (query == "NULL") { + //ui->tableWidget->setModel(model); + ui->tableWidget->resizeColumnsToContents(); + ui->tableWidget->sortByColumn(0, Qt::AscendingOrder); + } else { queryModel->setQuery(query); - ui->tableView->setModel(queryModel); + //ui->tableWidget->setModel(queryModel); } } - void MainWindow::clearFilterForTable() { model->setFilter(""); model->select(); - ui->tableView->setModel(model); + //ui->tableWidget->setModel(model); } - QGraphicsDropShadowEffect *MainWindow::paintDropShadowEffect() { QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this); @@ -1100,88 +1237,81 @@ QGraphicsDropShadowEffect *MainWindow::paintDropShadowEffect() return effect; } - QMap MainWindow::getColumnsNamesAndDatatypes(const QString &tableName) { - QMap headerListMap; + QMap headerListMap; - if (not tableName.isEmpty()) - { + if (not tableName.isEmpty()) { QSqlQueryModel *queryModel = new QSqlQueryModel(this); - QTableView *tableView = new QTableView(this); + QTableWidget *tableWidget = new QTableWidget(this); queryModel->setQuery("SELECT COLUMN_NAME, DATA_TYPE " "FROM INFORMATION_SCHEMA.COLUMNS " "WHERE table_schema = 'Gradify' " - "AND table_name = '" + tableName + "'" - "AND NOT column_name = 'Код'"); + "AND table_name = '" + + tableName + + "'" + "AND NOT column_name = 'Код'"); - tableView->setModel(queryModel); + //tableWidget->setModel(queryModel); - for (int row = 0; row < queryModel->rowCount(); ++row) - { - headerListMap.insert(tableView->model()->index(row, 0).data().toString(), - tableView->model()->index(row, 1).data().toString()); + for (int row = 0; row < queryModel->rowCount(); ++row) { + headerListMap.insert(tableWidget->model()->index(row, 0).data().toString(), + tableWidget->model()->index(row, 1).data().toString()); } } return headerListMap; } - QStringList MainWindow::getCurrentItemTable() { QStringList str; - switch (currentSelectTable) - { - case 0: - case 1: - for (int i = 0; i < ui->tableView->model()->rowCount(); ++i) - { - str << QString::number(i + 1) + ". " - + ui->tableView->model()->data(model->index(i, 1)).toString() + " " - + ui->tableView->model()->data(model->index(i, 2)).toString() + " " - + ui->tableView->model()->data(model->index(i, 3)).toString(); + switch (currentSelectTable) { + case TableType::Students: + case TableType::Teachers: + for (int i = 0; i < ui->tableWidget->model()->rowCount(); ++i) { + str << QString::number(i + 1) + ". " + + ui->tableWidget->model()->data(model->index(i, 1)).toString() + " " + + ui->tableWidget->model()->data(model->index(i, 2)).toString() + " " + + ui->tableWidget->model()->data(model->index(i, 3)).toString(); } break; - case 2: - for (int i = 0; i < ui->tableView->model()->rowCount(); ++i) - { - str << QString::number(i + 1) + ". " - + ui->tableView->model()->data(model->index(i, 2)).toString() + " - " - + ui->tableView->model()->data(model->index(i, 1)).toString() + ", " - + ui->tableView->model()->data(model->index(i, 4)).toString() + " (" - + ui->tableView->model()->data(model->index(i, 3)).toString() + ")"; + case TableType::Grades: + for (int i = 0; i < ui->tableWidget->model()->rowCount(); ++i) { + str << QString::number(i + 1) + ". " + + ui->tableWidget->model()->data(model->index(i, 2)).toString() + " - " + + ui->tableWidget->model()->data(model->index(i, 1)).toString() + ", " + + ui->tableWidget->model()->data(model->index(i, 4)).toString() + " (" + + ui->tableWidget->model()->data(model->index(i, 3)).toString() + ")"; } break; - case 3: - case 4: - for (int i = 0; i < ui->tableView->model()->rowCount(); ++i) - { - str << QString::number(i + 1) + ". " - + ui->tableView->model()->data(model->index(i, 1)).toString(); + case TableType::Groups: + case TableType::Subjects: + for (int i = 0; i < ui->tableWidget->model()->rowCount(); ++i) { + str << QString::number(i + 1) + ". " + + ui->tableWidget->model()->data(model->index(i, 1)).toString(); } break; + case None: + break; } return str; } - QStringList MainWindow::getRowData(const int &row) { QStringList listData; - for (int j = 0; j < model->columnCount(); ++j) - { + for (int j = 0; j < model->columnCount(); ++j) { listData << model->data(model->index(row - 1, j)).toString(); } return listData; } - QStringList MainWindow::getStudentsNames() { QStringList studentList; @@ -1193,17 +1323,15 @@ QStringList MainWindow::getStudentsNames() virtualTable->setModel(virualQueryModel); - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { - studentList.append(virtualTable->model()->index(row, 0).data().toString() + " " + - virtualTable->model()->index(row, 1).data().toString() + " " + - virtualTable->model()->index(row, 2).data().toString() ); + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { + studentList.append(virtualTable->model()->index(row, 0).data().toString() + " " + + virtualTable->model()->index(row, 1).data().toString() + " " + + virtualTable->model()->index(row, 2).data().toString()); } return studentList; } - QStringList MainWindow::getTeachersNames() { QStringList teacherList; @@ -1215,17 +1343,15 @@ QStringList MainWindow::getTeachersNames() virtualTable->setModel(virualQueryModel); - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { - teacherList.append(virtualTable->model()->index(row, 0).data().toString() + " " + - virtualTable->model()->index(row, 1).data().toString() + " " + - virtualTable->model()->index(row, 2).data().toString()); + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { + teacherList.append(virtualTable->model()->index(row, 0).data().toString() + " " + + virtualTable->model()->index(row, 1).data().toString() + " " + + virtualTable->model()->index(row, 2).data().toString()); } return teacherList; } - QStringList MainWindow::getSubjectsNames() { QStringList subjectList; @@ -1237,15 +1363,13 @@ QStringList MainWindow::getSubjectsNames() virtualTable->setModel(virualQueryModel); - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { subjectList.append(virtualTable->model()->index(row, 0).data().toString()); } return subjectList; } - QStringList MainWindow::getSubjectsTypes() { QStringList categoryList; @@ -1258,15 +1382,13 @@ QStringList MainWindow::getSubjectsTypes() virtualTable->setModel(virualQueryModel); - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { categoryList.append(virtualTable->model()->index(row, 0).data().toString()); } return categoryList; } - QStringList MainWindow::getCategoryTeachers() { QStringList categoryList; @@ -1279,15 +1401,13 @@ QStringList MainWindow::getCategoryTeachers() virtualTable->setModel(virualQueryModel); - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { categoryList.append(virtualTable->model()->index(row, 0).data().toString()); } return categoryList; } - QStringList MainWindow::getGroupsNames() { QStringList groupList; @@ -1297,18 +1417,15 @@ QStringList MainWindow::getGroupsNames() virualQueryModel->setQuery("SELECT `Назва`" "FROM `Групи`"); - virtualTable->setModel(virualQueryModel); - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { groupList.append(virtualTable->model()->index(row, 0).data().toString()); } return groupList; } - QStringList MainWindow::getGroupsSpecial() { QStringList groupSpecialList; @@ -1321,136 +1438,135 @@ QStringList MainWindow::getGroupsSpecial() virtualTable->setModel(virualQueryModel); - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { groupSpecialList.append(virtualTable->model()->index(row, 0).data().toString()); } return groupSpecialList; } - void MainWindow::on_tableView_clicked(const QModelIndex &index) { row = index.row(); } - //========================================================= // // КОД ДЛЯ ЗВИТОВ ПО ТАБЛИЦАМ!!! // //========================================================= -void MainWindow::fillHTMLTable(QString& textHTML, QTableView* tableView){ - for (int i = 0; i < tableView->model()->columnCount(); ++i) - { - textHTML += " " + tableView->model()->headerData(i, Qt::Horizontal ).toString() +"\n"; +void MainWindow::fillHTMLTable(QString &textHTML, QTableView *tableView) +{ + for (int i = 0; i < tableView->model()->columnCount(); ++i) { + textHTML += " " + tableView->model()->headerData(i, Qt::Horizontal).toString() + + "\n"; } textHTML += "\n"; - for (int i = 0; i < tableView->model()->rowCount(); ++i) - { + for (int i = 0; i < tableView->model()->rowCount(); ++i) { textHTML += "\n"; - for (int j = 0; j < tableView->model()->columnCount(); ++j) - { - if (i % 2 not_eq 0) - { - textHTML += " " + tableView->model()->index(i,j).data().toString() + "\n"; - } - else - { - textHTML += " " + tableView->model()->index(i,j).data().toString() + "\n"; + for (int j = 0; j < tableView->model()->columnCount(); ++j) { + if (i % 2 not_eq 0) { + textHTML += " " + tableView->model()->index(i, j).data().toString() + + "\n"; + } else { + textHTML += " " + tableView->model()->index(i, j).data().toString() + + "\n"; } } textHTML += "\n"; } - textHTML+= ""; + textHTML += ""; } - -void MainWindow::on_currentTableReportButton_clicked() +void MainWindow::generateCurrentTableReport() { - if (model->rowCount() > 0) - { + qDebug() << QString("generateCurrentTableReport()"); + return; + + if (model->rowCount() > 0) { QString typeFile; - QString pathToSave = QFileDialog::getSaveFileName(nullptr, - tr("Збереження звіту"), - "/Users/" + qgetenv("USER") + "/Desktop", - "PDF формат (*.pdf);;HTML формат (*.html)", - &typeFile); - if (not pathToSave.isEmpty()) - { + QString pathToSave + = QFileDialog::getSaveFileName(nullptr, + tr("Збереження звіту"), + "/Users/" + qgetenv("USER") + "/Desktop", + "PDF формат (*.pdf);;HTML формат (*.html)", + &typeFile); + if (not pathToSave.isEmpty()) { QString textHTML = getHeaderHTML(); - textHTML += "

Звіт Gradify

\n\nf"; + textHTML += "

Звіт Gradify

\n
\nf"; - fillHTMLTable(textHTML, ui->tableView); + fillHTMLTable(textHTML, ui->tableWidget); - if (typeFile == "HTML формат (*.html)") - { + if (typeFile == "HTML формат (*.html)") { printDocumentToHTML(pathToSave, textHTML); - } - else if (typeFile == "PDF формат (*.pdf)") - { + } else if (typeFile == "PDF формат (*.pdf)") { printDocumentToPDF(pathToSave, textHTML); } } - } - else - { - QMessageBox::information(this,"","У таблиці не знайдено записів!"); + } else { + QMessageBox::information(this, "", "У таблиці не знайдено записів!"); } } - -void MainWindow::on_studentsReportButton_clicked() +void MainWindow::generateStudentsGroupReport() { + qDebug() << QString("generateStudentsGroupReport()"); + return; + bool ok; - QString selectedGroup = QInputDialog::getItem(this, tr("Звіт за студентами групи"), - tr("Оберіть групу:"), getGroupsNames(), - 0, false, &ok); - if (ok) - { + QString selectedGroup = QInputDialog::getItem(this, + tr("Звіт за студентами групи"), + tr("Оберіть групу:"), + getGroupsNames(), + 0, + false, + &ok); + if (ok) { QString typeFile; - QString pathToSave = QFileDialog::getSaveFileName(nullptr, - tr("Збереження звіту"), - "/Users/" + qgetenv("USER") + "/Desktop", - "PDF формат (*.pdf);;HTML формат (*.html)", - &typeFile); - if (not pathToSave.isEmpty()) - { + QString pathToSave + = QFileDialog::getSaveFileName(nullptr, + tr("Збереження звіту"), + "/Users/" + qgetenv("USER") + "/Desktop", + "PDF формат (*.pdf);;HTML формат (*.html)", + &typeFile); + if (not pathToSave.isEmpty()) { QSqlQueryModel *queryModel = new QSqlQueryModel(this); QTableView *tableView = new QTableView(this); queryModel->setQuery("SELECT * " "FROM `Студенти`" - "WHERE `Студенти`.`Група` = '" + selectedGroup + "'"); + "WHERE `Студенти`.`Група` = '" + + selectedGroup + "'"); tableView->setModel(queryModel); QString textHTML = getHeaderHTML(); - textHTML += "

Звіт за студентами групи «" + selectedGroup + "»

\n
\nf"; + textHTML += "

Звіт за студентами групи «" + selectedGroup + + "»

\n
\nf"; fillHTMLTable(textHTML, tableView); queryModel->setQuery("SELECT `Куратор`,`Староста`" - "FROM `Групи`" - "WHERE `Групи`.`Назва` = '" + selectedGroup + "'"); + "FROM `Групи`" + "WHERE `Групи`.`Назва` = '" + + selectedGroup + "'"); tableView->setModel(queryModel); textHTML += "\n "; - - QString bufStr = tableView->model()->index(0, 0) .data().toString(); + QString bufStr = tableView->model()->index(0, 0).data().toString(); textHTML += "\n "; bufStr.remove(0, bufStr.indexOf(' ') + 1); textHTML += "\n "; bufStr.remove(0, bufStr.lastIndexOf(' ') + 1); textHTML += "\n \n\n"; - bufStr = tableView->model()->index(0, 1) .data().toString(); + bufStr = tableView->model()->index(0, 1).data().toString(); textHTML += "\n\n "; textHTML += "\n "; bufStr.remove(0, bufStr.indexOf(' ') + 1); @@ -1458,31 +1574,33 @@ void MainWindow::on_studentsReportButton_clicked() bufStr.remove(0, bufStr.lastIndexOf(' ') + 1); textHTML += "\n \n\n
Куратор" + bufStr.left(bufStr.indexOf(' ')) + "" + bufStr.left(bufStr.lastIndexOf(' ')) + "" + bufStr + "
Староста" + bufStr.left(bufStr.indexOf(' ')) + "" + bufStr + "
\n"; - if (typeFile == "HTML формат (*.html)") - { + if (typeFile == "HTML формат (*.html)") { printDocumentToHTML(pathToSave, textHTML); - } - else if (typeFile == "PDF формат (*.pdf)") - { + } else if (typeFile == "PDF формат (*.pdf)") { printDocumentToPDF(pathToSave, textHTML); } } } } - -void MainWindow::on_teachersReportButton_clicked() +void MainWindow::generateTeachersReport() { + qDebug() << QString("generateTeachersReport()"); + return; + // bool flag for get events status bool ok; // select teachers category - QString selectedCategory = QInputDialog::getItem(this, tr("Звіт по викладачам"), - tr("Оберіть категорію викладача:"), getCategoryTeachers(), - 0, false, &ok); - - if (ok) - { + QString selectedCategory = QInputDialog::getItem(this, + tr("Звіт по викладачам"), + tr("Оберіть категорію викладача:"), + getCategoryTeachers(), + 0, + false, + &ok); + + if (ok) { // create teachers list QStringList teachersList; QSqlQueryModel *virtualQueryModel = new QSqlQueryModel(this); @@ -1490,61 +1608,64 @@ void MainWindow::on_teachersReportButton_clicked() virtualQueryModel->setQuery("SELECT `Прізвище`" "FROM `Викладачі` " - "WHERE `Викладачі`.`Категорія` = '" + selectedCategory + "';"); + "WHERE `Викладачі`.`Категорія` = '" + + selectedCategory + "';"); virtualTable->setModel(virtualQueryModel); - if (virtualQueryModel->rowCount() > 0) - { + if (virtualQueryModel->rowCount() > 0) { teachersList.append("Всі викладачі"); - for (int row = 0; row < virtualQueryModel->rowCount(); ++row) - { + for (int row = 0; row < virtualQueryModel->rowCount(); ++row) { teachersList.append(virtualTable->model()->index(row, 0).data().toString()); } - } - else - { + } else { QMessageBox::information(this, "Помилка", "Викладачів даної категорії немає!"); return; } // string choice teacher - QString optionChoice = QInputDialog::getItem(this, tr("Звіт по викладачам"), - tr("Оберіть викладача:"), teachersList, - 0, false, &ok); - - if (ok) - { + QString optionChoice = QInputDialog::getItem(this, + tr("Звіт по викладачам"), + tr("Оберіть викладача:"), + teachersList, + 0, + false, + &ok); + + if (ok) { // get path to report save QString typeFile; - QString pathToSave = QFileDialog::getSaveFileName(nullptr, - tr("Збереження звіту"), - "/Users/" + qgetenv("USER") + "/Desktop", - "PDF формат (*.pdf);;HTML формат (*.html)", - &typeFile); - if (not pathToSave.isEmpty()) - { + QString pathToSave + = QFileDialog::getSaveFileName(nullptr, + tr("Збереження звіту"), + "/Users/" + qgetenv("USER") + "/Desktop", + "PDF формат (*.pdf);;HTML формат (*.html)", + &typeFile); + if (not pathToSave.isEmpty()) { QSqlQueryModel *virtualQueryModel = new QSqlQueryModel(this); QTableView *virtualTableView = new QTableView(this); QString textHTML = getHeaderHTML(); - if (optionChoice == "Всі викладачі") - { + if (optionChoice == "Всі викладачі") { virtualQueryModel->setQuery("SELECT * " "FROM `Викладачі`" - "WHERE `Викладачі`.`Категорія` = '" + selectedCategory + "';"); - textHTML += "

Викладачі з категорією «" + selectedCategory + "»

\n\nf"; + "WHERE `Викладачі`.`Категорія` = '" + + selectedCategory + "';"); + textHTML += "

Викладачі з категорією «" + selectedCategory + + "»

\n
\nf"; - } - else - { + } else { virtualQueryModel->setQuery("SELECT * " "FROM `Викладачі` " - "WHERE `Викладачі`.`Категорія` = '" + selectedCategory + "' " - "AND `Викладачі`.`Прізвище` = '" + optionChoice + "';"); - textHTML += "

Викладач з категорією «" + selectedCategory + "» " + optionChoice +"

\n
\nf"; - + "WHERE `Викладачі`.`Категорія` = '" + + selectedCategory + + "' " + "AND `Викладачі`.`Прізвище` = '" + + optionChoice + "';"); + textHTML += "

Викладач з категорією «" + selectedCategory + + "» " + optionChoice + + "

\n
\nf"; } virtualTableView->setModel(virtualQueryModel); @@ -1553,24 +1674,26 @@ void MainWindow::on_teachersReportButton_clicked() // statistics chart - if (optionChoice != "Всі викладачі") - { - virtualQueryModel->setQuery("SELECT `Предмети`.`Назва`, COUNT(`Оцінки`.`Оцінка`)" - "FROM `Оцінки`, `Предмети`, `Викладачі`" - "WHERE SUBSTRING_INDEX(`Предмети`.`Викладач`, ' ', 1) = '" + optionChoice + "'" - "AND `Предмети`.`Назва` = `Оцінки`.`Предмет`" - "GROUP BY(`Предмети`.`Назва`);"); - - if (virtualQueryModel->rowCount() > 0){ + if (optionChoice != "Всі викладачі") { + virtualQueryModel->setQuery( + "SELECT `Предмети`.`Назва`, COUNT(`Оцінки`.`Оцінка`)" + "FROM `Оцінки`, `Предмети`, `Викладачі`" + "WHERE SUBSTRING_INDEX(`Предмети`.`Викладач`, ' ', 1) = '" + + optionChoice + + "'" + "AND `Предмети`.`Назва` = `Оцінки`.`Предмет`" + "GROUP BY(`Предмети`.`Назва`);"); + + if (virtualQueryModel->rowCount() > 0) { // fill pie series virtualTable->setModel(virtualQueryModel); QPieSeries *pieSeries = new QPieSeries(); - for (int row = 0; row < virtualQueryModel->rowCount(); ++row) - { + for (int row = 0; row < virtualQueryModel->rowCount(); ++row) { pieSeries->append(virtualTable->model()->index(row, 0).data().toString(), - virtualTable->model()->index(row, 1).data().toInt() / 21); + virtualTable->model()->index(row, 1).data().toInt() + / 21); } pieSeries->setLabelsVisible(true); @@ -1585,174 +1708,166 @@ void MainWindow::on_teachersReportButton_clicked() chartView->setRenderHint(QPainter::Antialiasing); chartView->setBackgroundBrush(Qt::white); + chartView->grab().save(pathToSave.left(pathToSave.lastIndexOf('.')) + ".png", + "PNG"); - chartView->grab().save(pathToSave.left(pathToSave.lastIndexOf('.')) + ".png", "PNG"); - - textHTML += "


"; + textHTML += "


"; } } - if (typeFile == "HTML формат (*.html)") - { + if (typeFile == "HTML формат (*.html)") { printDocumentToHTML(pathToSave, textHTML); - } - else if (typeFile == "PDF формат (*.pdf)") - { + } else if (typeFile == "PDF формат (*.pdf)") { printDocumentToPDF(pathToSave, textHTML); } } } } - } - -void MainWindow::on_gradesReportButton_clicked() +void MainWindow::generateGradesReport() { + qDebug() << QString("generateGradesReport()"); + return; + bool ok; - QString selectedStudent = QInputDialog::getItem(this, tr("Звіт по оцінкам"), - tr("Оберіть отримувача оцінок:"), getStudentsNames(), - 0, false, &ok); - if (ok) - { + QString selectedStudent = QInputDialog::getItem(this, + tr("Звіт по оцінкам"), + tr("Оберіть отримувача оцінок:"), + getStudentsNames(), + 0, + false, + &ok); + if (ok) { QString typeFile; - QString pathToSave = QFileDialog::getSaveFileName(nullptr, - tr("Збереження звіту"), - "/Users/" + qgetenv("USER") + "/Desktop", - "PDF формат (*.pdf);;HTML формат (*.html)", - &typeFile); - if (not pathToSave.isEmpty()) - { + QString pathToSave + = QFileDialog::getSaveFileName(nullptr, + tr("Збереження звіту"), + "/Users/" + qgetenv("USER") + "/Desktop", + "PDF формат (*.pdf);;HTML формат (*.html)", + &typeFile); + if (not pathToSave.isEmpty()) { QSqlQueryModel *queryModel = new QSqlQueryModel(this); QTableView *tableView = new QTableView(this); queryModel->setQuery("SELECT * " "FROM `Оцінки`" - "WHERE `Оцінки`.`Отримувач` = '" + selectedStudent + "'"); + "WHERE `Оцінки`.`Отримувач` = '" + + selectedStudent + "'"); tableView->setModel(queryModel); QString textHTML = getHeaderHTML(); - textHTML += "

Звіт за оцінками студента «" + selectedStudent + "»

\n
\nf"; + textHTML += "

Звіт за оцінками студента «" + selectedStudent + + "»

\n
\nf"; fillHTMLTable(textHTML, tableView); - if (typeFile == "HTML формат (*.html)") - { + if (typeFile == "HTML формат (*.html)") { printDocumentToHTML(pathToSave, textHTML); - } - else if (typeFile == "PDF формат (*.pdf)") - { + } else if (typeFile == "PDF формат (*.pdf)") { printDocumentToPDF(pathToSave, textHTML); } } } } - -void MainWindow::on_groupsReportButton_clicked() +void MainWindow::generateGroupsReport() { + qDebug() << QString("generateGroupsReport()"); + return; + bool ok; - QString selectedTypeSubject = QInputDialog::getItem(this, tr("Звіт за спеціальностями груп"), - tr("Оберіть спеціальність групи:"), getGroupsSpecial(), - 0, false, &ok); - if (ok) - { + QString selectedTypeSubject = QInputDialog::getItem(this, + tr("Звіт за спеціальностями груп"), + tr("Оберіть спеціальність групи:"), + getGroupsSpecial(), + 0, + false, + &ok); + if (ok) { QString typeFile; - QString pathToSave = QFileDialog::getSaveFileName(nullptr, - tr("Збереження звіту"), - "/Users/" + qgetenv("USER") + "/Desktop", - "PDF формат (*.pdf);;HTML формат (*.html)", - &typeFile); - if (not pathToSave.isEmpty()) - { + QString pathToSave + = QFileDialog::getSaveFileName(nullptr, + tr("Збереження звіту"), + "/Users/" + qgetenv("USER") + "/Desktop", + "PDF формат (*.pdf);;HTML формат (*.html)", + &typeFile); + if (not pathToSave.isEmpty()) { QSqlQueryModel *queryModel = new QSqlQueryModel(this); QTableView *tableView = new QTableView(this); queryModel->setQuery("SELECT * " "FROM `Групи`" - "WHERE `Групи`.`Спеціальність` = '" + selectedTypeSubject + "'"); + "WHERE `Групи`.`Спеціальність` = '" + + selectedTypeSubject + "'"); tableView->setModel(queryModel); QString textHTML = getHeaderHTML(); - textHTML += "

Звіт за спеціальністю «" + selectedTypeSubject + "»

\n
\nf"; + textHTML += "

Звіт за спеціальністю «" + selectedTypeSubject + + "»

\n
\nf"; fillHTMLTable(textHTML, tableView); - if (typeFile == "HTML формат (*.html)") - { + if (typeFile == "HTML формат (*.html)") { printDocumentToHTML(pathToSave, textHTML); - } - else if (typeFile == "PDF формат (*.pdf)") - { + } else if (typeFile == "PDF формат (*.pdf)") { printDocumentToPDF(pathToSave, textHTML); } } } } - -void MainWindow::on_subjectsReportButton_clicked() +void MainWindow::generateSubjectsReport() { + qDebug() << QString("generateSubjectsReport()"); + return; + bool ok; - QString selectedTypeSubject = QInputDialog::getItem(this, tr("Звіт за предметами"), - tr("Оберіть тип предмету:"), getSubjectsTypes(), - 0, false, &ok); - if (ok) - { + QString selectedTypeSubject = QInputDialog::getItem(this, + tr("Звіт за предметами"), + tr("Оберіть тип предмету:"), + getSubjectsTypes(), + 0, + false, + &ok); + if (ok) { QString typeFile; - QString pathToSave = QFileDialog::getSaveFileName(nullptr, - tr("Збереження звіту"), - "/Users/" + qgetenv("USER") + "/Desktop", - "PDF формат (*.pdf);;HTML формат (*.html)", - &typeFile); - if (not pathToSave.isEmpty()) - { + QString pathToSave + = QFileDialog::getSaveFileName(nullptr, + tr("Збереження звіту"), + "/Users/" + qgetenv("USER") + "/Desktop", + "PDF формат (*.pdf);;HTML формат (*.html)", + &typeFile); + if (not pathToSave.isEmpty()) { QSqlQueryModel *queryModel = new QSqlQueryModel(this); QTableView *tableView = new QTableView(this); queryModel->setQuery("SELECT * " "FROM `Предмети`" - "WHERE `Предмети`.`Тип` = '" + selectedTypeSubject + "'"); + "WHERE `Предмети`.`Тип` = '" + + selectedTypeSubject + "'"); tableView->setModel(queryModel); QString textHTML = getHeaderHTML(); - textHTML += "

Звіт за типом предмета «" + selectedTypeSubject + "»

\n
\nf"; + textHTML += "

Звіт за типом предмета «" + selectedTypeSubject + + "»

\n
\nf"; fillHTMLTable(textHTML, tableView); - if (typeFile == "HTML формат (*.html)") - { + if (typeFile == "HTML формат (*.html)") { printDocumentToHTML(pathToSave, textHTML); - } - else if (typeFile == "PDF формат (*.pdf)") - { + } else if (typeFile == "PDF формат (*.pdf)") { printDocumentToPDF(pathToSave, textHTML); } } } } - -//========================================================= -// -// -// This code for styling theme application -// Warning! Many line code. -// -// -//========================================================= - -//==================== -// -// set black style -// -//==================== - - void MainWindow::setBlackUI() { QFile file(":/styles/black/mainWindow/mainWindow.qss"); @@ -1770,42 +1885,42 @@ void MainWindow::setBlackUI() selectButtonAuthStyle = QLatin1String(file.readAll()); file.close(); - if (isLogin) - { + if (isLogin) { ui->authorizationButton->setStyleSheet(selectButtonAuthStyle); } ui->searchLineEdit->setIconSearchButton(QIcon(":/img/blackMenuIcon/search.png"), QSize(12, 12)); - ui->searchLineEdit->setIconClearButton(QIcon(":/img/whiteMenuIcon/clearLoginIco.png"), QSize(12, 12)); + ui->searchLineEdit->setIconClearButton(QIcon(":/img/whiteMenuIcon/clearLoginIco.png"), + QSize(12, 12)); setCurrentIconAction(); - switch (currentSelectTable) - { - case 0: + switch (currentSelectTable) { + case TableType::Students: ui->studentsTableButton->setStyleSheet(selectButtonTableStyle); ui->studentsTableButton->setIcon(QIcon(":/img/blackMenuIcon/studentsIco.png")); break; - case 1: + case TableType::Teachers: ui->teachersTableButton->setStyleSheet(selectButtonTableStyle); ui->teachersTableButton->setIcon(QIcon(":/img/blackMenuIcon/teachersIco.png")); break; - case 2: + case TableType::Grades: ui->gradesTableButton->setStyleSheet(selectButtonTableStyle); - ui->gradesTableButton->setIcon(QIcon(":/img/blackMenuIcon/raitingIco.png")); + ui->gradesTableButton->setIcon(QIcon(":/img/blackMenuIcon/gradesIco.png")); break; - case 3: + case TableType::Groups: ui->groupsTableButton->setStyleSheet(selectButtonTableStyle); - ui->groupsTableButton->setIcon(QIcon(":/img/blackMenuIcon/groupIco.png")); + ui->groupsTableButton->setIcon(QIcon(":/img/blackMenuIcon/groupsIco.png")); break; - case 4: + case TableType::Subjects: ui->subjectsTableButton->setStyleSheet(selectButtonTableStyle); - ui->subjectsTableButton->setIcon(QIcon(":/img/blackMenuIcon/subjectIco.png")); + ui->subjectsTableButton->setIcon(QIcon(":/img/blackMenuIcon/subjectsIco.png")); + break; + case None: break; } } - //==================== // // set white style @@ -1829,235 +1944,151 @@ void MainWindow::setWhiteUI() selectButtonAuthStyle = QLatin1String(file.readAll()); file.close(); - if (isLogin) - { + if (isLogin) { ui->authorizationButton->setStyleSheet(selectButtonAuthStyle); } ui->searchLineEdit->setIconSearchButton(QIcon(":/img/blackMenuIcon/search.png"), QSize(12, 12)); - ui->searchLineEdit->setIconClearButton(QIcon(":/img/blackMenuIcon/clearLoginIco.png"), QSize(12, 12)); + ui->searchLineEdit->setIconClearButton(QIcon(":/img/blackMenuIcon/clearLoginIco.png"), + QSize(12, 12)); setCurrentIconAction(); - switch (currentSelectTable) - { - case 0: + switch (currentSelectTable) { + case TableType::Students: ui->studentsTableButton->setStyleSheet(selectButtonTableStyle); ui->studentsTableButton->setIcon(QIcon(":/img/whiteMenuIcon/studentsIco.png")); break; - case 1: + case TableType::Teachers: ui->teachersTableButton->setStyleSheet(selectButtonTableStyle); ui->teachersTableButton->setIcon(QIcon(":/img/whiteMenuIcon/teachersIco.png")); break; - case 2: + case TableType::Grades: ui->gradesTableButton->setStyleSheet(selectButtonTableStyle); - ui->gradesTableButton->setIcon(QIcon(":/img/whiteMenuIcon/raitingIco.png")); + ui->gradesTableButton->setIcon(QIcon(":/img/whiteMenuIcon/gradesIco.png")); break; - case 3: + case TableType::Groups: ui->groupsTableButton->setStyleSheet(selectButtonTableStyle); - ui->groupsTableButton->setIcon(QIcon(":/img/whiteMenuIcon/groupIco.png")); + ui->groupsTableButton->setIcon(QIcon(":/img/whiteMenuIcon/groupsIco.png")); break; - case 4: + case TableType::Subjects: ui->subjectsTableButton->setStyleSheet(selectButtonTableStyle); - ui->subjectsTableButton->setIcon(QIcon(":/img/whiteMenuIcon/subjectIco.png")); + ui->subjectsTableButton->setIcon(QIcon(":/img/whiteMenuIcon/subjectsIco.png")); + break; + case TableType::None: break; } } - void MainWindow::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { theme = "white"; setWhiteUI(); - } - else - { + } else { theme = "black"; setBlackUI(); } } - void MainWindow::setCurrentIconAction() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); QString iconColor = newBase.name() == "#000000" ? "black" : "white"; ui->openStudTabAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/studentsIco.png")); ui->openTeachTabAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/teachersIco.png")); - ui->openGradesTabAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/raitingIco.png")); - ui->openGroupTabAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/groupIco.png")); - ui->openSubjTabAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/subjectIco.png")); + ui->openGradesTabAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/gradesIco.png")); + ui->openGroupTabAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/groupsIco.png")); + ui->openSubjTabAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/subjectsIco.png")); ui->addRowAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/newRecord.png")); ui->deleteRowAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/deleteRecord.png")); ui->editRowAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/editRecord.png")); - ui->currentTableReportAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/reportCurrentTable.png")); - ui->studentsReportAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/reportStudent.png")); - ui->teachersReportAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/reportTeachers.png")); - ui->gradesReportAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/reportRaiting.png")); - ui->groupsReportAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/reportGroup.png")); - ui->subjectsReportAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/reportItem.png")); + ui->currentTableReportAction->setIcon( + QIcon(":/img/" + iconColor + "ActionsIcon/reportCurrentTable.png")); + ui->studentsReportAction->setIcon( + QIcon(":/img/" + iconColor + "ActionsIcon/reportStudents.png")); + ui->teachersReportAction->setIcon( + QIcon(":/img/" + iconColor + "ActionsIcon/reportTeachers.png")); + ui->gradesReportAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/reportGrades.png")); + ui->groupsReportAction->setIcon(QIcon(":/img/" + iconColor + "ActionsIcon/reportGroups.png")); + ui->subjectsReportAction->setIcon( + QIcon(":/img/" + iconColor + "ActionsIcon/reportSubjects.png")); } - //========================================================= // // Realisation menuBar code // //========================================================= -void MainWindow::on_addRowAction_triggered() -{ - on_addRowButton_clicked(); -} - - -void MainWindow::on_deleteRowAction_triggered() -{ - on_deleteRowButton_clicked(); -} - - -void MainWindow::on_editRowAction_triggered() -{ - on_editRowButton_clicked(); -} - - -void MainWindow::on_openStudTabAction_triggered() -{ - on_studentsTableButton_clicked(); -} - - -void MainWindow::on_openTeachTabAction_triggered() -{ - on_teachersTableButton_clicked(); -} - - -void MainWindow::on_openGradesTabAction_triggered() +void MainWindow::openManual() { - on_gradesTableButton_clicked(); + QDesktopServices::openUrl( + QUrl("https://gradify.online/Посібник_користувача.pdf", QUrl::TolerantMode)); } - -void MainWindow::on_openGroupTabAction_triggered() -{ - on_groupsTableButton_clicked(); -} - - -void MainWindow::on_openSubjTabAction_triggered() -{ - on_subjectsTableButton_clicked(); -} - - -void MainWindow::on_openManual_triggered() -{ - QDesktopServices::openUrl(QUrl("https://gradify.online/Посібник_користувача.pdf", QUrl::TolerantMode)); -} - - -void MainWindow::on_studentsReportAction_triggered() -{ - on_studentsReportButton_clicked(); -} - - -void MainWindow::on_teachersReportAction_triggered() -{ - on_teachersReportButton_clicked(); -} - - -void MainWindow::on_groupsReportAction_triggered() -{ - on_groupsReportButton_clicked(); -} - - -void MainWindow::on_gradesReportAction_triggered() -{ - on_gradesReportButton_clicked(); -} - - -void MainWindow::on_subjectsReportAction_triggered() -{ - on_subjectsReportButton_clicked(); -} - - -void MainWindow::on_currentTableReportAction_triggered() -{ - on_currentTableReportButton_clicked(); -} - - -void MainWindow::on_about_triggered() +void MainWindow::openAboutWindow() { aboutAppWindow->show(); } - -void MainWindow::on_statisticsButton_clicked() +void MainWindow::openStatisticsWindow() { closeAllStatisticsForm(); - switch (currentSelectTable) - { - case 0: + switch (currentSelectTable) { + case TableType::Students: studentStat->show(); break; - case 1: + case TableType::Teachers: teacherStat->fillChart(); teacherStat->show(); break; - case 2: + case TableType::Grades: gradeStat->show(); break; - case 3: + case TableType::Groups: groupStat->show(); emit updateStatisticsComboBoxSignal(); break; - case 4: + case TableType::Subjects: subjectStat->fillChart(); subjectStat->show(); break; + case None: + break; } emit updateStatisticsSignal(); } -QString MainWindow::modelDataToString(QAbstractItemModel* model) +QString MainWindow::modelDataToString(QAbstractItemModel *model) { QString textData; - for (int col = 0; col < model->columnCount(); ++col) - { + for (int col = 0; col < model->columnCount(); ++col) { textData += model->headerData(col, Qt::Horizontal).toString() + ", "; } textData += "\n"; - for (int row = 0; row < model->rowCount(); ++row) - { - for (int col = 0; col < model->columnCount(); ++col) - { - textData += model->data(model->index(row, col)).toString(); - textData += ", "; + for (int row = 0; row < model->rowCount(); ++row) { + for (int col = 0; col < model->columnCount(); ++col) { + textData += model->data(model->index(row, col)).toString(); + textData += ", "; } textData += "\n"; } @@ -2065,10 +2096,12 @@ QString MainWindow::modelDataToString(QAbstractItemModel* model) return textData; } -void MainWindow::on_actionCSV_triggered() +void MainWindow::exportDataToCSV() { - if (model->rowCount() == 0) - { + qDebug() << QString("exportDataToCSV"); + return; + + if (model->rowCount() == 0) { QMessageBox::information(this, "Помилка", "Оберіть таблицю для експорту"); return; } @@ -2076,22 +2109,23 @@ void MainWindow::on_actionCSV_triggered() QString pathToSave = QFileDialog::getSaveFileName(nullptr, tr("Експорт файлу:"), "/Users/" + qgetenv("USER") + "/Desktop", - "CSV files (*.csv);;All files (*.*)", new QString("CSV file (*.csv)")); + "CSV files (*.csv);;All files (*.*)", + new QString("CSV file (*.csv)")); QFile csvFile(pathToSave + ".csv"); - if(csvFile.open(QIODevice::WriteOnly)) { - + if (csvFile.open(QIODevice::WriteOnly)) { QTextStream out(&csvFile); out << modelDataToString(model); csvFile.close(); } } - -void MainWindow::on_actionTXT_triggered() +void MainWindow::exportDataToTXT() { - if (model->rowCount() == 0) - { + qDebug() << QString("exportDataToTXT"); + return; + + if (model->rowCount() == 0) { QMessageBox::information(this, "Помилка", "Оберіть таблицю для експорту"); return; } @@ -2099,20 +2133,20 @@ void MainWindow::on_actionTXT_triggered() QString pathToSave = QFileDialog::getSaveFileName(nullptr, tr("Експорт файлу:"), "/Users/" + qgetenv("USER") + "/Desktop", - "Text file (*.txt);;All files (*.*)", new QString("Text file (*.txt)")); + "Text file (*.txt);;All files (*.*)", + new QString("Text file (*.txt)")); QFile txtFile(pathToSave); - if (txtFile.open(QIODevice::WriteOnly)) - { + if (txtFile.open(QIODevice::WriteOnly)) { QTextStream out(&txtFile); out << modelDataToString(model); txtFile.close(); } } - void MainWindow::on_actionEnglish_Translate_triggered() { + /* qDebug() << "Switching to English (United States)..."; QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); qDebug() << "Current locale:" << QLocale::system().name(); @@ -2123,12 +2157,12 @@ void MainWindow::on_actionEnglish_Translate_triggered() } else { qDebug() << "Failed to install translation."; } + */ } - - void MainWindow::on_actionUkrainian_Translate_triggered() { + /* qDebug() << "Switching to Ukrainian (Ukraine)..."; QLocale::setDefault(QLocale(QLocale::Ukrainian, QLocale::Ukraine)); qDebug() << "Current locale:" << QLocale::system().name(); @@ -2139,5 +2173,5 @@ void MainWindow::on_actionUkrainian_Translate_triggered() } else { qDebug() << "Failed to install translation."; } + */ } - diff --git a/src/mainwindow.h b/src/mainwindow.h index 8cf8659..6f28ff0 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -1,28 +1,28 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include "QtWidgets/qpushbutton.h" -#include -#include +#include #include #include +#include +#include #include +#include +#include #include #include #include -#include -#include -#include -#include +#include #include +#include "QtWidgets/qpushbutton.h" #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include @@ -36,8 +36,12 @@ #include #include +#include + QT_BEGIN_NAMESPACE -namespace Ui { class MainWindow; } +namespace Ui { +class MainWindow; +} QT_END_NAMESPACE class MainWindow : public QMainWindow @@ -50,33 +54,46 @@ class MainWindow : public QMainWindow void changeEvent(QEvent *event) override; void closeEvent(QCloseEvent *event) override; + enum TableType { + Teachers, + Subjects, + Students, + Grades, + Groups, + None + }; + Q_ENUM(TableType); + protected: void mousePressEvent(QMouseEvent *event) override; private slots: - void on_studentsTableButton_clicked(); - void on_teachersTableButton_clicked(); - void on_gradesTableButton_clicked(); - void on_groupsTableButton_clicked(); + void openTeachersTable(); + void openSubjectsTable(); + void openStudentsTable(); + void openGradesTable(); + void openGroupsTable(); + void clearStyleButtonTable(); - void on_settingsButton_clicked(); + + void openSettingsWindow(); void setBlackUI(); void setWhiteUI(); void setSystemUI(); void setCurrentIconAction(); - void mainWindowInit(); + void initMainWindow(); void configDefault(); void configInit(); void configWrite(const QString &key, const QVariant &value); - void userLogout(); + void logoutUser(); - void on_authorizationButton_clicked(); - void on_addRowButton_clicked(); - void on_deleteRowButton_clicked(); + void handleLogin(); + void addRowToTable(); + void editRowInTable(); + void deleteRowFromTable(); void on_tableView_clicked(const QModelIndex &index); - void on_subjectsTableButton_clicked(); void clearSelectTable(); void closeAllPopUpWindow(); @@ -87,40 +104,25 @@ private slots: void setEnabledActions(const bool &status); void setEnabledEditButton(const bool &status); - void on_addRowAction_triggered(); - void on_deleteRowAction_triggered(); - void on_editRowAction_triggered(); - void on_editRowButton_clicked(); - void on_openStudTabAction_triggered(); - void on_openTeachTabAction_triggered(); - void on_openGradesTabAction_triggered(); - void on_openGroupTabAction_triggered(); - void on_openSubjTabAction_triggered(); - void on_studentsReportButton_clicked(); - void on_teachersReportButton_clicked(); - void on_gradesReportButton_clicked(); - void on_groupsReportButton_clicked(); - void on_subjectsReportButton_clicked(); - - void on_openManual_triggered(); - - void on_studentsReportAction_triggered(); - void on_teachersReportAction_triggered(); - void on_groupsReportAction_triggered(); - void on_gradesReportAction_triggered(); - void on_subjectsReportAction_triggered(); - void on_currentTableReportAction_triggered(); - void on_currentTableReportButton_clicked(); - - void on_about_triggered(); - void on_filterButton_clicked(); - void on_queryButton_clicked(); + void generateStudentsGroupReport(); + void generateTeachersReport(); + void generateGradesReport(); + void generateGroupsReport(); + void generateSubjectsReport(); + + void openManual(); + + void generateCurrentTableReport(); + + void openAboutWindow(); + void toggleFilterWindow(); + void toggleQueryWindow(); void printDocumentToPDF(const QString path, const QString html); void printDocumentToHTML(const QString path, const QString html); QString getHeaderHTML(); - void fillHTMLTable(QString& textHTML, QTableView* tableView); + void fillHTMLTable(QString &textHTML, QTableView *tableView); QGraphicsDropShadowEffect *paintDropShadowEffect(); @@ -136,12 +138,12 @@ private slots: QStringList getSubjectsTypes(); QStringList getCategoryTeachers(); - void on_statisticsButton_clicked(); + void openStatisticsWindow(); - QString modelDataToString(QAbstractItemModel* model); + QString modelDataToString(QAbstractItemModel *model); - void on_actionCSV_triggered(); - void on_actionTXT_triggered(); + void exportDataToCSV(); + void exportDataToTXT(); void on_actionEnglish_Translate_triggered(); @@ -150,13 +152,15 @@ private slots: private: Ui::MainWindow *ui; + DatabaseHandler *dbHandler; + QTranslator translator; - appSetting *settingWindow; - authorizationForm *authorizationWindow; - filterForm *filterWindow; - queryForm *queryWindow; - aboutApp *aboutAppWindow; + AppSettingsWindow *appSettingsWindow; + LoginWindow *loginWindow; + FilterWindow *filterWindow; + QueryWindow *queryWindow; + AboutAppWindow *aboutAppWindow; gradeWindow *gradeForm; groupWindow *groupForm; @@ -188,19 +192,21 @@ private slots: QGraphicsDropShadowEffect *effect; int row; - int currentSelectTable; + + TableType currentSelectTable; bool isLogin; public slots: void setTheme(const QString &style); void authorization(const QString &login); - void setFilterForTable(const QString &filterQuery, - const QString ¤tColumnFilter); + void setFilterForTable(const QString &filterQuery, const QString ¤tColumnFilter); void clearFilterForTable(); void goSearch(); void setDataToModel(QStringList dataList, bool isNewRow); void setQueryForTable(QString query); + void openTable(TableType tableType, const QString &tableName); + void fillTable(const QStringList &columns, const QJsonArray &data); signals: void setThemeSettingsUI(const QString); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index da47f1b..75cfe29 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -127,7 +127,7 @@ - :/img/blueMenuIcon/raitingIco.png:/img/blueMenuIcon/raitingIco.png + :/img/blueMenuIcon/gradesIco.png:/img/blueMenuIcon/gradesIco.png @@ -293,7 +293,7 @@ - :/img/blueMenuIcon/groupIco.png:/img/blueMenuIcon/groupIco.png + :/img/blueMenuIcon/groupsIco.png:/img/blueMenuIcon/groupsIco.png @@ -318,7 +318,7 @@ - Авторизація + Вхід @@ -369,7 +369,7 @@ - :/img/blueMenuIcon/subjectIco.png:/img/blueMenuIcon/subjectIco.png + :/img/blueMenuIcon/subjectsIco.png:/img/blueMenuIcon/subjectsIco.png @@ -438,7 +438,7 @@ - :/img/reportsIcon/reportItem.png:/img/reportsIcon/reportItem.png + :/img/reportsIcon/reportSubjects.png:/img/reportsIcon/reportSubjects.png @@ -532,7 +532,7 @@ - :/img/reportsIcon/reportRaiting.png:/img/reportsIcon/reportRaiting.png + :/img/reportsIcon/reportGrades.png:/img/reportsIcon/reportGrades.png @@ -579,7 +579,7 @@ - :/img/reportsIcon/reportGroup.png:/img/reportsIcon/reportGroup.png + :/img/reportsIcon/reportGroups.png:/img/reportsIcon/reportGroups.png @@ -626,7 +626,7 @@ - :/img/reportsIcon/reportStudent.png:/img/reportsIcon/reportStudent.png + :/img/reportsIcon/reportStudents.png:/img/reportsIcon/reportStudents.png @@ -718,7 +718,7 @@ - :/img/blueMenuIcon/settingIco.png:/img/blueMenuIcon/settingIco.png + :/img/blueMenuIcon/settingsIco.png:/img/blueMenuIcon/settingsIco.png @@ -1112,43 +1112,13 @@ - - - - 5 - 12 - - - - true - - - true - - - - + QAbstractItemView::NoEditTriggers - - true - true - - true - - - true - - - false - - - 20 - @@ -1171,11 +1141,11 @@ Перегляд - + + - @@ -1183,11 +1153,11 @@ Звіти - + + - @@ -1221,8 +1191,8 @@ Редагування - + @@ -1261,7 +1231,7 @@ Відкрити таблицю "Студенти" - Ctrl+Alt+1 + Ctrl+Alt+3 @@ -1269,7 +1239,7 @@ Відкрити таблицю "Викладачі" - Ctrl+Alt+2 + Ctrl+Alt+1 @@ -1277,7 +1247,7 @@ Відкрити таблицю "Оцінки" - Ctrl+Alt+3 + Ctrl+Alt+4 @@ -1288,7 +1258,7 @@ Відкрити таблицю "Групи" - Ctrl+Alt+4 + Ctrl+Alt+5 @@ -1296,7 +1266,7 @@ Відкрити таблицю "Предмети" - Ctrl+Alt+5 + Ctrl+Alt+2 @@ -1315,7 +1285,7 @@ Звіт по студентам - Meta+Ctrl+2 + Meta+Ctrl+4 @@ -1323,7 +1293,7 @@ Звіт по викладачам - Meta+Ctrl+3 + Meta+Ctrl+2 @@ -1331,7 +1301,7 @@ Звіт по оцінкам - Meta+Ctrl+4 + Meta+Ctrl+5 @@ -1339,7 +1309,7 @@ Звіт по групам - Meta+Ctrl+5 + Meta+Ctrl+6 @@ -1347,7 +1317,7 @@ Звіт по предметам - Meta+Ctrl+6 + Meta+Ctrl+3 diff --git a/src/preloader.cpp b/src/preloader.cpp index a689c69..bb8568a 100644 --- a/src/preloader.cpp +++ b/src/preloader.cpp @@ -1,13 +1,13 @@ #include "preloader.h" #include "ui_preloader.h" +#include #include #include -#include -preloader::preloader(QWidget *parent) : - QWidget(parent), - ui(new Ui::preloader) +preloader::preloader(QWidget *parent) + : QWidget(parent) + , ui(new Ui::preloader) { ui->setupUi(this); @@ -36,20 +36,15 @@ preloader::preloader(QWidget *parent) : connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressBar())); - QTimer::singleShot(1000, [this] - { + QTimer::singleShot(1000, [this] { ui->loadStatusLabel->setText("LOADING database connection"); }); - QTimer::singleShot(1850, [this] - { + QTimer::singleShot(1850, [this] { ui->loadStatusLabel->setText("LOADING application styles"); }); - QTimer::singleShot(2300, [this] - { - ui->loadLabel->setText("start!"); - }); + QTimer::singleShot(2300, [this] { ui->loadLabel->setText("start!"); }); QFile file(":/styles/other/preloader/preloader.qss"); file.open(QFile::ReadOnly); @@ -57,26 +52,19 @@ preloader::preloader(QWidget *parent) : file.close(); } - preloader::~preloader() { delete ui; } - - void preloader::updateProgressBar() { - - if (ui->progressBar->value() < 100) - { + if (ui->progressBar->value() < 100) { ui->progressBar->setValue(ui->progressBar->value() + 1); - } - else - { + } else { mainMenu = new MainWindow; mainMenu->show(); - delete(timer); + delete (timer); close(); } } diff --git a/src/preloader.h b/src/preloader.h index a93eb3b..c91f9d1 100644 --- a/src/preloader.h +++ b/src/preloader.h @@ -1,8 +1,8 @@ #ifndef PRELOADER_H #define PRELOADER_H -#include #include +#include #include diff --git a/src/queryform.cpp b/src/querywindow.cpp similarity index 57% rename from src/queryform.cpp rename to src/querywindow.cpp index 1f1c444..7b91152 100644 --- a/src/queryform.cpp +++ b/src/querywindow.cpp @@ -1,18 +1,17 @@ -#include "queryform.h" -#include "ui_queryform.h" +#include "querywindow.h" +#include "ui_querywindow.h" -#include -#include #include -#include +#include #include +#include +#include #include -#include #include -queryForm::queryForm(QWidget *parent) : - QWidget(parent), - ui(new Ui::queryForm) +QueryWindow::QueryWindow(QWidget *parent) + : QWidget(parent) + , ui(new Ui::queryForm) { ui->setupUi(this); setWindowFlag(Qt::FramelessWindowHint, true); @@ -22,28 +21,26 @@ queryForm::queryForm(QWidget *parent) : changedGradeTable = -1; } - -queryForm::~queryForm() +QueryWindow::~QueryWindow() { delete ui; } - -void queryForm::on_mySQLPushButton_clicked() +void QueryWindow::on_mySQLPushButton_clicked() { ui->mySQLPushButton->setFocus(); show(); emit clearFilter(); } - -void queryForm::on_succesStudentPushButton_clicked() +void QueryWindow::on_succesStudentPushButton_clicked() { bool ok; QString strSqlQuery; QStringList listGroup; + /* QSqlQueryModel *queryModel = new QSqlQueryModel(this); QTableView *tableView = new QTableView(this); @@ -51,38 +48,44 @@ void queryForm::on_succesStudentPushButton_clicked() "FROM `Групи`"); tableView->setModel(queryModel); - for (int row = 0; row < queryModel->rowCount(); ++row) - { + for (int row = 0; row < queryModel->rowCount(); ++row) { listGroup.append(tableView->model()->index(row, 0).data().toString()); } - QString selectedGroup = QInputDialog::getItem(this, tr("Запит по успішності групи"), - tr("Оберіть групу:"), listGroup, - 0, false, &ok); + QString selectedGroup = QInputDialog::getItem(this, + tr("Запит по успішності групи"), + tr("Оберіть групу:"), + listGroup, + 0, + false, + &ok); - if (ok) - { + if (ok) { strSqlQuery = "SELECT `Отримувач`, AVG(`Оцінка`) AS 'Середній бал' " "FROM `Оцінки`, `Студенти` " "WHERE `Студенти`.`Прізвище` = SUBSTRING_INDEX(`Отримувач`, ' ', 1) " - "AND `Студенти`.`Група` = '" + selectedGroup + "' " - "GROUP BY `Отримувач` " - "ORDER BY AVG(`Оцінка`) DESC;"; + "AND `Студенти`.`Група` = '" + + selectedGroup + + "' " + "GROUP BY `Отримувач` " + "ORDER BY AVG(`Оцінка`) DESC;"; emit sendQuery(strSqlQuery); } + */ } - -void queryForm::on_searchGradeStudentButton_clicked() +void QueryWindow::on_searchGradeStudentButton_clicked() { - if (changedGradeTable == 2) - { + + /* + if (changedGradeTable == 2) { bool ok; QString strSqlQuery; QStringList listGroup; + QSqlQueryModel *queryModel = new QSqlQueryModel(this); QTableView *tableView = new QTableView(this); @@ -90,55 +93,59 @@ void queryForm::on_searchGradeStudentButton_clicked() "FROM `Групи`"); tableView->setModel(queryModel); - for (int row = 0; row < queryModel->rowCount(); ++row) - { - listGroup.append(tableView->model()->index(row,0).data().toString()); + for (int row = 0; row < queryModel->rowCount(); ++row) { + listGroup.append(tableView->model()->index(row, 0).data().toString()); } - QString selectedGroup = QInputDialog::getItem(this, tr("Оберіть групу студента"), - tr("Оберіть групу:"), listGroup, - 0, false, &ok); + QString selectedGroup = QInputDialog::getItem(this, + tr("Оберіть групу студента"), + tr("Оберіть групу:"), + listGroup, + 0, + false, + &ok); - if (ok) - { + if (ok) { QStringList studentList; queryModel->setQuery("SELECT `Прізвище`, `Ім\'я` ,`По батькові`" "FROM `Студенти`" - "WHERE `Студенти`.`Група` = '" + selectedGroup + "'"); + "WHERE `Студенти`.`Група` = '" + + selectedGroup + "'"); tableView->setModel(queryModel); - for (int row = 0; row < queryModel->rowCount(); ++row) - { + for (int row = 0; row < queryModel->rowCount(); ++row) { studentList.append(tableView->model()->index(row, 0).data().toString() + " " + tableView->model()->index(row, 1).data().toString() + " " + tableView->model()->index(row, 2).data().toString()); } - QString selectedStudent = QInputDialog::getItem(this, tr("Оберіть студента"), - tr("Оберіть студента для запиту:"), studentList, - 0, false, &ok); - if (ok) - { + QString selectedStudent = QInputDialog::getItem(this, + tr("Оберіть студента"), + tr("Оберіть студента для запиту:"), + studentList, + 0, + false, + &ok); + if (ok) { QString dateStr = getDateWithDialog(); - if (dateStr not_eq "NULL") - { - strSqlQuery = "`Оцінки`.`Отримувач` = '" + selectedStudent + "' " - "AND `Оцінки`.`Дата виставлення` = '" + dateStr + "'"; + if (dateStr not_eq "NULL") { + strSqlQuery = "`Оцінки`.`Отримувач` = '" + selectedStudent + + "' " + "AND `Оцінки`.`Дата виставлення` = '" + + dateStr + "'"; emit sendFilter(strSqlQuery, "Дата виставлення"); } } } + } else { + QMessageBox::information(this, "", "Для цього запиту потрібно\nвідкрити таблицю оцінок"); } - else - { - QMessageBox::information(this,"","Для цього запиту потрібно\nвідкрити таблицю оцінок"); - } + */ } - -QString queryForm::getDateWithDialog() +QString QueryWindow::getDateWithDialog() { QDialog dialog(this); dialog.setWindowTitle("Оберіть дату"); @@ -163,39 +170,30 @@ QString queryForm::getDateWithDialog() mainLayout.addLayout(&buttonLayout); - QObject::connect(&okButton, &QPushButton::clicked, [&dateEdit, &dialog]() - { - dialog.accept(); - }); + QObject::connect(&okButton, &QPushButton::clicked, [&dateEdit, &dialog]() { dialog.accept(); }); - QObject::connect(&cancelButton, &QPushButton::clicked, [&dialog]() - { - dialog.reject(); - }); + QObject::connect(&cancelButton, &QPushButton::clicked, [&dialog]() { dialog.reject(); }); dialog.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); dialog.setFixedSize(dialog.sizeHint()); dialog.exec(); - if (dialog.result() == QDialog::Accepted) - { + if (dialog.result() == QDialog::Accepted) { return dateEdit.date().toString("yyyy-MM-dd"); - } - else - { + } else { return "NULL"; } } - -void queryForm::selectedGradeTable(int status) +void QueryWindow::selectedGradeTable(int status) { changedGradeTable = status; } -void queryForm::on_avgScorePushButton_clicked() +void QueryWindow::on_avgScorePushButton_clicked() { - QString query = "SELECT `Групи`.`Назва`, ROUND(AVG(CAST(`Оцінки`.`Оцінка` as float)), 2) as `Середня оцінка`" + QString query = "SELECT `Групи`.`Назва`, ROUND(AVG(CAST(`Оцінки`.`Оцінка` as float)), 2) as " + "`Середня оцінка`" "FROM `Групи`, `Студенти`, `Оцінки`" "WHERE `Групи`.`Назва` = `Студенти`.`Група`" "AND SUBSTRING_INDEX(`Оцінки`.`Отримувач`, ' ', 1) = `Студенти`.`Прізвище`" @@ -203,4 +201,3 @@ void queryForm::on_avgScorePushButton_clicked() emit sendQuery(query); } - diff --git a/src/queryform.h b/src/querywindow.h similarity index 75% rename from src/queryform.h rename to src/querywindow.h index 1db3f61..a6036e5 100644 --- a/src/queryform.h +++ b/src/querywindow.h @@ -1,5 +1,5 @@ -#ifndef QUERYFORM_H -#define QUERYFORM_H +#ifndef QUERYWINDOW_H +#define QUERYWINDOW_H #include @@ -7,13 +7,13 @@ namespace Ui { class queryForm; } -class queryForm : public QWidget +class QueryWindow : public QWidget { Q_OBJECT public: - explicit queryForm(QWidget *parent = nullptr); - ~queryForm(); + explicit QueryWindow(QWidget *parent = nullptr); + ~QueryWindow(); private slots: void on_mySQLPushButton_clicked(); @@ -38,4 +38,4 @@ public slots: void clearFilter(); }; -#endif // QUERYFORM_H +#endif // QUERYWINDOW_H diff --git a/src/queryform.ui b/src/querywindow.ui similarity index 100% rename from src/queryform.ui rename to src/querywindow.ui diff --git a/src/recordsForms/gradewindow.cpp b/src/recordsForms/gradewindow.cpp index d43f766..dcd9f21 100644 --- a/src/recordsForms/gradewindow.cpp +++ b/src/recordsForms/gradewindow.cpp @@ -2,13 +2,13 @@ #include "ui_gradewindow.h" #include -#include #include #include +#include -gradeWindow::gradeWindow(QWidget *parent) : - QWidget(parent), - ui(new Ui::gradeWindow) +gradeWindow::gradeWindow(QWidget *parent) + : QWidget(parent) + , ui(new Ui::gradeWindow) { ui->setupUi(this); setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); @@ -23,13 +23,11 @@ gradeWindow::gradeWindow(QWidget *parent) : isNewRow = false; } - gradeWindow::~gradeWindow() { delete ui; } - void gradeWindow::setBlackUI() { ui->mainImage->setPixmap(QPixmap(":/img/whiteMenuIcon/raitingIco.png")); @@ -39,7 +37,6 @@ void gradeWindow::setBlackUI() file.close(); } - void gradeWindow::setWhiteUI() { ui->mainImage->setPixmap(QPixmap(":/img/blackMenuIcon/raitingIco.png")); @@ -49,24 +46,21 @@ void gradeWindow::setWhiteUI() file.close(); } - void gradeWindow::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { setWhiteUI(); - } - else - { + } else { setBlackUI(); } } - void gradeWindow::setData(QString titleName, QStringList listData) { isNewRow = false; @@ -74,7 +68,7 @@ void gradeWindow::setData(QString titleName, QStringList listData) idRowEdit = listData[0].toInt(); titleName.remove(0, titleName.indexOf('.') + 2); - setWindowTitle("Редагування оцінки (" + titleName +")"); + setWindowTitle("Редагування оцінки (" + titleName + ")"); ui->gradeSpinBox->setFocus(); ui->subjectComboBox->setCurrentText(listData[1]); @@ -93,9 +87,9 @@ void gradeWindow::setData(QString titleName, QStringList listData) QString queryMy = "SELECT `Група`" "\nFROM `Студенти`" - "\nWHERE `Студенти`.`Прізвище` = '" + FIOStr[0] + "'" + - " AND `Студенти`.`Ім\'я` = '" + FIOStr[1] + "'" + - " AND `Студенти`.`По батькові` = '" + FIOStr[2] + "'"; + "\nWHERE `Студенти`.`Прізвище` = '" + + FIOStr[0] + "'" + " AND `Студенти`.`Ім\'я` = '" + FIOStr[1] + "'" + + " AND `Студенти`.`По батькові` = '" + FIOStr[2] + "'"; queryModel->setQuery(queryMy); tableView->setModel(queryModel); @@ -109,7 +103,6 @@ void gradeWindow::setData(QString titleName, QStringList listData) ui->okLabel->setVisible(false); } - void gradeWindow::setDataStudentComboBox(const QStringList list) { ui->whoTakeComboBox->clear(); @@ -118,8 +111,6 @@ void gradeWindow::setDataStudentComboBox(const QStringList list) ui->whoTakeComboBox->addItems(list); } - - void gradeWindow::setDataSubjectComboBox(const QStringList list) { ui->subjectComboBox->clear(); @@ -128,24 +119,17 @@ void gradeWindow::setDataSubjectComboBox(const QStringList list) ui->subjectComboBox->addItems(list); } - void gradeWindow::setTheme(const QString style) { - if (style == "black") - { + if (style == "black") { setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { setWhiteUI(); - } - else - { + } else { setSystemUI(); } } - void gradeWindow::newRow() { setWindowTitle("Додавання оцінки"); @@ -160,18 +144,16 @@ void gradeWindow::newRow() ui->gradeSpinBox->setValue(2); ui->typeGradeComboBox->setCurrentIndex(0); ui->takeDateEdit->setDate(QDate::currentDate()); - QString::number(ui->takeDateEdit->date().year()) + "." + - QString::number(ui->takeDateEdit->date().month()) + "." + - QString::number(ui->takeDateEdit->date().day()) + "."; + QString::number(ui->takeDateEdit->date().year()) + "." + + QString::number(ui->takeDateEdit->date().month()) + "." + + QString::number(ui->takeDateEdit->date().day()) + "."; } - void gradeWindow::on_cancelButton_clicked() { this->close(); } - QString gradeWindow::reverseDate(QString str) { QString newStrDate; @@ -190,7 +172,6 @@ QString gradeWindow::reverseDate(QString str) return newStrDate; } - QStringList gradeWindow::getCurrentData() { QStringList dataList; @@ -200,66 +181,48 @@ QStringList gradeWindow::getCurrentData() dataList << ui->whoTakeComboBox->currentText(); dataList << QString::number(ui->gradeSpinBox->value()); dataList << ui->typeGradeComboBox->currentText(); - dataList << QString::number(ui->takeDateEdit->date().year()) + "." + - QString::number(ui->takeDateEdit->date().month()) + "." + - QString::number(ui->takeDateEdit->date().day()) + "."; + dataList << QString::number(ui->takeDateEdit->date().year()) + "." + + QString::number(ui->takeDateEdit->date().month()) + "." + + QString::number(ui->takeDateEdit->date().day()) + "."; return dataList; - } - void gradeWindow::on_saveButton_clicked() { - if (ui->subjectComboBox->currentIndex() not_eq 0 and - ui->whoTakeComboBox->currentIndex() not_eq 0 and - ui->typeGradeComboBox->currentIndex() not_eq 0) - { - if (isNewRow) - { + if (ui->subjectComboBox->currentIndex() not_eq 0 + and ui->whoTakeComboBox->currentIndex() not_eq 0 + and ui->typeGradeComboBox->currentIndex() not_eq 0) { + if (isNewRow) { ui->okLabel->setText("Запис додано"); ui->okLabel->setVisible(true); emit sendData(getCurrentData(), true); - } - else - { + } else { ui->okLabel->setText("Запис збережено"); ui->okLabel->setVisible(true); emit sendData(getCurrentData(), false); } - } - else if (ui->subjectComboBox->currentIndex() == 0) - { + } else if (ui->subjectComboBox->currentIndex() == 0) { ui->subjectComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть з якого предмету оцінка"); - } - else if (ui->groupComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Оберіть з якого предмету оцінка"); + } else if (ui->groupComboBox->currentIndex() == 0) { ui->groupComboBox->setFocus(); - QMessageBox::critical(this,"","Для вибору отримувача оберіть спочатку його групу"); - } - else if (ui->whoTakeComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Для вибору отримувача оберіть спочатку його групу"); + } else if (ui->whoTakeComboBox->currentIndex() == 0) { ui->whoTakeComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть хто отримав оцінку"); - } - else if (ui->typeGradeComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Оберіть хто отримав оцінку"); + } else if (ui->typeGradeComboBox->currentIndex() == 0) { ui->typeGradeComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть тип оцінки"); + QMessageBox::critical(this, "", "Оберіть тип оцінки"); } } - void gradeWindow::on_groupComboBox_currentIndexChanged(int index) { - if (index == 0) - { + if (index == 0) { ui->whoTakeComboBox->setCurrentIndex(0); ui->whoTakeComboBox->setEnabled(false); - } - else - { + } else { ui->whoTakeComboBox->setEnabled(true); QStringList studentList; @@ -268,22 +231,20 @@ void gradeWindow::on_groupComboBox_currentIndexChanged(int index) queryModel->setQuery("SELECT `Прізвище`, `Ім'я`, `По батькові`" "FROM `Студенти`" - "WHERE `Студенти`.`Група` = '" + ui->groupComboBox->currentText() + "'"); + "WHERE `Студенти`.`Група` = '" + + ui->groupComboBox->currentText() + "'"); tableView->setModel(queryModel); - for (int row = 0; row < queryModel->rowCount(); ++row) - { - studentList.append(tableView->model()->index(row, 0).data().toString() + " " + - tableView->model()->index(row, 1).data().toString() + " " + - tableView->model()->index(row, 2).data().toString()); + for (int row = 0; row < queryModel->rowCount(); ++row) { + studentList.append(tableView->model()->index(row, 0).data().toString() + " " + + tableView->model()->index(row, 1).data().toString() + " " + + tableView->model()->index(row, 2).data().toString()); } setDataStudentComboBox(studentList); - } } - void gradeWindow::setGroupComboBox() { ui->groupComboBox->clear(); @@ -298,12 +259,9 @@ void gradeWindow::setGroupComboBox() "FROM `Групи`"); tableView->setModel(queryModel); - for (int row = 0; row < queryModel->rowCount(); ++row) - { + for (int row = 0; row < queryModel->rowCount(); ++row) { listGroup.append(tableView->model()->index(row, 0).data().toString()); } ui->groupComboBox->addItems(listGroup); } - - diff --git a/src/recordsForms/groupwindow.cpp b/src/recordsForms/groupwindow.cpp index 75610b8..9683a24 100644 --- a/src/recordsForms/groupwindow.cpp +++ b/src/recordsForms/groupwindow.cpp @@ -6,9 +6,9 @@ #include #include -groupWindow::groupWindow(QWidget *parent) : - QWidget(parent), - ui(new Ui::groupWindow) +groupWindow::groupWindow(QWidget *parent) + : QWidget(parent) + , ui(new Ui::groupWindow) { ui->setupUi(this); setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); @@ -23,13 +23,11 @@ groupWindow::groupWindow(QWidget *parent) : isNewRow = false; } - groupWindow::~groupWindow() { delete ui; } - void groupWindow::setBlackUI() { ui->mainImage->setPixmap(QPixmap(":/img/whiteMenuIcon/groupIco.png")); @@ -39,7 +37,6 @@ void groupWindow::setBlackUI() file.close(); } - void groupWindow::setWhiteUI() { ui->mainImage->setPixmap(QPixmap(":/img/blackMenuIcon/groupIco.png")); @@ -49,31 +46,28 @@ void groupWindow::setWhiteUI() file.close(); } - void groupWindow::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { setWhiteUI(); - } - else - { + } else { setBlackUI(); } } - void groupWindow::setData(QString titleName, QStringList listData) { isNewRow = false; idRowEdit = listData[0].toInt(); titleName.remove(0, titleName.indexOf('.') + 2); - setWindowTitle("Редагування групи (" + titleName +")"); + setWindowTitle("Редагування групи (" + titleName + ")"); ui->nameLineEdit->setFocus(); @@ -87,7 +81,6 @@ void groupWindow::setData(QString titleName, QStringList listData) ui->okLabel->setVisible(false); } - void groupWindow::setDataCuratorComboBox(const QStringList list) { ui->curatorComboBox->clear(); @@ -96,7 +89,6 @@ void groupWindow::setDataCuratorComboBox(const QStringList list) ui->curatorComboBox->addItems(list); } - void groupWindow::setDataHeadManComboBox(QString group) { ui->headManComboBox->clear(); @@ -111,41 +103,32 @@ void groupWindow::setDataHeadManComboBox(QString group) virualQueryModel->setQuery("SELECT `Прізвище`, `Ім'я`, `По батькові`" "FROM `Студенти`" - "WHERE `Студенти`.`Група` = '" + group + "'"); + "WHERE `Студенти`.`Група` = '" + + group + "'"); - if (virualQueryModel->rowCount() <= 0 ) - { + if (virualQueryModel->rowCount() <= 0) { ui->headManComboBox->addItem("Студентів поки що нема"); ui->headManComboBox->setCurrentIndex(2); - } - else - { + } else { virtualTable->setModel(virualQueryModel); - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { - studentList.append(virtualTable->model()->index(row, 0).data().toString() + " " + - virtualTable->model()->index(row, 1).data().toString() + " " + - virtualTable->model()->index(row, 2).data().toString()); + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { + studentList.append(virtualTable->model()->index(row, 0).data().toString() + " " + + virtualTable->model()->index(row, 1).data().toString() + " " + + virtualTable->model()->index(row, 2).data().toString()); } ui->headManComboBox->addItems(studentList); } } - void groupWindow::setTheme(const QString style) { - if (style == "black") - { + if (style == "black") { setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { setWhiteUI(); - } - else - { + } else { setSystemUI(); } } @@ -165,62 +148,45 @@ void groupWindow::newRow() ui->headManComboBox->setCurrentIndex(0); } - void groupWindow::on_cancelButton_clicked() { this->close(); } - void groupWindow::on_saveButton_clicked() { - if (not ui->nameLineEdit->text().isEmpty() and - ui->specialComboBox->currentIndex() not_eq 0 and - ui->curatorComboBox->currentIndex() not_eq 0 and - ui->headManComboBox->currentIndex() not_eq 0) - { - if (isNewRow) - { + if (not ui->nameLineEdit->text().isEmpty() and ui->specialComboBox->currentIndex() not_eq 0 + and ui->curatorComboBox->currentIndex() not_eq 0 + and ui->headManComboBox->currentIndex() not_eq 0) { + if (isNewRow) { ui->okLabel->setText("Запис додано"); ui->okLabel->setVisible(true); emit sendData(getCurrentData(), true); - } - else - { + } else { ui->okLabel->setText("Запис збережено"); ui->okLabel->setVisible(true); emit sendData(getCurrentData(), false); } - } - else if (ui->nameLineEdit->text().isEmpty()) - { + } else if (ui->nameLineEdit->text().isEmpty()) { ui->nameLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть назву групи"); - } - else if (ui->specialComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Введіть назву групи"); + } else if (ui->specialComboBox->currentIndex() == 0) { ui->specialComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть спеціальність групи"); - } - else if (ui->curatorComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Оберіть спеціальність групи"); + } else if (ui->curatorComboBox->currentIndex() == 0) { ui->curatorComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть куратора групи"); - } - else if (ui->headManComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Оберіть куратора групи"); + } else if (ui->headManComboBox->currentIndex() == 0) { ui->headManComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть старосту групи"); + QMessageBox::critical(this, "", "Оберіть старосту групи"); } } - void groupWindow::on_startStudySpinBox_valueChanged(int arg1) { ui->endStudySpinBox->setMinimum(arg1 + 1); } - QStringList groupWindow::getCurrentData() { QStringList dataList; @@ -235,4 +201,3 @@ QStringList groupWindow::getCurrentData() return dataList; } - diff --git a/src/recordsForms/studentwindow.cpp b/src/recordsForms/studentwindow.cpp index 4f5c5e1..500603e 100644 --- a/src/recordsForms/studentwindow.cpp +++ b/src/recordsForms/studentwindow.cpp @@ -4,9 +4,9 @@ #include #include -studentWindow::studentWindow(QWidget *parent) : - QWidget(parent), - ui(new Ui::studentWindow) +studentWindow::studentWindow(QWidget *parent) + : QWidget(parent) + , ui(new Ui::studentWindow) { ui->setupUi(this); setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); @@ -26,13 +26,11 @@ studentWindow::studentWindow(QWidget *parent) : isNewRow = false; } - studentWindow::~studentWindow() { delete ui; } - void studentWindow::setBlackUI() { ui->mainImage->setPixmap(QPixmap(":/img/whiteMenuIcon/studentsIco.png")); @@ -42,7 +40,6 @@ void studentWindow::setBlackUI() file.close(); } - void studentWindow::setWhiteUI() { ui->mainImage->setPixmap(QPixmap(":/img/blackMenuIcon/studentsIco.png")); @@ -52,31 +49,28 @@ void studentWindow::setWhiteUI() file.close(); } - void studentWindow::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { setWhiteUI(); - } - else - { + } else { setBlackUI(); } } - void studentWindow::setData(QString titleName, QStringList listData) { isNewRow = false; idRowEdit = listData[0].toInt(); titleName.remove(0, titleName.indexOf('.') + 2); - setWindowTitle("Редагування студента (" + titleName +")"); + setWindowTitle("Редагування студента (" + titleName + ")"); ui->lastNameLineEdit->setFocus(); @@ -96,7 +90,6 @@ void studentWindow::setData(QString titleName, QStringList listData) ui->lastNameLineEdit->setFocus(); } - void studentWindow::setComboBox(const QStringList groupList) { ui->groupComboBox->clear(); @@ -105,24 +98,17 @@ void studentWindow::setComboBox(const QStringList groupList) ui->groupComboBox->addItems(groupList); } - void studentWindow::setTheme(const QString style) { - if (style == "black") - { + if (style == "black") { setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { setWhiteUI(); - } - else - { + } else { setSystemUI(); } } - void studentWindow::newRow() { setWindowTitle("Додавання студента"); @@ -141,13 +127,11 @@ void studentWindow::newRow() ui->nalogLineEdit->clear(); } - void studentWindow::on_cancelButton_clicked() { this->close(); } - QString studentWindow::reverseDate(QString str) { QString newStrDate; @@ -166,7 +150,6 @@ QString studentWindow::reverseDate(QString str) return newStrDate; } - QValidator *studentWindow::getValidatorPass() { QRegularExpression passRE("^\\d{9}"); @@ -174,7 +157,6 @@ QValidator *studentWindow::getValidatorPass() return passValidator; } - QStringList studentWindow::getCurrentData() { QStringList dataList; @@ -184,9 +166,9 @@ QStringList studentWindow::getCurrentData() dataList << ui->nameLineEdit->text(); dataList << ui->surnameLineEdit->text(); dataList << ui->numberLineEdit->text(); - dataList << QString::number(ui->birthDayDataEdit->date().year()) + "." + - QString::number(ui->birthDayDataEdit->date().month()) + "." + - QString::number(ui->birthDayDataEdit->date().day()) + "."; + dataList << QString::number(ui->birthDayDataEdit->date().year()) + "." + + QString::number(ui->birthDayDataEdit->date().month()) + "." + + QString::number(ui->birthDayDataEdit->date().day()) + "."; dataList << ui->addressLineEdit->text(); dataList << ui->passLineEdit->text(); dataList << ui->groupComboBox->currentText(); @@ -195,79 +177,55 @@ QStringList studentWindow::getCurrentData() return dataList; } - void studentWindow::on_numberLineEdit_textChanged(const QString &arg1) { - if (arg1.isEmpty()) - { + if (arg1.isEmpty()) { ui->numberLineEdit->setText("+380"); } } - void studentWindow::on_saveButton_clicked() { - if (not ui->lastNameLineEdit->text().isEmpty() and - not ui->nameLineEdit->text().isEmpty() and - not ui->surnameLineEdit->text().isEmpty() and - ui->numberLineEdit->text().length() == 13 and - not ui->addressLineEdit->text().isEmpty() and - ui->passLineEdit->text().length() == 9 and - ui->nalogLineEdit->text().length() == 9 and - ui->groupComboBox->currentIndex() not_eq 0) - { - if (isNewRow) - { + if (not ui->lastNameLineEdit->text().isEmpty() and not ui->nameLineEdit->text().isEmpty() + and not ui->surnameLineEdit->text().isEmpty() and ui->numberLineEdit->text().length() == 13 + and not ui->addressLineEdit->text().isEmpty() and ui->passLineEdit->text().length() == 9 + and ui->nalogLineEdit->text().length() == 9 + and ui->groupComboBox->currentIndex() not_eq 0) { + if (isNewRow) { ui->okLabel->setText("Запис додано"); ui->okLabel->setVisible(true); emit sendData(getCurrentData(), true); - } - else - { + } else { ui->okLabel->setText("Запис збережено"); ui->okLabel->setVisible(true); emit sendData(getCurrentData(), false); } - } - else if (ui->lastNameLineEdit->text().isEmpty()) - { + } else if (ui->lastNameLineEdit->text().isEmpty()) { ui->lastNameLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть прізвище"); - } - else if (ui->nameLineEdit->text().isEmpty()) - { + QMessageBox::critical(this, "", "Введіть прізвище"); + } else if (ui->nameLineEdit->text().isEmpty()) { ui->nameLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть ім'я"); - } - else if (ui->surnameLineEdit->text().isEmpty()) - { + QMessageBox::critical(this, "", "Введіть ім'я"); + } else if (ui->surnameLineEdit->text().isEmpty()) { ui->surnameLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть по батькові"); - } - else if (ui->numberLineEdit->text().length() not_eq 13) - { + QMessageBox::critical(this, "", "Введіть по батькові"); + } else if (ui->numberLineEdit->text().length() not_eq 13) { ui->numberLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть коректний номер телефону у форматі:\n" - "(+3800000000000)"); - } - else if (ui->addressLineEdit->text().isEmpty()) - { + QMessageBox::critical(this, + "", + "Введіть коректний номер телефону у форматі:\n" + "(+3800000000000)"); + } else if (ui->addressLineEdit->text().isEmpty()) { ui->addressLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть адресу проживання"); - } - else if (ui->passLineEdit->text().length() not_eq 9 ) - { + QMessageBox::critical(this, "", "Введіть адресу проживання"); + } else if (ui->passLineEdit->text().length() not_eq 9) { ui->passLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть коректний номер паспорту студента"); - } - else if (ui->nalogLineEdit->text().length() not_eq 9) - { + QMessageBox::critical(this, "", "Введіть коректний номер паспорту студента"); + } else if (ui->nalogLineEdit->text().length() not_eq 9) { ui->nalogLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть коректний ІНН студента"); - } - else if (ui->groupComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Введіть коректний ІНН студента"); + } else if (ui->groupComboBox->currentIndex() == 0) { ui->groupComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть групу студента"); + QMessageBox::critical(this, "", "Оберіть групу студента"); } } diff --git a/src/recordsForms/studentwindow.h b/src/recordsForms/studentwindow.h index b4c7402..602a8a8 100644 --- a/src/recordsForms/studentwindow.h +++ b/src/recordsForms/studentwindow.h @@ -1,8 +1,8 @@ #ifndef STUDENTWINDOW_H #define STUDENTWINDOW_H -#include #include +#include namespace Ui { class studentWindow; diff --git a/src/recordsForms/subjectwindow.cpp b/src/recordsForms/subjectwindow.cpp index 11b53c6..2fc4f63 100644 --- a/src/recordsForms/subjectwindow.cpp +++ b/src/recordsForms/subjectwindow.cpp @@ -4,9 +4,9 @@ #include #include -subjectWindow::subjectWindow(QWidget *parent) : - QWidget(parent), - ui(new Ui::subjectWindow) +subjectWindow::subjectWindow(QWidget *parent) + : QWidget(parent) + , ui(new Ui::subjectWindow) { ui->setupUi(this); setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); @@ -21,19 +21,20 @@ subjectWindow::subjectWindow(QWidget *parent) : ui->okLabel->setVisible(false); isNewRow = false; - connect(ui->lectureTimeSpinBox, &QSpinBox::valueChanged, this, &subjectWindow::setCurrentAllTime); + connect(ui->lectureTimeSpinBox, + &QSpinBox::valueChanged, + this, + &subjectWindow::setCurrentAllTime); connect(ui->labTimeSpinBox, &QSpinBox::valueChanged, this, &subjectWindow::setCurrentAllTime); connect(ui->seminarSpinBox, &QSpinBox::valueChanged, this, &subjectWindow::setCurrentAllTime); connect(ui->soloWorkSpinBox, &QSpinBox::valueChanged, this, &subjectWindow::setCurrentAllTime); } - subjectWindow::~subjectWindow() { delete ui; } - void subjectWindow::setBlackUI() { ui->mainImage->setPixmap(QPixmap(":/img/whiteMenuIcon/subjectIco.png")); @@ -43,7 +44,6 @@ void subjectWindow::setBlackUI() file.close(); } - void subjectWindow::setWhiteUI() { ui->mainImage->setPixmap(QPixmap(":/img/blackMenuIcon/subjectIco.png")); @@ -53,31 +53,28 @@ void subjectWindow::setWhiteUI() file.close(); } - void subjectWindow::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { setWhiteUI(); - } - else - { + } else { setBlackUI(); } } - void subjectWindow::setData(QString titleName, QStringList listData) { isNewRow = false; idRowEdit = listData[0].toInt(); titleName.remove(0, titleName.indexOf('.') + 2); - setWindowTitle("Редагування предмета (" + titleName +")"); + setWindowTitle("Редагування предмета (" + titleName + ")"); ui->nameLineEdit->setFocus(); @@ -95,7 +92,6 @@ void subjectWindow::setData(QString titleName, QStringList listData) ui->okLabel->setVisible(false); } - void subjectWindow::setTeacherComboBox(const QStringList teacherList) { ui->teacherComboBox->clear(); @@ -104,24 +100,17 @@ void subjectWindow::setTeacherComboBox(const QStringList teacherList) ui->teacherComboBox->addItems(teacherList); } - void subjectWindow::setTheme(const QString style) { - if (style == "black") - { + if (style == "black") { setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { setWhiteUI(); - } - else - { + } else { setSystemUI(); } } - void subjectWindow::newRow() { setWindowTitle("Додавання предмета"); @@ -141,65 +130,46 @@ void subjectWindow::newRow() ui->controlComboBox->setCurrentIndex(0); } - void subjectWindow::on_cancelButton_clicked() { this->close(); } - void subjectWindow::on_saveButton_clicked() { - if (not ui->nameLineEdit->text().isEmpty() and - ui->typeComboBox->currentIndex() not_eq 0 and - ui->teacherComboBox->currentIndex() not_eq 0 and - ui->controlComboBox->currentIndex() not_eq 0) - { - if (isNewRow) - { + if (not ui->nameLineEdit->text().isEmpty() and ui->typeComboBox->currentIndex() not_eq 0 + and ui->teacherComboBox->currentIndex() not_eq 0 + and ui->controlComboBox->currentIndex() not_eq 0) { + if (isNewRow) { ui->okLabel->setText("Запис додано"); ui->okLabel->setVisible(true); emit sendData(getCurrentData(), true); - } - else - { + } else { ui->okLabel->setText("Запис збережено"); ui->okLabel->setVisible(true); emit sendData(getCurrentData(), false); } - } - else if (ui->nameLineEdit->text().isEmpty()) - { + } else if (ui->nameLineEdit->text().isEmpty()) { ui->nameLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть назву предмета"); - } - else if (ui->typeComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Введіть назву предмета"); + } else if (ui->typeComboBox->currentIndex() == 0) { ui->typeComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть тип предмету"); - } - else if (ui->teacherComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Оберіть тип предмету"); + } else if (ui->teacherComboBox->currentIndex() == 0) { ui->teacherComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть викладача предмету"); - } - else if (ui->controlComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Оберіть викладача предмету"); + } else if (ui->controlComboBox->currentIndex() == 0) { ui->controlComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть семестровий контроль з предмету"); + QMessageBox::critical(this, "", "Оберіть семестровий контроль з предмету"); } } - void subjectWindow::setCurrentAllTime() { - ui->allTimeSpinBox->setValue(ui->lectureTimeSpinBox->value() - + ui->labTimeSpinBox->value() - + ui->seminarSpinBox->value() - + ui->soloWorkSpinBox->value()); + ui->allTimeSpinBox->setValue(ui->lectureTimeSpinBox->value() + ui->labTimeSpinBox->value() + + ui->seminarSpinBox->value() + ui->soloWorkSpinBox->value()); } - QStringList subjectWindow::getCurrentData() { QStringList dataList; diff --git a/src/recordsForms/teacherwindow.cpp b/src/recordsForms/teacherwindow.cpp index c64b3cb..93ec5cd 100644 --- a/src/recordsForms/teacherwindow.cpp +++ b/src/recordsForms/teacherwindow.cpp @@ -4,9 +4,9 @@ #include #include -teacherWindow::teacherWindow(QWidget *parent) : - QWidget(parent), - ui(new Ui::teacherWindow) +teacherWindow::teacherWindow(QWidget *parent) + : QWidget(parent) + , ui(new Ui::teacherWindow) { ui->setupUi(this); setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); @@ -25,13 +25,11 @@ teacherWindow::teacherWindow(QWidget *parent) : isNewRow = false; } - teacherWindow::~teacherWindow() { delete ui; } - void teacherWindow::setBlackUI() { ui->mainImage->setPixmap(QPixmap(":/img/whiteMenuIcon/teachersIco.png")); @@ -41,7 +39,6 @@ void teacherWindow::setBlackUI() file.close(); } - void teacherWindow::setWhiteUI() { ui->mainImage->setPixmap(QPixmap(":/img/blackMenuIcon/teachersIco.png")); @@ -51,31 +48,28 @@ void teacherWindow::setWhiteUI() file.close(); } - void teacherWindow::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { setWhiteUI(); - } - else - { + } else { setBlackUI(); } } - void teacherWindow::setData(QString titleName, QStringList listData) { isNewRow = false; idRowEdit = listData[0].toInt(); titleName.remove(0, titleName.indexOf('.') + 2); - setWindowTitle("Редагування викладача (" + titleName +")"); + setWindowTitle("Редагування викладача (" + titleName + ")"); ui->lastNameLineEdit->setFocus(); ui->lastNameLineEdit->setFocus(); @@ -93,24 +87,17 @@ void teacherWindow::setData(QString titleName, QStringList listData) ui->lastNameLineEdit->setFocus(); } - void teacherWindow::setTheme(const QString style) { - if (style == "black") - { + if (style == "black") { setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { setWhiteUI(); - } - else - { + } else { setSystemUI(); } } - void teacherWindow::newRow() { setWindowTitle("Додавання викладача"); @@ -128,13 +115,11 @@ void teacherWindow::newRow() ui->specialComboBox->setCurrentIndex(0); } - void teacherWindow::on_cancelButton_clicked() { this->close(); } - QString teacherWindow::reverseDate(QString str) { QString newStrDate; @@ -153,7 +138,6 @@ QString teacherWindow::reverseDate(QString str) return newStrDate; } - QStringList teacherWindow::getCurrentData() { QStringList dataList; @@ -163,9 +147,9 @@ QStringList teacherWindow::getCurrentData() dataList << ui->nameLineEdit->text(); dataList << ui->surnameLineEdit->text(); dataList << ui->numberLineEdit->text(); - dataList << QString::number(ui->birthDayDataEdit->date().year()) + "." + - QString::number(ui->birthDayDataEdit->date().month()) + "." + - QString::number(ui->birthDayDataEdit->date().day()) + "."; + dataList << QString::number(ui->birthDayDataEdit->date().year()) + "." + + QString::number(ui->birthDayDataEdit->date().month()) + "." + + QString::number(ui->birthDayDataEdit->date().day()) + "."; dataList << ui->addressLineEdit->text(); dataList << ui->categoryComboBox->currentText(); dataList << ui->specialComboBox->currentText(); @@ -173,74 +157,52 @@ QStringList teacherWindow::getCurrentData() return dataList; } - void teacherWindow::on_numberLineEdit_textChanged(const QString &arg1) { - if (arg1.isEmpty()) - { + if (arg1.isEmpty()) { ui->numberLineEdit->setText("+380"); } } - void teacherWindow::on_saveButton_clicked() { - if (not ui->lastNameLineEdit->text().isEmpty() and - not ui->nameLineEdit->text().isEmpty() and - not ui->surnameLineEdit->text().isEmpty() and - ui->numberLineEdit->text().length() == 13 and - not ui->addressLineEdit->text().isEmpty() and - ui->categoryComboBox->currentIndex() not_eq 0 and - ui->specialComboBox->currentIndex() not_eq 0) - { - if (isNewRow) - { + if (not ui->lastNameLineEdit->text().isEmpty() and not ui->nameLineEdit->text().isEmpty() + and not ui->surnameLineEdit->text().isEmpty() and ui->numberLineEdit->text().length() == 13 + and not ui->addressLineEdit->text().isEmpty() + and ui->categoryComboBox->currentIndex() not_eq 0 + and ui->specialComboBox->currentIndex() not_eq 0) { + if (isNewRow) { ui->okLabel->setText("Запис додано"); ui->okLabel->setVisible(true); emit sendData(getCurrentData(), true); - } - else - { + } else { ui->okLabel->setText("Запис збережено"); ui->okLabel->setVisible(true); emit sendData(getCurrentData(), false); } - } - else if (ui->lastNameLineEdit->text().isEmpty()) - { + } else if (ui->lastNameLineEdit->text().isEmpty()) { ui->lastNameLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть прізвище"); - } - else if (ui->nameLineEdit->text().isEmpty()) - { + QMessageBox::critical(this, "", "Введіть прізвище"); + } else if (ui->nameLineEdit->text().isEmpty()) { ui->nameLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть ім'я"); - } - else if (ui->surnameLineEdit->text().isEmpty()) - { + QMessageBox::critical(this, "", "Введіть ім'я"); + } else if (ui->surnameLineEdit->text().isEmpty()) { ui->surnameLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть по батькові"); - } - else if (ui->numberLineEdit->text().length() not_eq 13) - { + QMessageBox::critical(this, "", "Введіть по батькові"); + } else if (ui->numberLineEdit->text().length() not_eq 13) { ui->numberLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть коректний номер телефону у форматі:\n" - "(+3800000000000)"); - } - else if (ui->addressLineEdit->text().isEmpty()) - { + QMessageBox::critical(this, + "", + "Введіть коректний номер телефону у форматі:\n" + "(+3800000000000)"); + } else if (ui->addressLineEdit->text().isEmpty()) { ui->addressLineEdit->setFocus(); - QMessageBox::critical(this,"","Введіть адресу проживання"); - } - else if (ui->categoryComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Введіть адресу проживання"); + } else if (ui->categoryComboBox->currentIndex() == 0) { ui->categoryComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть категорію вчителя"); - } - else if (ui->specialComboBox->currentIndex() == 0) - { + QMessageBox::critical(this, "", "Оберіть категорію вчителя"); + } else if (ui->specialComboBox->currentIndex() == 0) { ui->specialComboBox->setFocus(); - QMessageBox::critical(this,"","Оберіть спеціальність вчителя"); + QMessageBox::critical(this, "", "Оберіть спеціальність вчителя"); } } - diff --git a/src/recources.qrc b/src/recources.qrc index 58037e1..99a5c2a 100644 --- a/src/recources.qrc +++ b/src/recources.qrc @@ -4,26 +4,26 @@ img/blackMenuIcon/cloud.png img/blackMenuIcon/downArrow.png img/blackMenuIcon/downArrowDisabled.png - img/blackMenuIcon/groupIco.png + img/blackMenuIcon/groupsIco.png img/blackMenuIcon/noWatchPass.png - img/blackMenuIcon/raitingIco.png - img/blackMenuIcon/subjectIco.png + img/blackMenuIcon/gradesIco.png + img/blackMenuIcon/subjectsIco.png img/blackMenuIcon/teachersIco.png img/blackMenuIcon/watchPass.png img/blueMenuIcon/deleteRecord.png img/blueMenuIcon/editRecord.png - img/blueMenuIcon/groupIco.png + img/blueMenuIcon/groupsIco.png img/blueMenuIcon/newRecord.png - img/blueMenuIcon/raitingIco.png - img/blueMenuIcon/settingIco.png + img/blueMenuIcon/gradesIco.png + img/blueMenuIcon/settingsIco.png img/blueMenuIcon/studentsIco.png - img/blueMenuIcon/subjectIco.png + img/blueMenuIcon/subjectsIco.png img/blueMenuIcon/teachersIco.png img/reportsIcon/reportCurrentTable.png - img/reportsIcon/reportGroup.png - img/reportsIcon/reportItem.png - img/reportsIcon/reportRaiting.png - img/reportsIcon/reportStudent.png + img/reportsIcon/reportGroups.png + img/reportsIcon/reportSubjects.png + img/reportsIcon/reportGrades.png + img/reportsIcon/reportStudents.png img/reportsIcon/reportTeachers.png img/settingIcon/settingBlackUIIco.png img/settingIcon/settingSystemUIICo.png @@ -31,18 +31,18 @@ img/whiteMenuIcon/clearLoginIco.png img/whiteMenuIcon/cloud.png img/whiteMenuIcon/downArrow.png - img/whiteMenuIcon/groupIco.png + img/whiteMenuIcon/groupsIco.png img/whiteMenuIcon/noWatchPass.png - img/whiteMenuIcon/raitingIco.png - img/whiteMenuIcon/settingIco.png - img/whiteMenuIcon/subjectIco.png + img/whiteMenuIcon/gradesIco.png + img/whiteMenuIcon/settingsIco.png + img/whiteMenuIcon/subjectsIco.png img/whiteMenuIcon/teachersIco.png img/whiteMenuIcon/watchPass.png img/AppIcon.icns - styles/black/appSetting/appSetting.qss + styles/black/AppSettingsWindow/AppSettingsWindow.qss styles/black/mainWindow/mainWindow.qss styles/black/mainWindow/selectButtonTableStyle.qss - styles/white/appSetting/appSetting.qss + styles/white/AppSettingsWindow/AppSettingsWindow.qss styles/white/mainWindow/mainWindow.qss styles/white/mainWindow/selectButtonTableStyle.qss img/blueMenuIcon/filterIco.png @@ -74,34 +74,34 @@ styles/white/aboutApp/aboutApp.qss img/blackActionsIcon/deleteRecord.png img/blackActionsIcon/editRecord.png - img/blackActionsIcon/groupIco.png + img/blackActionsIcon/groupsIco.png img/blackActionsIcon/newRecord.png - img/blackActionsIcon/raitingIco.png + img/blackActionsIcon/gradesIco.png img/blackActionsIcon/reportCurrentTable.png - img/blackActionsIcon/reportGroup.png - img/blackActionsIcon/reportItem.png - img/blackActionsIcon/reportRaiting.png - img/blackActionsIcon/reportStudent.png + img/blackActionsIcon/reportGroups.png + img/blackActionsIcon/reportSubjects.png + img/blackActionsIcon/reportGrades.png + img/blackActionsIcon/reportStudents.png img/blackActionsIcon/reportTeachers.png - img/blackActionsIcon/subjectIco.png + img/blackActionsIcon/subjectsIco.png img/blackActionsIcon/teachersIco.png img/whiteActionsIcon/deleteRecord.png img/whiteActionsIcon/editRecord.png - img/whiteActionsIcon/groupIco.png + img/whiteActionsIcon/groupsIco.png img/whiteActionsIcon/newRecord.png - img/whiteActionsIcon/raitingIco.png + img/whiteActionsIcon/gradesIco.png img/whiteActionsIcon/reportCurrentTable.png - img/whiteActionsIcon/reportGroup.png - img/whiteActionsIcon/reportItem.png - img/whiteActionsIcon/reportRaiting.png - img/whiteActionsIcon/reportStudent.png + img/whiteActionsIcon/reportGroups.png + img/whiteActionsIcon/reportSubjects.png + img/whiteActionsIcon/reportGrades.png + img/whiteActionsIcon/reportStudents.png img/whiteActionsIcon/reportTeachers.png - img/whiteActionsIcon/subjectIco.png + img/whiteActionsIcon/subjectsIco.png img/whiteActionsIcon/teachersIco.png styles/white/recordsForms/recordsForms.qss styles/black/recordsForms/recordsForms.qss - styles/white/authorizationForm/authorizationForm.qss - styles/black/authorizationForm/authorizationForm.qss + styles/white/LoginWindow/LoginWindow.qss + styles/black/LoginWindow/LoginWindow.qss img/whiteMenuIcon/studentsIco.png img/blackActionsIcon/studentsIco.png img/whiteActionsIcon/studentsIco.png diff --git a/src/statisticsForms/gradestatistics.cpp b/src/statisticsForms/gradestatistics.cpp index 6de854e..8c86f56 100644 --- a/src/statisticsForms/gradestatistics.cpp +++ b/src/statisticsForms/gradestatistics.cpp @@ -1,20 +1,20 @@ #include "gradestatistics.h" #include "ui_gradestatistics.h" -#include -#include +#include #include +#include #include -#include -#include +#include #include #include -#include #include +#include +#include -gradeStatistics::gradeStatistics(QWidget *parent) : - QWidget(parent), - ui(new Ui::gradeStatistics) +gradeStatistics::gradeStatistics(QWidget *parent) + : QWidget(parent) + , ui(new Ui::gradeStatistics) { ui->setupUi(this); @@ -48,7 +48,6 @@ gradeStatistics::~gradeStatistics() delete ui; } - void gradeStatistics::setBlackUI() { QFile file(":/styles/black/statisticsForms/statisticsForms.qss"); @@ -57,10 +56,9 @@ void gradeStatistics::setBlackUI() file.close(); chartView->chart()->setTheme(QChart::ChartThemeDark); - chartView->chart()->setBackgroundBrush(QColor (49, 51, 52)); + chartView->chart()->setBackgroundBrush(QColor(49, 51, 52)); } - void gradeStatistics::setWhiteUI() { QFile file(":/styles/white/statisticsForms/statisticsForms.qss"); @@ -69,27 +67,24 @@ void gradeStatistics::setWhiteUI() file.close(); chartView->chart()->setTheme(QChart::ChartThemeLight); - chartView->chart()->setBackgroundBrush(QColor (255, 255, 255)); + chartView->chart()->setBackgroundBrush(QColor(255, 255, 255)); } - void gradeStatistics::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { setWhiteUI(); - } - else - { + } else { setBlackUI(); } } - void gradeStatistics::updateTeacherComboBox() { setWindowTitle("Статистика оцінок"); @@ -101,11 +96,11 @@ void gradeStatistics::updateTeacherComboBox() virualQueryModel->setQuery("SELECT `Прізвище`, `Ім\'я`, `По батькові`" "FROM `Викладачі`" - "WHERE `Викладачі`.`Категорія` = '" + ui->categoryComboBox->currentText() + "'"); + "WHERE `Викладачі`.`Категорія` = '" + + ui->categoryComboBox->currentText() + "'"); virtualTable->setModel(virualQueryModel); - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { teacherList.append(virtualTable->model()->index(row, 0).data().toString() + " " + virtualTable->model()->index(row, 1).data().toString() + " " + virtualTable->model()->index(row, 2).data().toString()); @@ -117,7 +112,6 @@ void gradeStatistics::updateTeacherComboBox() ui->teacherComboBox->addItems(teacherList); } - void gradeStatistics::clearTeacherComboBox() { setWindowTitle("Статистика оцінок"); @@ -125,7 +119,6 @@ void gradeStatistics::clearTeacherComboBox() ui->teacherComboBox->addItem("Оберіть викладача"); } - void gradeStatistics::clearSubjectComboBox() { setWindowTitle("Статистика оцінок"); @@ -133,7 +126,6 @@ void gradeStatistics::clearSubjectComboBox() ui->subjectComboBox->addItem("Оберіть предмет"); } - void gradeStatistics::clearPieChart() { setWindowTitle("Статистика оцінок"); @@ -141,50 +133,36 @@ void gradeStatistics::clearPieChart() series->append("Приклад", 1); } - void gradeStatistics::setTheme(const QString &style) { - if (style == "black") - { + if (style == "black") { setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { setWhiteUI(); - } - else - { + } else { setSystemUI(); } } - void gradeStatistics::on_categoryComboBox_currentIndexChanged(int index) { - if (index == 0) - { + if (index == 0) { ui->teacherComboBox->setEnabled(false); ui->subjectComboBox->setEnabled(false); clearTeacherComboBox(); clearSubjectComboBox(); - } - else if (index > 0) - { + } else if (index > 0) { updateTeacherComboBox(); } } - void gradeStatistics::on_teacherComboBox_currentIndexChanged(int index) { - if (index == 0) - { + if (index == 0) { ui->subjectComboBox->setEnabled(false); clearSubjectComboBox(); - } - else if (index > 0) - { + } else if (index > 0) { ui->subjectComboBox->setEnabled(true); QStringList subjectList; @@ -193,19 +171,15 @@ void gradeStatistics::on_teacherComboBox_currentIndexChanged(int index) virualQueryModel->setQuery("SELECT `Назва`" "FROM `Предмети`" - "WHERE `Предмети`.`Викладач` = '" + ui->teacherComboBox->currentText() + "'"); + "WHERE `Предмети`.`Викладач` = '" + + ui->teacherComboBox->currentText() + "'"); virtualTable->setModel(virualQueryModel); - - if (virualQueryModel->rowCount() == 0) - { + if (virualQueryModel->rowCount() == 0) { ui->subjectComboBox->clear(); ui->subjectComboBox->addItem("Немає предметів"); - } - else - { - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { + } else { + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { subjectList.append(virtualTable->model()->index(row, 0).data().toString()); } @@ -217,58 +191,56 @@ void gradeStatistics::on_teacherComboBox_currentIndexChanged(int index) } } - void gradeStatistics::on_subjectComboBox_currentIndexChanged(int index) { - if (index == 0) - { + if (index == 0) { clearPieChart(); - } - else if (index > 0) - { + } else if (index > 0) { series->clear(); setWindowTitle("Статистика оцінок - (" + ui->subjectComboBox->currentText() + ")"); QSqlQueryModel *virualQueryModel = new QSqlQueryModel(this); QTableView *virtualTable = new QTableView(this); - for (int i = 2; i <= 5; i++) - { + for (int i = 2; i <= 5; i++) { virualQueryModel->setQuery("SELECT COUNT(`Оцінка`)" "FROM `Оцінки`" - "WHERE `Оцінки`.`Предмет` = '" + ui->subjectComboBox->currentText() + "'" - "AND `Оцінки`.`Оцінка` = '" + QString::number(i) + "'" - "GROUP BY `Оцінки`.`Оцінка`"); + "WHERE `Оцінки`.`Предмет` = '" + + ui->subjectComboBox->currentText() + + "'" + "AND `Оцінки`.`Оцінка` = '" + + QString::number(i) + + "'" + "GROUP BY `Оцінки`.`Оцінка`"); virtualTable->setModel(virualQueryModel); - switch (i) - { + switch (i) { case 2: - if (virtualTable->model()->index(0, 0).data().toInt() != NULL) - { - series->append("Незадовільно [" + virtualTable->model()->index(0, 0).data().toString() + "]", - virtualTable->model()->index(0, 0).data().toInt()); + if (virtualTable->model()->index(0, 0).data().toInt() != NULL) { + series->append("Незадовільно [" + + virtualTable->model()->index(0, 0).data().toString() + "]", + virtualTable->model()->index(0, 0).data().toInt()); } break; case 3: - if (virtualTable->model()->index(0, 0).data().toInt() != NULL) - { - series->append("Задовільно [" + virtualTable->model()->index(0, 0).data().toString() + "]", - virtualTable->model()->index(0, 0).data().toInt()); + if (virtualTable->model()->index(0, 0).data().toInt() != NULL) { + series->append("Задовільно [" + + virtualTable->model()->index(0, 0).data().toString() + "]", + virtualTable->model()->index(0, 0).data().toInt()); } break; case 4: - if (virtualTable->model()->index(0, 0).data().toInt() != NULL) - { - series->append("Добре [" + virtualTable->model()->index(0, 0).data().toString() + "]", + if (virtualTable->model()->index(0, 0).data().toInt() != NULL) { + series->append("Добре [" + virtualTable->model()->index(0, 0).data().toString() + + "]", virtualTable->model()->index(0, 0).data().toInt()); } break; case 5: - if (virtualTable->model()->index(0, 0).data().toInt() != NULL) - { - series->append("Відмінно [" + virtualTable->model()->index(0, 0).data().toString() + "]", - virtualTable->model()->index(0, 0).data().toInt()); + if (virtualTable->model()->index(0, 0).data().toInt() != NULL) { + series->append("Відмінно [" + + virtualTable->model()->index(0, 0).data().toString() + "]", + virtualTable->model()->index(0, 0).data().toInt()); } break; } @@ -277,4 +249,3 @@ void gradeStatistics::on_subjectComboBox_currentIndexChanged(int index) series->setLabelsVisible(true); } } - diff --git a/src/statisticsForms/gradestatistics.h b/src/statisticsForms/gradestatistics.h index 6b0fdeb..45df2ce 100644 --- a/src/statisticsForms/gradestatistics.h +++ b/src/statisticsForms/gradestatistics.h @@ -1,10 +1,10 @@ #ifndef GRADESTATISTICS_H #define GRADESTATISTICS_H -#include #include #include #include +#include namespace Ui { class gradeStatistics; @@ -43,7 +43,6 @@ private slots: public slots: void setTheme(const QString &style); - }; #endif // GRADESTATISTICS_H diff --git a/src/statisticsForms/groupstatistics.cpp b/src/statisticsForms/groupstatistics.cpp index 52e672b..5c0045d 100644 --- a/src/statisticsForms/groupstatistics.cpp +++ b/src/statisticsForms/groupstatistics.cpp @@ -1,20 +1,20 @@ #include "groupstatistics.h" #include "ui_groupstatistics.h" -#include -#include -#include +#include #include +#include +#include #include -#include -#include +#include +#include #include #include -#include +#include -groupStatistics::groupStatistics(QWidget *parent) : - QWidget(parent), - ui(new Ui::groupStatistics) +groupStatistics::groupStatistics(QWidget *parent) + : QWidget(parent) + , ui(new Ui::groupStatistics) { ui->setupUi(this); @@ -36,13 +36,11 @@ groupStatistics::groupStatistics(QWidget *parent) : clearPieChart(); } - groupStatistics::~groupStatistics() { delete ui; } - void groupStatistics::setBlackUI() { QFile file(":/styles/black/statisticsForms/statisticsForms.qss"); @@ -51,10 +49,9 @@ void groupStatistics::setBlackUI() file.close(); chartView->chart()->setTheme(QChart::ChartThemeDark); - chartView->chart()->setBackgroundBrush(QColor (49, 51, 52)); + chartView->chart()->setBackgroundBrush(QColor(49, 51, 52)); } - void groupStatistics::setWhiteUI() { QFile file(":/styles/white/statisticsForms/statisticsForms.qss"); @@ -63,44 +60,35 @@ void groupStatistics::setWhiteUI() file.close(); chartView->chart()->setTheme(QChart::ChartThemeLight); - chartView->chart()->setBackgroundBrush(QColor (255, 255, 255)); + chartView->chart()->setBackgroundBrush(QColor(255, 255, 255)); } - void groupStatistics::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { setWhiteUI(); - } - else - { + } else { setBlackUI(); } } - void groupStatistics::setTheme(const QString &style) { - if (style == "black") - { + if (style == "black") { setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { setWhiteUI(); - } - else - { + } else { setSystemUI(); } } - void groupStatistics::setGroupComboBox() { QStringList groupList; @@ -112,8 +100,7 @@ void groupStatistics::setGroupComboBox() virtualTable->setModel(virualQueryModel); - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { groupList.append(virtualTable->model()->index(row, 0).data().toString()); } @@ -123,22 +110,22 @@ void groupStatistics::setGroupComboBox() ui->groupComboBox->addItems(groupList); } - void groupStatistics::on_groupComboBox_currentIndexChanged(int index) { clearPieChart(); - if (index > 0) - { + if (index > 0) { series->clear(); QSqlQueryModel *virualQueryModel = new QSqlQueryModel(); QTableView *virtualTable = new QTableView(); virualQueryModel->setQuery("SELECT COUNT(*)" - "FROM `Студенти`" - "WHERE `Студенти`.`Група` = '" + ui->groupComboBox->currentText() + "'" - "GROUP BY `Студенти`.`Група`"); + "FROM `Студенти`" + "WHERE `Студенти`.`Група` = '" + + ui->groupComboBox->currentText() + + "'" + "GROUP BY `Студенти`.`Група`"); virtualTable->setModel(virualQueryModel); int countCurrentGroupStudent = virtualTable->model()->index(0, 0).data().toInt(); @@ -147,17 +134,15 @@ void groupStatistics::on_groupComboBox_currentIndexChanged(int index) virtualTable->setModel(virualQueryModel); int allCountStudent = virtualTable->model()->index(0, 0).data().toInt(); - if (allCountStudent not_eq 0 and countCurrentGroupStudent not_eq 0) - { + if (allCountStudent not_eq 0 and countCurrentGroupStudent not_eq 0) { series->append("Кількість студентів інших груп [" + QString::number(allCountStudent - countCurrentGroupStudent) + "]", - allCountStudent - countCurrentGroupStudent); + allCountStudent - countCurrentGroupStudent); - series->append("Кількість студентів групи " + ui->groupComboBox->currentText() - + "[" + QString::number(countCurrentGroupStudent) + "]", countCurrentGroupStudent); - } - else if (allCountStudent not_eq 0 ) - { + series->append("Кількість студентів групи " + ui->groupComboBox->currentText() + "[" + + QString::number(countCurrentGroupStudent) + "]", + countCurrentGroupStudent); + } else if (allCountStudent not_eq 0) { series->append("Загальна кількість студентів", allCountStudent); } @@ -165,11 +150,9 @@ void groupStatistics::on_groupComboBox_currentIndexChanged(int index) } } - void groupStatistics::clearPieChart() { setWindowTitle("Статистика груп"); series->clear(); series->append("Приклад", 1); } - diff --git a/src/statisticsForms/groupstatistics.h b/src/statisticsForms/groupstatistics.h index 9fe0273..a547a11 100644 --- a/src/statisticsForms/groupstatistics.h +++ b/src/statisticsForms/groupstatistics.h @@ -1,10 +1,10 @@ #ifndef GROUPSTATISTICS_H #define GROUPSTATISTICS_H -#include #include #include #include +#include namespace Ui { class groupStatistics; @@ -37,7 +37,6 @@ private slots: public slots: void setTheme(const QString &style); void setGroupComboBox(); - }; #endif // GROUPSTATISTICS_H diff --git a/src/statisticsForms/studentstatistics.cpp b/src/statisticsForms/studentstatistics.cpp index 5eaac7c..8e71189 100644 --- a/src/statisticsForms/studentstatistics.cpp +++ b/src/statisticsForms/studentstatistics.cpp @@ -1,20 +1,20 @@ #include "studentstatistics.h" #include "ui_studentstatistics.h" -#include -#include -#include +#include #include +#include +#include #include -#include -#include +#include +#include #include #include -#include +#include -studentStatistics::studentStatistics(QWidget *parent) : - QWidget(parent), - ui(new Ui::studentStatistics) +studentStatistics::studentStatistics(QWidget *parent) + : QWidget(parent) + , ui(new Ui::studentStatistics) { ui->setupUi(this); @@ -40,10 +40,18 @@ studentStatistics::studentStatistics(QWidget *parent) : chartView = new QChartView(chart); QStringList categories; - categories << "Січень" << "Лютий" << "Березень" - << "Квітень" << "Травень" << "Червень" - << "Липень" << "Серпень" << "Вересень" - << "Жовтень" << "Листопад" << "Грудень"; + categories << "Січень" + << "Лютий" + << "Березень" + << "Квітень" + << "Травень" + << "Червень" + << "Липень" + << "Серпень" + << "Вересень" + << "Жовтень" + << "Листопад" + << "Грудень"; QBarCategoryAxis *axisX = new QBarCategoryAxis(); axisX->append(categories); @@ -66,13 +74,11 @@ studentStatistics::studentStatistics(QWidget *parent) : ui->specialChart->addWidget(chartView); } - studentStatistics::~studentStatistics() { delete ui; } - void studentStatistics::setBlackUI() { QFile file(":/styles/black/statisticsForms/statisticsForms.qss"); @@ -81,7 +87,7 @@ void studentStatistics::setBlackUI() file.close(); chartView->chart()->setTheme(QChart::ChartThemeDark); - chartView->chart()->setBackgroundBrush(QColor (49, 51, 52)); + chartView->chart()->setBackgroundBrush(QColor(49, 51, 52)); set0->setColor(QColor(255, 95, 95)); set1->setColor(QColor(254, 202, 100)); @@ -89,7 +95,6 @@ void studentStatistics::setBlackUI() set3->setColor(QColor(136, 91, 255)); } - void studentStatistics::setWhiteUI() { QFile file(":/styles/white/statisticsForms/statisticsForms.qss"); @@ -98,7 +103,7 @@ void studentStatistics::setWhiteUI() file.close(); chartView->chart()->setTheme(QChart::ChartThemeLight); - chartView->chart()->setBackgroundBrush(QColor (255, 255, 255)); + chartView->chart()->setBackgroundBrush(QColor(255, 255, 255)); set0->setColor(QColor(255, 102, 152)); set1->setColor(QColor(245, 179, 67)); @@ -106,41 +111,32 @@ void studentStatistics::setWhiteUI() set3->setColor(QColor(170, 114, 192)); } - void studentStatistics::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { setWhiteUI(); - } - else - { + } else { setBlackUI(); } } - void studentStatistics::setTheme(const QString &style) { - if (style == "black") - { + if (style == "black") { setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { setWhiteUI(); - } - else - { + } else { setSystemUI(); } } - void studentStatistics::updateGroupComboBox() { QStringList groupList; @@ -152,8 +148,7 @@ void studentStatistics::updateGroupComboBox() virtualTable->setModel(virualQueryModel); - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { groupList.append(virtualTable->model()->index(row, 0).data().toString()); } @@ -163,20 +158,16 @@ void studentStatistics::updateGroupComboBox() ui->groupComboBox->addItems(groupList); } - void studentStatistics::on_groupComboBox_currentIndexChanged(int index) { clearChartSets(); chart->setTitle("Кількість оцінок за рік"); - if (index == 0) - { + if (index == 0) { ui->studentComboBox->setEnabled(false); ui->studentComboBox->clear(); ui->studentComboBox->addItem("Студенти групи відсутні", 0); - } - else - { + } else { ui->studentComboBox->setEnabled(true); QStringList studentList; @@ -185,14 +176,13 @@ void studentStatistics::on_groupComboBox_currentIndexChanged(int index) virualQueryModel->setQuery("SELECT `Прізвище`, `Ім'я`, `По батькові`" "FROM `Студенти`" - "WHERE `Студенти`.`Група` = '" + ui->groupComboBox->currentText() + "'"); + "WHERE `Студенти`.`Група` = '" + + ui->groupComboBox->currentText() + "'"); virtualTable->setModel(virualQueryModel); - if (virualQueryModel->rowCount() > 0) - { - for (int row = 0; row < virualQueryModel->rowCount(); ++row) - { + if (virualQueryModel->rowCount() > 0) { + for (int row = 0; row < virualQueryModel->rowCount(); ++row) { studentList.append(virtualTable->model()->index(row, 0).data().toString() + " " + virtualTable->model()->index(row, 1).data().toString() + " " + virtualTable->model()->index(row, 2).data().toString()); @@ -202,16 +192,15 @@ void studentStatistics::on_groupComboBox_currentIndexChanged(int index) ui->studentComboBox->addItem("Оберіть студента", 0); ui->studentComboBox->insertSeparator(1); ui->studentComboBox->addItems(studentList); - } - else - { + } else { ui->studentComboBox->clear(); ui->studentComboBox->addItem("Студенти групи відсутні", 0); } virualQueryModel->setQuery("SELECT `Рік початку навчання`, `Рік закінчення навчання`" "FROM `Групи`" - "WHERE `Групи`.`Назва` = '" + ui->groupComboBox->currentText() + "'"); + "WHERE `Групи`.`Назва` = '" + + ui->groupComboBox->currentText() + "'"); virtualTable->setModel(virualQueryModel); @@ -223,37 +212,31 @@ void studentStatistics::on_groupComboBox_currentIndexChanged(int index) setWindowTitle("Статистика студента"); } - void studentStatistics::on_studentComboBox_currentIndexChanged(int index) { - if (index == 0) - { + if (index == 0) { clearChartSets(); ui->nameLabel->setText("Статистика за:"); setWindowTitle("Статистика студента"); - } - else if (index > 0) - { + } else if (index > 0) { setCurrentChart(); } } - void studentStatistics::clearChartSets() { - set0->remove(0 , set0->count()); - set1->remove(0 , set1->count()); - set2->remove(0 , set2->count()); - set3->remove(0 , set3->count()); + set0->remove(0, set0->count()); + set1->remove(0, set1->count()); + set2->remove(0, set2->count()); + set3->remove(0, set3->count()); } - void studentStatistics::setCurrentChart() { clearChartSets(); - ui->nameLabel->setText("Статистика за: " + ui->studentComboBox->currentText() - + " [" + ui->groupComboBox->currentText() + "]"); + ui->nameLabel->setText("Статистика за: " + ui->studentComboBox->currentText() + " [" + + ui->groupComboBox->currentText() + "]"); setWindowTitle("Статистика " + ui->studentComboBox->currentText()); QSqlQueryModel *virualQueryModel = new QSqlQueryModel(this); @@ -261,58 +244,48 @@ void studentStatistics::setCurrentChart() virualQueryModel->setQuery("SELECT `Оцінка`, MONTH(`Дата виставлення`)" "FROM `Оцінки`" - "WHERE `Оцінки`.`Отримувач` = '" + ui->studentComboBox->currentText() + "'" - " AND YEAR(`Дата виставлення`) = '" + QString::number(ui->yearSpinBox->value()) + "'"); + "WHERE `Оцінки`.`Отримувач` = '" + + ui->studentComboBox->currentText() + + "'" + " AND YEAR(`Дата виставлення`) = '" + + QString::number(ui->yearSpinBox->value()) + "'"); virtualTable->setModel(virualQueryModel); int maxCount = 0; - for (int i = 0; i < 12; ++i) - { + for (int i = 0; i < 12; ++i) { int sum0 = 0; int sum1 = 0; int sum2 = 0; int sum3 = 0; - for (int j = 0; j < virualQueryModel->rowCount(); ++j) - { + for (int j = 0; j < virualQueryModel->rowCount(); ++j) { if (virtualTable->model()->index(j, 0).data().toInt() == 2 - and (virtualTable->model()->index(j, 1).data().toInt() - 1) == i) - { + and (virtualTable->model()->index(j, 1).data().toInt() - 1) == i) { sum0++; - if (sum0 > maxCount) - { + if (sum0 > maxCount) { maxCount = sum0; } - } - else if (virtualTable->model()->index(j, 0).data().toInt() == 3 - and (virtualTable->model()->index(j, 1).data().toInt() - 1) == i) - { + } else if (virtualTable->model()->index(j, 0).data().toInt() == 3 + and (virtualTable->model()->index(j, 1).data().toInt() - 1) == i) { sum1++; - if (sum1 > maxCount) - { + if (sum1 > maxCount) { maxCount = sum1; } - } - else if (virtualTable->model()->index(j, 0).data().toInt() == 4 - and (virtualTable->model()->index(j, 1).data().toInt() - 1) == i) - { + } else if (virtualTable->model()->index(j, 0).data().toInt() == 4 + and (virtualTable->model()->index(j, 1).data().toInt() - 1) == i) { sum2++; - if (sum2 > maxCount) - { + if (sum2 > maxCount) { maxCount = sum2; } - } - else if (virtualTable->model()->index(j, 0).data().toInt() == 5 - and (virtualTable->model()->index(j, 1).data().toInt() - 1) == i) - { + } else if (virtualTable->model()->index(j, 0).data().toInt() == 5 + and (virtualTable->model()->index(j, 1).data().toInt() - 1) == i) { sum3++; - if (sum3 > maxCount) - { + if (sum3 > maxCount) { maxCount = sum3; } } @@ -325,18 +298,19 @@ void studentStatistics::setCurrentChart() virualQueryModel->setQuery("SELECT MAX(`Оцінка`)" "FROM `Оцінки`" - "WHERE `Оцінки`.`Отримувач` = '" + ui->studentComboBox->currentText() + "'" - " AND YEAR(`Дата виставлення`) = '" + QString::number(ui->yearSpinBox->value()) + "'"); + "WHERE `Оцінки`.`Отримувач` = '" + + ui->studentComboBox->currentText() + + "'" + " AND YEAR(`Дата виставлення`) = '" + + QString::number(ui->yearSpinBox->value()) + "'"); virtualTable->setModel(virualQueryModel); chart->axes(Qt::Vertical).first()->setRange(0, maxCount + 1); - chart->setTitle("Кількість оцінок за " + QString::number(ui->yearSpinBox->value())+ " рік"); + chart->setTitle("Кількість оцінок за " + QString::number(ui->yearSpinBox->value()) + " рік"); } - void studentStatistics::on_yearSpinBox_valueChanged(int arg1) { - if (ui->studentComboBox->currentIndex() > 0) - { + if (ui->studentComboBox->currentIndex() > 0) { setCurrentChart(); } } diff --git a/src/statisticsForms/studentstatistics.h b/src/statisticsForms/studentstatistics.h index 8185b88..c00d5c8 100644 --- a/src/statisticsForms/studentstatistics.h +++ b/src/statisticsForms/studentstatistics.h @@ -1,11 +1,11 @@ #ifndef STUDENTSTATISTICS_H #define STUDENTSTATISTICS_H -#include +#include +#include #include #include -#include -#include +#include namespace Ui { class studentStatistics; diff --git a/src/statisticsForms/subjectstatistics.cpp b/src/statisticsForms/subjectstatistics.cpp index abee7d3..f2e026c 100644 --- a/src/statisticsForms/subjectstatistics.cpp +++ b/src/statisticsForms/subjectstatistics.cpp @@ -1,17 +1,17 @@ #include "subjectstatistics.h" #include "ui_subjectstatistics.h" -#include -#include -#include +#include #include +#include +#include #include +#include #include -#include -subjectStatistics::subjectStatistics(QWidget *parent) : - QWidget(parent), - ui(new Ui::subjectStatistics) +subjectStatistics::subjectStatistics(QWidget *parent) + : QWidget(parent) + , ui(new Ui::subjectStatistics) { ui->setupUi(this); setWindowTitle("Статистика предметів по типам"); @@ -32,7 +32,6 @@ subjectStatistics::subjectStatistics(QWidget *parent) : ui->specialChart->addWidget(chartView); } - subjectStatistics::~subjectStatistics() { delete ui; @@ -40,14 +39,14 @@ subjectStatistics::~subjectStatistics() void subjectStatistics::closeEvent(QCloseEvent *event) { - if (event->Close) - { + if (event->Close) { series->clear(); } } void subjectStatistics::fillChart() { + /* QSqlQueryModel *virtualQueryModel = new QSqlQueryModel(); QTableView *virtualTableView = new QTableView(); @@ -57,12 +56,12 @@ void subjectStatistics::fillChart() virtualTableView->setModel(virtualQueryModel); - for (int row = 0; row < virtualTableView->model()->rowCount(); ++row) - { + for (int row = 0; row < virtualTableView->model()->rowCount(); ++row) { series->append(virtualTableView->model()->index(row, 0).data().toString(), virtualTableView->model()->index(row, 1).data().toInt()); } series->setLabelsVisible(true); + */ } void subjectStatistics::setBlackUI() @@ -76,7 +75,6 @@ void subjectStatistics::setBlackUI() chartView->chart()->setBackgroundBrush(QColor(49, 51, 52)); } - void subjectStatistics::setWhiteUI() { QFile file(":/styles/white/statisticsForms/statisticsForms.qss"); @@ -88,36 +86,28 @@ void subjectStatistics::setWhiteUI() chartView->chart()->setBackgroundBrush(QColor(255, 255, 255)); } - void subjectStatistics::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { setWhiteUI(); - } - else - { + } else { setBlackUI(); } } - void subjectStatistics::setTheme(const QString &style) { - if (style == "black") - { + if (style == "black") { setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { setWhiteUI(); - } - else - { + } else { setSystemUI(); } } diff --git a/src/statisticsForms/subjectstatistics.h b/src/statisticsForms/subjectstatistics.h index 817a718..dbae49f 100644 --- a/src/statisticsForms/subjectstatistics.h +++ b/src/statisticsForms/subjectstatistics.h @@ -1,12 +1,11 @@ #ifndef SUBJECTSTATISTICS_H #define SUBJECTSTATISTICS_H -#include #include #include #include #include -#include +#include namespace Ui { class subjectStatistics; @@ -31,9 +30,9 @@ private slots: private: Ui::subjectStatistics *ui; - QChartView* chartView; - QChart* chart; - QPieSeries* series; + QChartView *chartView; + QChart *chart; + QPieSeries *series; public slots: void setTheme(const QString &style); diff --git a/src/statisticsForms/teacherstatistics.cpp b/src/statisticsForms/teacherstatistics.cpp index f825925..62457c2 100644 --- a/src/statisticsForms/teacherstatistics.cpp +++ b/src/statisticsForms/teacherstatistics.cpp @@ -1,17 +1,17 @@ #include "teacherstatistics.h" #include "ui_teacherstatistics.h" -#include -#include -#include +#include #include +#include +#include #include +#include #include -#include -teacherStatistics::teacherStatistics(QWidget *parent) : - QWidget(parent), - ui(new Ui::teacherStatistics) +teacherStatistics::teacherStatistics(QWidget *parent) + : QWidget(parent) + , ui(new Ui::teacherStatistics) { ui->setupUi(this); setWindowTitle("Статистика викладачів по категоріям"); @@ -32,7 +32,6 @@ teacherStatistics::teacherStatistics(QWidget *parent) : ui->specialChartL->addWidget(chartView); } - teacherStatistics::~teacherStatistics() { delete ui; @@ -40,14 +39,14 @@ teacherStatistics::~teacherStatistics() void teacherStatistics::closeEvent(QCloseEvent *event) { - if (event->Close) - { + if (event->Close) { series->clear(); } } void teacherStatistics::fillChart() { + /* QSqlQueryModel *virtualQueryModel = new QSqlQueryModel(); QTableView *virtualTableView = new QTableView(); @@ -57,12 +56,12 @@ void teacherStatistics::fillChart() virtualTableView->setModel(virtualQueryModel); - for (int row = 0; row < virtualTableView->model()->rowCount(); ++row) - { + for (int row = 0; row < virtualTableView->model()->rowCount(); ++row) { series->append(virtualTableView->model()->index(row, 0).data().toString(), virtualTableView->model()->index(row, 1).data().toInt()); } series->setLabelsVisible(true); + */ } void teacherStatistics::setBlackUI() @@ -76,7 +75,6 @@ void teacherStatistics::setBlackUI() chartView->chart()->setBackgroundBrush(QColor(49, 51, 52)); } - void teacherStatistics::setWhiteUI() { QFile file(":/styles/white/statisticsForms/statisticsForms.qss"); @@ -88,36 +86,28 @@ void teacherStatistics::setWhiteUI() chartView->chart()->setBackgroundBrush(QColor(255, 255, 255)); } - void teacherStatistics::setSystemUI() { QPalette basePalette; QColor baseColor = basePalette.base().color(); - QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), 1 - baseColor.greenF(), 1 - baseColor.blueF()); + QColor newBase = QColor::fromRgbF(1 - baseColor.redF(), + 1 - baseColor.greenF(), + 1 - baseColor.blueF()); - if (newBase.name() == "#000000") - { + if (newBase.name() == "#000000") { setWhiteUI(); - } - else - { + } else { setBlackUI(); } } - void teacherStatistics::setTheme(const QString &style) { - if (style == "black") - { + if (style == "black") { setBlackUI(); - } - else if (style == "white") - { + } else if (style == "white") { setWhiteUI(); - } - else - { + } else { setSystemUI(); } } diff --git a/src/statisticsForms/teacherstatistics.h b/src/statisticsForms/teacherstatistics.h index 9d2b8d3..9715dc4 100644 --- a/src/statisticsForms/teacherstatistics.h +++ b/src/statisticsForms/teacherstatistics.h @@ -1,12 +1,11 @@ #ifndef TEACHERSTATISTICS_H #define TEACHERSTATISTICS_H -#include #include #include #include #include -#include +#include namespace Ui { class teacherStatistics; @@ -31,9 +30,9 @@ private slots: private: Ui::teacherStatistics *ui; - QChartView* chartView; - QChart* chart; - QPieSeries* series; + QChartView *chartView; + QChart *chart; + QPieSeries *series; public slots: void setTheme(const QString &style); diff --git a/src/styles/black/appSetting/appSetting.qss b/src/styles/black/AppSettingsWindow/AppSettingsWindow.qss similarity index 94% rename from src/styles/black/appSetting/appSetting.qss rename to src/styles/black/AppSettingsWindow/AppSettingsWindow.qss index aec97ff..d326fa7 100644 --- a/src/styles/black/appSetting/appSetting.qss +++ b/src/styles/black/AppSettingsWindow/AppSettingsWindow.qss @@ -1,4 +1,4 @@ -appSetting +AppSettingsWindow { background-color: rgb(29, 31, 32); } @@ -26,7 +26,7 @@ QLabel#labelSeeUI, QLabel#dataBaseText, QLabel#accountText, QLabel#dbname, -QLabel#dbhostname, +QLabel#dburl, QLabel#dblogin, QLabel#dbpassword, QLabel#accountText_2, @@ -42,7 +42,7 @@ QLabel#succSaveSettings color: lime; } -QLineEdit#dbhostnameLineEdit, +QLineEdit#dburlLineEdit, QLineEdit#dbloginLineEdit, QLineEdit#dbpasswordLineEdit, QLineEdit#dbnameLineEdit, @@ -59,7 +59,7 @@ QLineEdit#accountLideEdit_4 border-radius: 8px; } -QLineEdit#dbhostnameLineEdit:focus, +QLineEdit#dburlLineEdit:focus, QLineEdit#dbloginLineEdit:focus, QLineEdit#dbpasswordLineEdit:focus, QLineEdit#dbnameLineEdit:focus, diff --git a/src/styles/black/authorizationForm/authorizationForm.qss b/src/styles/black/LoginWindow/LoginWindow.qss similarity index 98% rename from src/styles/black/authorizationForm/authorizationForm.qss rename to src/styles/black/LoginWindow/LoginWindow.qss index 934ec28..3125234 100644 --- a/src/styles/black/authorizationForm/authorizationForm.qss +++ b/src/styles/black/LoginWindow/LoginWindow.qss @@ -1,4 +1,4 @@ -authorizationForm +LoginWindow { background-color: rgb(41, 45, 48) } diff --git a/src/styles/white/appSetting/appSetting.qss b/src/styles/white/AppSettingsWindow/AppSettingsWindow.qss similarity index 94% rename from src/styles/white/appSetting/appSetting.qss rename to src/styles/white/AppSettingsWindow/AppSettingsWindow.qss index a4e6ec4..00f7e14 100644 --- a/src/styles/white/appSetting/appSetting.qss +++ b/src/styles/white/AppSettingsWindow/AppSettingsWindow.qss @@ -1,4 +1,4 @@ -appSetting +AppSettingsWindow { background-color: rgb(231, 224, 223); } @@ -26,7 +26,7 @@ QLabel#labelSeeUI, QLabel#dataBaseText, QLabel#accountText, QLabel#dbname, -QLabel#dbhostname, +QLabel#dburl, QLabel#dblogin, QLabel#dbpassword, QLabel#accountText_2, @@ -42,7 +42,7 @@ QLabel#succSaveSettings color: green; } -QLineEdit#dbhostnameLineEdit, +QLineEdit#dburlLineEdit, QLineEdit#dbloginLineEdit, QLineEdit#dbpasswordLineEdit, QLineEdit#dbnameLineEdit, @@ -59,7 +59,7 @@ QLineEdit#accountLideEdit_4 border-radius: 8px; } -QLineEdit#dbhostnameLineEdit:focus, +QLineEdit#dburlLineEdit:focus, QLineEdit#dbloginLineEdit:focus, QLineEdit#dbpasswordLineEdit:focus, QLineEdit#dbnameLineEdit:focus, diff --git a/src/styles/white/authorizationForm/authorizationForm.qss b/src/styles/white/LoginWindow/LoginWindow.qss similarity index 98% rename from src/styles/white/authorizationForm/authorizationForm.qss rename to src/styles/white/LoginWindow/LoginWindow.qss index e92a1b2..1d5c617 100644 --- a/src/styles/white/authorizationForm/authorizationForm.qss +++ b/src/styles/white/LoginWindow/LoginWindow.qss @@ -1,4 +1,4 @@ -authorizationForm +LoginWindow { background-color: rgb(231, 224, 223); }