Из ГУИ чат с инструкторами

This commit is contained in:
2025-09-09 17:25:26 +03:00
parent 15325eb43a
commit 0728582be0
4 changed files with 46 additions and 1 deletions

View File

@@ -9,9 +9,11 @@ ViewerInstructors::ViewerInstructors(ConnectorToServer* connectorToServer, QWidg
{
ui->setupUi(this);
connect(treeWidget, &QTreeWidget::currentItemChanged, this, &ViewerInstructors::on_treeWidget_currentItemChanged);
ui->horizontalLayout_1->addWidget(treeWidget);
treeWidget->setSelectionMode(QAbstractItemView::NoSelection);
//treeWidget->setSelectionMode(QAbstractItemView::NoSelection);
preparationTreeWidget();
setNotLoggedInVisible(true);
@@ -69,6 +71,28 @@ void ViewerInstructors::on_btnEditorInstructors_clicked()
Q_EMIT signal_BlockAutorization(false);
}
void ViewerInstructors::on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
if(current == nullptr)
return;
//if(current->childCount() == 0)
{//Выбран обучаемый
QString login = current->text(ColumnsTreeInsructors::clmn_Login);
//if(login != "")
{
int newCurrentID = connectorToServer->getIdInstructorByLogin(login);
if(newCurrentID == lastCurrentID)
return;
lastCurrentID = newCurrentID;
Q_EMIT signal_instructorSelected(login);
}
}
}
void ViewerInstructors::updateButtons()
{
if(adminMode && authComplited)

View File

@@ -32,6 +32,13 @@ Q_SIGNALS:
public Q_SLOTS:
void on_btnEditorInstructors_clicked();
public slots:
void on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
Q_SIGNALS:
//сигнал о выборе инструктора
void signal_instructorSelected(QString login);
private:
void updateButtons() override;

View File

@@ -52,6 +52,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
connect(connectorToServer,&ConnectorToServer::signal_ConnectedToServer,this,&InstructorsAndTraineesWidget::slot_ConnectedToServer);
connect(viewerTrainees, &ViewerTrainees::signal_traineeSelected, this, &InstructorsAndTraineesWidget::slot_traineeSelected);
connect(viewerInstructors, &ViewerInstructors::signal_instructorSelected, this, &InstructorsAndTraineesWidget::slot_instructorSelected);
//Размещение
ui->verticalLayout_Trainees->addWidget(viewerTrainees);
@@ -263,6 +264,18 @@ void InstructorsAndTraineesWidget::slot_traineeSelected(QString login)
}
}
void InstructorsAndTraineesWidget::slot_instructorSelected(QString login)
{
/* Messanger*/
messangerController->deleteWidget(messangerWidget);
if(login != "")
{
Instructor instructor = connectorToServer->getInstructor(connectorToServer->getIdInstructorByLogin(login));
if(instructor.getID())
messangerWidget = messangerController->newWidget(this, &instructor, ui->verticalLayout_Messenger);
}
}
bool InstructorsAndTraineesWidget::authorizationInstructorDialog(QWidget* parent)
{
DialogAuthorizationInstructor dlg(parent);

View File

@@ -49,6 +49,7 @@ public Q_SLOTS:
void slot_ConnectedToServer(bool state);
void slot_traineeSelected(QString login);
void slot_instructorSelected(QString login);
Q_SIGNALS:
//сигнал смены языка