Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+170
@@ -0,0 +1,170 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for Messaging - Messaging Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#include "alm_history.h"
|
||||
#include "ui_alm_history.h"
|
||||
|
||||
#include <Plugins/AlarmManagement/Gui/Common/alm_history_alarm_model.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AlarmManagement
|
||||
{
|
||||
|
||||
AlarmView::AlarmView(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_alarmHistoryModel(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_sitMapGuiIfc(nullptr)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::AlarmView)
|
||||
, m_logger(getLogger("AlarmView"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " --- AlarmView Konstruktor() ";
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
|
||||
// connects fuer Widgetaenderungen
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &AlarmView::onSelectionChanged);
|
||||
|
||||
// Double Clicked
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &AlarmView::onShowAlarm);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print,
|
||||
this, &AlarmView::onPrint);
|
||||
// Create Remove-Button
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &AlarmView::onRemoveAlarm);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
// Center Map Button
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &AlarmView::onCenterAlarm);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Alarm_History"));
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
AlarmView::~AlarmView()
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- AlarmView Destruktor() ";
|
||||
m_sitMapGuiIfc = nullptr;
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AlarmView::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Alarm History"));
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setText(tr("Center Map"));
|
||||
}
|
||||
|
||||
bool AlarmView::init(const std::shared_ptr<AlarmManagement::Interface::Dtc> &dtc,
|
||||
AlarmHistoryModel *alarmHistoryModel)
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- init() ";
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_alarmHistoryModel = alarmHistoryModel;
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- AlarmView::init ";
|
||||
m_proxyModel = new AlarmHistoryProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_alarmHistoryModel);
|
||||
m_ui->widget->setModel(m_proxyModel);
|
||||
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::Id);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::ParticipantId);
|
||||
m_ui->widget->hideColumn(AlarmHistoryModel::AesId);
|
||||
#endif
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Edit)->setIcon(QIcon(QStringLiteral("icon:center_to_object.svg")));
|
||||
m_session->getForeignGuiInterface<SituationMap::ForeignGuiInterface>(m_sitMapGuiIfc);
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AlarmView::onSelectionChanged()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1); // onCenterAlarm
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows > 0);
|
||||
} // end of onSelectionChanged()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AlarmView::onShowAlarm()
|
||||
{
|
||||
INFO_LOG(m_logger) << "--- onShowMAlarm() ";
|
||||
} // end of onShowAlarm()
|
||||
|
||||
|
||||
// Window to remove an Alarm
|
||||
void AlarmView::onRemoveAlarm()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onRemoveAlarm selectedRows.size"
|
||||
<< m_ui->widget->selectedRows().size();
|
||||
|
||||
const QModelIndexList idxList = m_ui->widget->selectedRows();
|
||||
QVector<int> rowsToRemove;
|
||||
rowsToRemove.reserve(idxList.size());
|
||||
for (const auto &idx : idxList)
|
||||
rowsToRemove.push_back(idx.row());
|
||||
std::sort(rowsToRemove.begin(), rowsToRemove.end(), std::greater<int>());
|
||||
for (int i = 0; i < rowsToRemove.length(); i++)
|
||||
m_alarmHistoryModel->removeRow(rowsToRemove.at(i));
|
||||
} // end of onRemoveAlarm()
|
||||
|
||||
// Window to center an Alarm to participant
|
||||
void AlarmView::onCenterAlarm()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onCenterAlarm";
|
||||
if (!m_sitMapGuiIfc)
|
||||
return;
|
||||
const QModelIndexList indexList = m_ui->widget->selectedRows();
|
||||
if (indexList.isEmpty())
|
||||
return;
|
||||
const QModelIndex &index = indexList.first();
|
||||
|
||||
const QModelIndex indexPosi = m_alarmHistoryModel->index(index.row(), AlarmHistoryModel::Position, index.parent());
|
||||
const QPointF &position = indexPosi.data(Qt::UserRole).toPointF(); // Qt::UserRole to get Position as value, not as string
|
||||
|
||||
if (!position.isNull())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " position=" << position.x() << " - " << position.y();
|
||||
m_sitMapGuiIfc->setCenterPoint(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QModelIndex &indexParticipantId = m_alarmHistoryModel->index(index.row(), AlarmHistoryModel::ParticipantId, index.parent());
|
||||
const int participantId = indexParticipantId.data().toInt();
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " participantId=" << participantId;
|
||||
m_sitMapGuiIfc->centerMapToParticipant(participantId);
|
||||
}
|
||||
} // end of onCenterAlarm()
|
||||
|
||||
void AlarmView::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
void AlarmView::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
} // namespace AlarmManagement
|
||||
Reference in new issue
Block a user