- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung - 44 Export-Header Include-Pfade korrigiert (_export.h) - 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h) - INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros - Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits) - FATAL_LOG Makro hinzugefügt - InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h) - FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h) - AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp) - SymbolAppearance Klasse vollständig definiert mit content() Methode - BuildingComponentFilter Klasse definiert mit Copy-Konstruktor - Ftc Factory: nullptr Return (abstract class) - AesFilter Klasse in aes.hpp hinzugefügt - Dtc Klasse in ppm.hpp mit participantChanged Signal - AesType Enum: alle 15 At* Werte definiert - AesEffectState_def: EsReceived hinzugefügt - DataModification Enum: eAdded/eModified/eRemoved - function_reply_object.h → core_types.h Include-Pfad (72 Dateien) - Enum-Class-Streaming Template-Operator in INGLLogger.h - ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen - ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge - QRegExp → QRegularExpression in tpm_js_parser.cpp - .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert - Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
265 lines
8.9 KiB
C++
Executable File
265 lines
8.9 KiB
C++
Executable File
|
|
|
|
|
|
#include "nom_dialog.h"
|
|
#include <ui_nom_dialog.h>
|
|
|
|
#include "nom_dialog_model.h"
|
|
|
|
#include <QLabel>
|
|
#include <QTextBrowser>
|
|
#include <LtsSession/lts_session.h>
|
|
#include <LtsSession/lts_session_data.h>
|
|
#include <LtsWidgets/lts_events.h>
|
|
#include <LtsUtilsSettings/settings.h>
|
|
#include <LtsWidgets/lts_base_layout_widget.h>
|
|
#include <LtsWidgets/lts_events.h>
|
|
#include <Plugins/NotificationManagement/nom_data_plugin_interface.h>
|
|
|
|
namespace NotificationManagement
|
|
{
|
|
|
|
NotificationManagementDialog::NotificationManagementDialog(LtsSession::LtsSession *session, const QString &menuGroup, QWidget *parent)
|
|
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
|
, m_model(new NotificationManagementDialogModel(this))
|
|
, m_ui(new Ui::NotificationManagementDialog)
|
|
, m_session(session)
|
|
, m_menuGroup(menuGroup)
|
|
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
|
{
|
|
m_ui->setupUi(this);
|
|
m_ui->widget->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
setOnlineHelpFilename(QStringLiteral("Administrator-Notifications"));
|
|
|
|
|
|
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &NotificationManagementDialog::onAcknowledgeNotification);
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, false);
|
|
m_buttonBox->setText(LtsWidgets::DialogButton::Save, tr("Acknowledge"));
|
|
|
|
|
|
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &NotificationManagementDialog::onRemoveNotification);
|
|
|
|
|
|
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &NotificationManagementDialog::onShowNotificationContent);
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
|
|
|
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &NotificationManagementDialog::onShowNotificationContent);
|
|
|
|
if (!m_session->getDtc<NotificationManagement::DataInterface>(m_dtc))
|
|
return;
|
|
if (!m_session->getFtc<NotificationManagement::DataInterface>(m_ftc))
|
|
return;
|
|
if (!m_session->getDtc<OperatorManagement::DataInterface>(m_dtcOpm))
|
|
return;
|
|
if (!m_session->getDtc<AssetManagement::DataInterface>(m_dtcAsm))
|
|
return;
|
|
|
|
m_dtcAsm->enableAsset();
|
|
|
|
m_model->initModel(m_session);
|
|
auto proxy = new NotificationDialogProxyModel(this);
|
|
proxy->setSourceModel(m_model);
|
|
m_ui->widget->setModel(proxy);
|
|
|
|
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &NotificationManagementDialog::enaDisa);
|
|
enaDisa();
|
|
}
|
|
|
|
NotificationManagementDialog::~NotificationManagementDialog() { delete m_ui; }
|
|
|
|
void NotificationManagementDialog::retranslate() { translate(m_ui, tr("Notifications")); }
|
|
|
|
void NotificationManagementDialog::tableColumnOrganiserSetting()
|
|
{
|
|
|
|
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
|
}
|
|
|
|
void NotificationManagementDialog::onAcknowledgeNotification()
|
|
{
|
|
const QModelIndex curIdx = m_ui->widget->currentIndex();
|
|
const NomNotification ¬i = m_model->getRowData(curIdx.row());
|
|
|
|
ReadReceipt request;
|
|
|
|
int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
|
int workstationId = LtsSessionData::LtsSessionData::getInstance()->getWorkstationId();
|
|
|
|
for (const auto &addr : noti.recipientIds())
|
|
{
|
|
if ((addr.addressType() == AddressType_def::Operator && addr.addressId() == operatorId)
|
|
|| (addr.addressType() == AddressType_def::Workstation && addr.addressId() == workstationId))
|
|
{
|
|
request.addressId(addr.id());
|
|
break;
|
|
}
|
|
}
|
|
request.operatorId(operatorId);
|
|
request.workstationId(workstationId);
|
|
|
|
bool onlyNotYetAcknowledged = true;
|
|
request.notificationIds(selectedNotificationIds(onlyNotYetAcknowledged));
|
|
if (request.notificationIds().empty())
|
|
return;
|
|
request.processed(true);
|
|
|
|
m_requestHelper->setCustomWaitMessage(tr("Marking notification as read"));
|
|
m_requestHelper->startSingleRequest(
|
|
[&]()
|
|
{
|
|
DEBUG_LOG() << "m_ftc->readReceipt ";
|
|
return m_ftc->readReceiptRequest(request, this);
|
|
});
|
|
}
|
|
|
|
std::vector<int32_t> NotificationManagementDialog::selectedNotificationIds(bool onlyNotYetAcknowledged)
|
|
{
|
|
std::vector<int32_t> notificationIds;
|
|
QModelIndexList selectedRows = m_ui->widget->selectionModel()->selectedRows();
|
|
notificationIds.reserve(selectedRows.size());
|
|
for (const QModelIndex &index : selectedRows)
|
|
{
|
|
const NomNotification ¬i = m_model->getRowData(index.row());
|
|
|
|
|
|
|
|
if (onlyNotYetAcknowledged && noti.processed())
|
|
continue;
|
|
|
|
|
|
notificationIds.emplace_back(noti.id());
|
|
}
|
|
|
|
return notificationIds;
|
|
}
|
|
|
|
void NotificationManagementDialog::onRemoveNotification()
|
|
{
|
|
const QModelIndex curIdx = m_ui->widget->currentIndex();
|
|
const NomNotification ¬i = m_model->getRowData(curIdx.row());
|
|
|
|
DeleteMessage request;
|
|
|
|
const int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
|
const int workstationId = LtsSessionData::LtsSessionData::getInstance()->getWorkstationId();
|
|
|
|
for (const auto &addr : noti.recipientIds())
|
|
{
|
|
if ((addr.addressType() == AddressType_def::Operator && addr.addressId() == operatorId)
|
|
|| (addr.addressType() == AddressType_def::Workstation && addr.addressId() == workstationId))
|
|
{
|
|
request.addressId(addr.id());
|
|
break;
|
|
}
|
|
}
|
|
request.operatorId(operatorId);
|
|
request.workstationId(workstationId);
|
|
|
|
bool acknowledge = false;
|
|
request.notificationIds(selectedNotificationIds(acknowledge));
|
|
|
|
m_requestHelper->setCustomWaitMessage(tr("Delete message"));
|
|
m_requestHelper->startSingleRequest(
|
|
[&]()
|
|
{
|
|
DEBUG_LOG() << "m_ftc->readReceipt ";
|
|
return m_ftc->deleteMessageRequest(request, this);
|
|
});
|
|
}
|
|
|
|
void NotificationManagementDialog::enaDisa()
|
|
{
|
|
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
|
const int cntSelectedRows = selectedRows.size();
|
|
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, cntSelectedRows >= 1);
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows >= 1);
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, cntSelectedRows == 1);
|
|
}
|
|
|
|
void NotificationManagementDialog::onShowNotificationContent()
|
|
{
|
|
LtsWidgets::LtsFramelessDialog *contentPopup = new LtsWidgets::LtsFramelessDialog(this, LtsWidgets::Behaviour::Popup);
|
|
|
|
const QModelIndex curIdx = m_ui->widget->currentIndex();
|
|
const NomNotification ¬i = m_model->getRowData(curIdx.row());
|
|
|
|
QString content = QCoreApplication::translate("Notification", noti.content().c_str());
|
|
|
|
NomNotification notiDDS = m_dtc->nomNotification(noti.id());
|
|
DEBUG_LOG() << "onShowNotificationContent"
|
|
<< ", content=" << noti.content()
|
|
<< ", contentArgs().size()=" << noti.contentArgs().size()
|
|
<< ", notiDDS.contentArgs().size()=" << notiDDS.contentArgs().size();
|
|
|
|
for (const std::string& arg : notiDDS.contentArgs()) {
|
|
|
|
content = content.arg(QString::fromStdString(arg));
|
|
DEBUG_LOG() << ".arg() ersetzt immer den kleinsten freien Platzhalter"
|
|
<< ", arg=" << arg
|
|
<< ", content=" << content;
|
|
}
|
|
|
|
QScrollArea *scrollArea = new QScrollArea(this);
|
|
scrollArea->setWidgetResizable(true);
|
|
|
|
QTextBrowser *wid = new QTextBrowser(this);
|
|
wid->setOpenExternalLinks(false);
|
|
wid->setOpenLinks(false);
|
|
|
|
wid->setWordWrapMode(QTextOption::WordWrap);
|
|
wid->setMarkdown(content);
|
|
connect(wid, &QTextBrowser::anchorClicked, this, [this, contentPopup](QUrl link )
|
|
{
|
|
DEBUG_LOG() << "LINK CLICKED: " << link.toString();
|
|
auto *event = new LtsWidgets::LtsLinkEvent(link, m_session->baseLayoutWidget());
|
|
event->setAccepted(false);
|
|
QApplication::postEvent(qApp, event);
|
|
contentPopup->close();
|
|
});
|
|
|
|
scrollArea->setWidget(wid);
|
|
|
|
QFont font;
|
|
font.setBold(true);
|
|
|
|
QLabel *lblTitle = new QLabel(QCoreApplication::translate("Notification", noti.title().c_str()), contentPopup);
|
|
lblTitle->setFont(font);
|
|
QLabel *lblFrom = new QLabel(tr("From: "));
|
|
lblFrom->setFont(font);
|
|
QLabel *lblSender = new QLabel(QString::fromStdString(noti.sender().name()));
|
|
|
|
QFrame *line = new QFrame(this);
|
|
line->setFrameShape(QFrame::HLine);
|
|
line->setFrameShadow(QFrame::Sunken);
|
|
QFrame *line2 = new QFrame(this);
|
|
line2->setFrameShape(QFrame::HLine);
|
|
line2->setFrameShadow(QFrame::Sunken);
|
|
|
|
LtsWidgets::LtsDialogButtonBox *btnBox = new LtsWidgets::LtsDialogButtonBox(contentPopup);
|
|
connect(btnBox->getButton(LtsWidgets::DialogButton::Close), &QPushButton::clicked, contentPopup, &LtsWidgets::LtsFramelessDialog::accept);
|
|
btnBox->getButton(LtsWidgets::DialogButton::Ok)->hide();
|
|
|
|
|
|
QHBoxLayout *hLayFrom = new QHBoxLayout();
|
|
hLayFrom->addWidget(lblFrom);
|
|
hLayFrom->addWidget(lblSender);
|
|
hLayFrom->addStretch(1);
|
|
|
|
QVBoxLayout *lay = new QVBoxLayout(contentPopup);
|
|
lay->addWidget(lblTitle);
|
|
lay->addWidget(line);
|
|
lay->addLayout(hLayFrom);
|
|
lay->addWidget(line2);
|
|
lay->addWidget(scrollArea);
|
|
lay->addWidget(btnBox);
|
|
|
|
contentPopup->setLayout(lay);
|
|
contentPopup->setMinimumSize(m_session->baseLayoutWidget()->size()/2.0);
|
|
|
|
|
|
contentPopup->show();
|
|
}
|
|
|
|
}
|