Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+234
@@ -0,0 +1,234 @@
|
||||
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Dialog to create a new online report
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-02-27
|
||||
*/
|
||||
|
||||
#include "alm_participant_dialog.h"
|
||||
#include "ui_alm_participant_dialog.h"
|
||||
#include "alm_config_participant_dialog.h"
|
||||
#include "alm_participant_model.h"
|
||||
|
||||
#include <AdvancedSymbology/asb_data_plugin_interface.h>
|
||||
#include <ParticipantManagement/Gui/Common/participant_edit_model.h>
|
||||
#include <ParticipantManagement/ppm_gui_combobox_plugin_interface.h>
|
||||
|
||||
#include <QTreeView>
|
||||
#include <LtsPrinting/printing.h>
|
||||
|
||||
namespace ParticipantAlarms
|
||||
{
|
||||
int ParticipantsDialog::s_preselectedParty = -1;
|
||||
|
||||
ParticipantsDialog::ParticipantsDialog(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent)
|
||||
, m_session(nullptr)
|
||||
, m_almDtc(nullptr)
|
||||
, m_almFtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_participantModel(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_ui(new Ui::ParticipantsDialog)
|
||||
, m_logger(AlarmManagement::getLogger("ParticipantsDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ParticipantsDialog::onAddButtonClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ParticipantsDialog::onPrint);
|
||||
//m_buttonBox->getButton(LtsWidgets::DialogButton::_change_)->hide();
|
||||
|
||||
m_ui->cbAllParticipants->setVisible(false);
|
||||
// m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Assign_Participant_Alarms"));
|
||||
}
|
||||
|
||||
ParticipantsDialog::~ParticipantsDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ParticipantsDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Assign Participant Alarms"));
|
||||
}
|
||||
|
||||
bool ParticipantsDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Dtc> &almDtc,
|
||||
const std::shared_ptr<AlarmManagement::Interface::Ftc> &almFtc,
|
||||
const std::shared_ptr<ParticipantManagement::ForeignGuiComboboxInterface> &ppmGuiCbxIfc)
|
||||
{
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_almDtc = almDtc;
|
||||
m_almFtc = almFtc;
|
||||
m_session = session;
|
||||
|
||||
if (m_ppmDtc == nullptr ||
|
||||
!ppmDtc->enableDynamicParticipantData() ||
|
||||
!ppmDtc->enableParticipant())
|
||||
return false;
|
||||
|
||||
if (m_almFtc == nullptr ||
|
||||
!almFtc->enableConfigureAlarms())
|
||||
return false;
|
||||
|
||||
std::shared_ptr<AdvancedSymbology::ForeignDataInterface> asbIfc;
|
||||
m_session->getForeignDataInterface<AdvancedSymbology::DataInterface>(asbIfc);
|
||||
m_participantModel = new ParticipantAlarms::ParticipantAlarmModel(this,
|
||||
m_ppmDtc,
|
||||
asbIfc);
|
||||
m_participantProxyModel = new ParticipantManagement::ParticipantTreeFilterProxyModel(this);
|
||||
m_participantProxyModel->setSourceModel(m_participantModel);
|
||||
m_participantProxyModel->setRecursiveFilteringEnabled(true);
|
||||
|
||||
m_ui->dvParticipants->setModel(m_participantProxyModel);
|
||||
connect(m_ui->cbParty,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ParticipantsDialog::onCbPartyChanged);
|
||||
connect(m_ui->cbAllParticipants, &QCheckBox::clicked,
|
||||
m_ui->dvParticipants, &LtsDataView::LtsDataView::setDisabled);
|
||||
connect(m_ui->dvParticipants, &LtsDataView::LtsDataView::selectionChanged,
|
||||
this, &ParticipantsDialog::onSelectionChanged);
|
||||
connect(m_ui->dvParticipants, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &ParticipantsDialog::onDoubleClicked);
|
||||
connect(m_ui->cbAllParticipants, &QCheckBox::clicked,
|
||||
this, [this](bool checked)
|
||||
{
|
||||
if (checked)
|
||||
m_ui->dvParticipants->treeView()->selectAll();
|
||||
else
|
||||
m_ui->dvParticipants->treeView()->clearSelection();
|
||||
});
|
||||
|
||||
ppmGuiCbxIfc->fillPartyComboBox(m_ui->cbParty);
|
||||
const int idx = m_ui->cbParty->findData(s_preselectedParty);
|
||||
if (idx >= 0)
|
||||
m_ui->cbParty->setCurrentIndex(idx);
|
||||
onCbPartyChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onSelectionChanged()
|
||||
{
|
||||
bool configureAlarms = false;
|
||||
DEBUG_LOG(m_logger) << "onSelectionChanged";
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->dvParticipants->selectedRows();
|
||||
|
||||
for (const QModelIndex &index : currentlySelectedParticipants)
|
||||
{
|
||||
const ParticipantManagement::ParticipantData data(m_participantModel->getParticipantData(index));
|
||||
if ((data.equipmentNumber().is_set() && data.equipmentNumber().get() > 0) ||
|
||||
m_ppmDtc->type(data.typeId()).typeClass() == ParticipantManagement::TypeClass_def::Unit)
|
||||
configureAlarms = true;
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected row =" << index.row() << " column=" << index.column();
|
||||
|
||||
}
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, configureAlarms);
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onCbPartyChanged()
|
||||
{
|
||||
const int curPartyId = m_ui->cbParty->currentData().toInt();
|
||||
s_preselectedParty = curPartyId;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_participantModel->onReinitModel(curPartyId);
|
||||
m_ui->dvParticipants->expandAll();
|
||||
if (m_ui->cbAllParticipants->isChecked())
|
||||
m_ui->dvParticipants->treeView()->selectAll();
|
||||
m_ui->dvParticipants->resizeHeadersByContent();
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onAddButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onAddButtonClicked";
|
||||
// get participant IDs ---
|
||||
m_participantVector.clear();
|
||||
m_equipmentVector.clear();
|
||||
if (!m_ui->cbAllParticipants->isChecked())
|
||||
{
|
||||
const QModelIndexList currentlySelectedParticipants = m_ui->dvParticipants->selectedRows();
|
||||
|
||||
for (const QModelIndex &index : currentlySelectedParticipants)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setChildrenSelected: " << index.row() << " column=" << index.column();
|
||||
setChildrenSelected(index);
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex participantIndex = m_ui->dvParticipants->currentIndex();
|
||||
ParticipantManagement::ParticipantData data = m_participantModel->getParticipantData(participantIndex);
|
||||
DEBUG_LOG(m_logger) << "current participantId = " << data.id();
|
||||
m_participantVector.push_back(data.id());
|
||||
|
||||
const auto partData = m_participantModel->getParticipantData(participantIndex);
|
||||
addDialog(LtsWidgets::initDialog(new ConfigParticipantsDialog(this),
|
||||
m_ppmDtc, m_almDtc, m_almFtc, partData, m_participantVector, m_equipmentVector),
|
||||
m_menuGroup, QStringLiteral("ConfigAlarms%1").arg(partData.id()));
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dvParticipants->treeView());
|
||||
}
|
||||
|
||||
void ParticipantsDialog::setChildrenSelected(const QModelIndex &parent)
|
||||
{
|
||||
if (!(parent.isValid() &&
|
||||
m_participantModel->hasChildren(parent)))
|
||||
return;
|
||||
|
||||
const int rc = m_participantModel->rowCount(parent);
|
||||
for (int currentRow = 0; currentRow < rc; ++currentRow)
|
||||
{
|
||||
QModelIndex childIndex = m_participantModel->index(currentRow, 0, parent);
|
||||
|
||||
if (m_participantModel->hasChildren(childIndex))
|
||||
setChildrenSelected(childIndex);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Setting row "
|
||||
<< childIndex.row()
|
||||
<< " selected";
|
||||
|
||||
ParticipantManagement::ParticipantData data = m_participantModel->getParticipantData(childIndex);
|
||||
DEBUG_LOG(m_logger) << "append participantId = " << data.id();
|
||||
m_participantVector.push_back(data.id());
|
||||
if (data.equipmentNumber().is_set())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "append equipmentNumber = " << data.equipmentNumber().get();
|
||||
m_equipmentVector.push_back(data.equipmentNumber().get());
|
||||
}
|
||||
|
||||
m_ui->dvParticipants->selectionModel()->select(m_participantProxyModel->mapFromSource(childIndex), QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
}
|
||||
}
|
||||
|
||||
void ParticipantsDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->dvParticipants->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onConfigureAlarmsReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onConfigureAlarmsReply" << replyObject.str();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void ParticipantsDialog::onDoubleClicked()
|
||||
{
|
||||
if (!m_buttonBox->isButtonEnabled(LtsWidgets::DialogButton::Edit))
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "onDoubleClicked";
|
||||
onAddButtonClicked();
|
||||
}
|
||||
|
||||
} // namespace Messaging
|
||||
|
||||
Reference in new issue
Block a user