Оповещения о непрочитанных сообщениях

This commit is contained in:
2025-12-01 14:29:26 +03:00
parent 834e192479
commit c97c86ac55
10 changed files with 116 additions and 0 deletions

View File

@@ -100,6 +100,24 @@ void TraineesView::loadTraineesFromDB()
if(! trainee.getLoggedIn())
if(! notLoggedInVisible)
ItemTrainee->setHidden(true);
mtxmapNewMsg.lock();
if(mapNewMsg.contains(trainee.getID()))
{//Есть непрочитанные сообщения от него
if(mapNewMsg.value(trainee.getID()))
{
if(lastCurrentID == trainee.getID())
mapNewMsg.take(lastCurrentID);
else
{
for (int i = 0; i < ColumnsTreeUsers::clmn_count; i++)
{
ItemTrainee->setBackground(i, QBrush(QColor(250, 210, 1)));
}
}
}
}
mtxmapNewMsg.unlock();
}
//if(! archiveVisible && cntChildsNotArchived == 0)

View File

@@ -98,6 +98,17 @@ void ViewerTrainees::changeEvent(QEvent *event)
}
}
void ViewerTrainees::slot_receiveMessage(ClientMessage clientMessage)
{
int id_trainee = clientMessage.fromId.toInt();
mtxmapNewMsg.lock();
mapNewMsg.insert(id_trainee, true);
mtxmapNewMsg.unlock();
slot_NeedUpdateUI(false, true);
}
void ViewerTrainees::on_btnEditorTrainees_clicked()
{
connectorToServer->sendQueryBlockAuth(true);
@@ -181,6 +192,20 @@ void ViewerTrainees::on_treeWidgetItemClicked(QTreeWidgetItem *item, int column)
lastCurrentID = newCurrentID;
mtxmapNewMsg.lock();
if(mapNewMsg.contains(newCurrentID))
{//Есть непрочитанные сообщения от него
if(mapNewMsg.value(newCurrentID))
{
for (int i = 0; i < ColumnsTreeUsers::clmn_count; i++)
{
item->setBackground(i, QBrush(Qt::GlobalColor::white));
}
mapNewMsg.take(newCurrentID);
}
}
mtxmapNewMsg.unlock();
Q_EMIT signal_traineeSelected(newCurrentID);
}
}

View File

@@ -33,6 +33,9 @@ public:
protected:
void changeEvent(QEvent * event) override;
public slots:
void slot_receiveMessage(ClientMessage clientMessage);
public Q_SLOTS:
void on_btnEditorTrainees_clicked();
void on_btnPersonalCard_clicked();