Files
RRJServer/DB_IaT/InstructorsAndTrainees/instructors/viewerinstructors.cpp
2024-11-13 09:54:35 +03:00

74 lines
2.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include <QMessageBox>
#include "editorinstructors.h"
#include "viewerinstructors.h"
#include "ui_viewerinstructors.h"
ViewerInstructors::ViewerInstructors(DataBaseInstructors* db, bool adminMode, QWidget *parent) :
InstructorsView(db, CommonView::TypeView::onlyView, adminMode, parent),
ui(new Ui::ViewerInstructors)
{
ui->setupUi(this);
this->adminMode = adminMode;
// Сделаем первоначальную инициализацию перевода для окна виджета
qtLanguageTranslator.load(QString(QStringLiteral("translations/InstructorsAndTrainees_")) + QString(QStringLiteral("ru_RU")), QStringLiteral("."));
qApp->installTranslator(&qtLanguageTranslator);
preparationTreeWidget(ui->treeWidget);
setNotLoggedInVisible(true);
loadInstructorsFromDB();
if(! this->adminMode)
ui->btnEditorInstructors->setEnabled(false);
}
ViewerInstructors::~ViewerInstructors()
{
delete ui;
}
void ViewerInstructors::setFilterInstructorLoggedIn(bool enabled)
{
setNotLoggedInVisible(!enabled);
loadInstructorsFromDB();
}
void ViewerInstructors::changeEvent(QEvent *event)
{
// В случае получения события изменения языка приложения
if (event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this); // переведём окно заново
reSetHeadTreeWidget();
loadInstructorsFromDB();
}
}
void ViewerInstructors::slot_LanguageChanged(QString language)
{
qtLanguageTranslator.load(QString(QStringLiteral("translations/InstructorsAndTrainees_")) + language, QStringLiteral("."));
qApp->installTranslator(&qtLanguageTranslator);
}
void ViewerInstructors::on_btnEditorInstructors_clicked()
{
if(! adminMode)
{
QMessageBox::warning(this, tr("Attention!"),
tr("Only the Administrator has the right to edit instructors."));
return;
}
EditorInstructors editorInstructors(dbInstructors, adminMode);
QDialog* dialog = new QDialog(this);
QHBoxLayout *layout = new QHBoxLayout(dialog);
layout->addWidget(&editorInstructors);
dialog->setWindowTitle(tr("Editor of instructors"));
dialog->setMinimumSize(1600, 800);
dialog->exec();
loadInstructorsFromDB();
}