Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+185
@@ -0,0 +1,185 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* GUI Plugin for SituationReplayManagement - Replay Partition Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-07-19
|
||||
*/
|
||||
|
||||
|
||||
#include "replay_dialog.h"
|
||||
#include "ui_replay_dialog.h"
|
||||
#include "replay_dialog_model.h"
|
||||
#include "CustomView/srm_replay.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
|
||||
#include <QModelIndexList>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace SituationReplayManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// SituationReplayManagementDialog
|
||||
//---------------------------------
|
||||
SituationReplayManagementDialog::SituationReplayManagementDialog(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_session(session)
|
||||
, m_model(nullptr)
|
||||
, m_ui(new Ui::SituationReplayManagementDialog)
|
||||
, m_srmForeign(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger("SituationReplayManagementDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add,
|
||||
this, &SituationReplayManagementDialog::onAddReplayPartition);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove,
|
||||
this, &SituationReplayManagementDialog::onRemoveReplayPartition);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print,
|
||||
this, &SituationReplayManagementDialog::onPrint);
|
||||
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Yes, tr("Start Replay"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Yes, // renamed to "Start"
|
||||
this, &SituationReplayManagementDialog::slotStartReplay);
|
||||
|
||||
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Replay_Management"));
|
||||
}
|
||||
|
||||
|
||||
SituationReplayManagementDialog::~SituationReplayManagementDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void SituationReplayManagementDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Replay Management"));
|
||||
}
|
||||
|
||||
void SituationReplayManagementDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
|
||||
void SituationReplayManagementDialog::slotStartReplay()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
const Core::ReplayPartition rp = m_model->getRowData(idx.row());
|
||||
|
||||
int replayPartition = rp.id();
|
||||
|
||||
if (replayPartition < 1)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("This Replay Partition is not valid!"), tr("Cannot start Replay"));
|
||||
return;
|
||||
}
|
||||
|
||||
const LtsSession::DdsConnectionParams connParams(rp);
|
||||
m_session->getSessionManager()->createSession(connParams, true, false /* no payloads! */);
|
||||
}
|
||||
|
||||
|
||||
bool SituationReplayManagementDialog::init(const std::shared_ptr<Core::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<SituationReplayManagement::ForeignDataInterface> &srmForeign)
|
||||
{
|
||||
m_srmForeign = srmForeign;
|
||||
m_model = new ReplayPartitionDialogModel(this);
|
||||
m_model->initModel(m_session->exerciseId(), dtc);
|
||||
m_ui->widget->setModel(m_model, [this]() { return new CustomViewReplay(this); });
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &SituationReplayManagementDialog::enaDisa);
|
||||
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void SituationReplayManagementDialog::enaDisa()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (cntSelectedRows > 0));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Yes, (cntSelectedRows == 1));
|
||||
}
|
||||
|
||||
|
||||
void SituationReplayManagementDialog::onAddReplayPartition()
|
||||
{
|
||||
if (!m_session)
|
||||
return;
|
||||
|
||||
const int partitionId = m_session->partitionId();
|
||||
try
|
||||
{
|
||||
m_srmForeign->replayPartitionCreateRequest(partitionId,
|
||||
LtsSessionData::LtsSessionData::getInstance()->getWorkstationId(),
|
||||
LtsSessionData::LtsSessionData::getInstance()->getOperatorId(),
|
||||
Core::ReplayType::SituationData);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("Failed to create replay partition!"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SituationReplayManagementDialog::onRemoveReplayPartition()
|
||||
{
|
||||
QVector<QPair<int, int> > toDelete;
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
|
||||
for (auto i = selectedRows.constBegin(); i != selectedRows.constEnd(); ++i)
|
||||
{
|
||||
const Core::ReplayPartition &rp = m_model->getRowData((*i).row());
|
||||
int id = rp.id();
|
||||
int wsId = rp.workstationId();
|
||||
|
||||
if (id < 1 || wsId < 1) // invalid!
|
||||
continue;
|
||||
|
||||
QPair<int, int> p(id, wsId);
|
||||
|
||||
toDelete.append(p);
|
||||
}
|
||||
|
||||
for (auto i = toDelete.constBegin(); i != toDelete.constEnd(); ++i)
|
||||
{
|
||||
QPair<int, int> p = *i;
|
||||
|
||||
try
|
||||
{
|
||||
m_srmForeign->replayPartitionRemoveRequest(p.first, p.second, 0);
|
||||
} // no more remove on error
|
||||
catch(...)
|
||||
{
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("Failed to remove replay partition!"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SituationReplayManagementDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
|
||||
}
|
||||
} // namespace SituationReplayManagement
|
||||
Reference in new issue
Block a user