154 lines
4.2 KiB
C++
Executable File
154 lines
4.2 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* HMI Plugin for ParticipantManagement - Party View
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Patric Karwat, SLSE, 2016-11-11
|
|
*/
|
|
|
|
#include "ppm_party_view.h"
|
|
#include "ui_ppm_party_view.h"
|
|
#include "participant_show.h"
|
|
|
|
#include <LtsSession/lts_session_manager.h>
|
|
#include <PluginInterfaces/gui_plugin_interface.h>
|
|
|
|
#include <LtsPrinting/printing.h>
|
|
#include <QTreeView>
|
|
|
|
namespace ParticipantManagement
|
|
{
|
|
|
|
PartyView::PartyView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
|
|
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
|
, m_menuGroup(menuGroup)
|
|
, m_model(nullptr)
|
|
, m_dtc(nullptr)
|
|
, m_ftc(nullptr)
|
|
, m_session(session)
|
|
, m_ui(new Ui::PartyView)
|
|
, m_logger(getLogger("PartyView"))
|
|
{
|
|
m_ui->setupUi(this);
|
|
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
|
|
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
|
this, &PartyView::onSelectionChanged);
|
|
|
|
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked,
|
|
this, &PartyView::onShowParty);
|
|
|
|
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &PartyView::onShowParty);
|
|
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &PartyView::onPrint);
|
|
|
|
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Load, false);
|
|
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Print, false);
|
|
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, false);
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
|
|
|
setOnlineHelpFilename(QStringLiteral("Situation-Operational_Planing"));
|
|
}
|
|
|
|
PartyView::~PartyView()
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
void PartyView::retranslate()
|
|
{
|
|
translate(m_ui, tr("Operational Planing"));
|
|
}
|
|
|
|
bool PartyView::init(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &dtc,
|
|
const std::shared_ptr<ParticipantManagement::Interface::Ftc> &ftc,
|
|
const std::shared_ptr<ForeignGuiComboboxInterface> &ppmGuiCbxIfc, const std::shared_ptr<AdvancedSymbology::ForeignDataInterface> &asbIfc)
|
|
{
|
|
if (!dtc || !ftc || !ppmGuiCbxIfc)
|
|
return false;
|
|
|
|
m_dtc = dtc;
|
|
m_ftc = ftc;
|
|
m_ppmGuiCbxIfc = ppmGuiCbxIfc;
|
|
m_asbIfc = asbIfc;
|
|
m_model = new PartyModel(this);
|
|
m_model->initModel(m_dtc);
|
|
m_ui->widget->setModel(m_model);
|
|
|
|
#ifndef LTS_DEBUG
|
|
m_ui->widget->hideColumn(PartyModel::Id);
|
|
#endif
|
|
m_ui->widget->setSortingEnabled(false);
|
|
m_ui->widget->setSortIndicator(-1, Qt::AscendingOrder);
|
|
|
|
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Show, true);
|
|
|
|
return true;
|
|
}
|
|
|
|
void PartyView::onSelectionChanged()
|
|
{
|
|
const QModelIndex idx = m_ui->widget->currentIndex();
|
|
|
|
int row = idx.row();
|
|
|
|
if (m_ui->widget->selectedRows().size() == 0
|
|
|| row < 0)
|
|
{
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
|
|
|
return;
|
|
}
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, true);
|
|
}
|
|
|
|
void PartyView::onShowParty()
|
|
{
|
|
const QModelIndex idx = m_ui->widget->currentIndex();
|
|
|
|
int row = idx.row();
|
|
if (row < 0)
|
|
return;
|
|
|
|
PartyData party = m_model->getRowData(row);
|
|
if (party.id < 0)
|
|
{
|
|
// Show Operator-List
|
|
std::shared_ptr<OperatorManagement::OverviewForeignGuiInterface> opmOverviewIfc;
|
|
if (m_session->getForeignGuiInterface(opmOverviewIfc))
|
|
{
|
|
opmOverviewIfc->showOperators(tr("Operational Planning - Operators"));
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
bool asSupportService = false;
|
|
ParticipantShow *diag = new ParticipantShow(m_session, asSupportService, this);
|
|
if (diag->init(m_dtc, m_ftc, m_asbIfc, party.id , party.name))
|
|
addDialog(diag, m_menuGroup, QStringLiteral("Participants") + QString::number(party.id), LtsWidgets::LayoutArea::eDialogTab);
|
|
else
|
|
delete diag;
|
|
}
|
|
}
|
|
|
|
|
|
void PartyView::onPrint()
|
|
{
|
|
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
|
|
}
|
|
|
|
void PartyView::tableColumnOrganiserSetting()
|
|
{
|
|
//LtsColumnOrganiser
|
|
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace ParticipantManagement
|