135 lines
4.0 KiB
C++
Executable File
135 lines
4.0 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* The EditVideoTeamDialog allows to set data for a VideoTeam
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Hannes Baeuerle, SLSE, 2017-07-25
|
|
*/
|
|
|
|
#include "avm_mvs_edit_dialog.h"
|
|
#include "ui_avm_mvs_edit_dialog.h"
|
|
|
|
#include <LtsUtilsSettings/settings.h>
|
|
|
|
namespace AudioVideoManagement
|
|
{
|
|
|
|
EditVideoTeamDialog::EditVideoTeamDialog(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc, int32_t exerciseId, QWidget *parent)
|
|
: EditVideoTeamDialog(0, avmDtc, exerciseId, parent)
|
|
{
|
|
slotChangesMade();
|
|
init();
|
|
m_uiRequirements->addRequirement({m_ui->lblStreamName, [this]() { return (m_ui->leStreamName->text().size() > 0); }});
|
|
|
|
onCurrentTeamChanged();
|
|
}
|
|
|
|
EditVideoTeamDialog::EditVideoTeamDialog(int32_t id, const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc, int32_t exerciseId, const VideoTeam &team, QWidget *parent)
|
|
: EditVideoTeamDialog(id, avmDtc, exerciseId, parent)
|
|
{
|
|
m_videoTeam = team;
|
|
QString name = QString::fromStdString(m_videoTeam.name());
|
|
if (!m_teamsToIndex.contains(name))
|
|
{
|
|
m_teamsToIndex.insert(name, m_ui->cbIdentifier->count());
|
|
m_ui->cbIdentifier->addItem(name, m_takenTeams.value(name, 0));
|
|
}
|
|
|
|
m_ui->cbIdentifier->setCurrentIndex(m_teamsToIndex.value(name, 0));
|
|
m_uiRequirements->addRequirement({m_ui->lblStreamName, [this]() { return (m_ui->leStreamName->text().size() > 0); }});
|
|
|
|
m_ui->leStreamName->setText(QString::fromStdString((m_videoTeam.streamName())));
|
|
}
|
|
|
|
EditVideoTeamDialog::EditVideoTeamDialog(int32_t id, const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc, int32_t exerciseId, QWidget *parent)
|
|
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
|
, m_ui(new Ui::EditVideoTeamDialog)
|
|
, m_exerciseId(exerciseId)
|
|
, m_id(id)
|
|
, m_avmDtc(avmDtc)
|
|
, m_logger(getLogger("EditVideoTeamDialog"))
|
|
{
|
|
Q_ASSERT(m_id >= 0);
|
|
m_ui->setupUi(this);
|
|
init();
|
|
setOnlineHelpFilename(QStringLiteral("Situation-Configuration_Video_Teams"));
|
|
}
|
|
|
|
EditVideoTeamDialog::~EditVideoTeamDialog()
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
void EditVideoTeamDialog::retranslate()
|
|
{
|
|
translate(m_ui, QString(), m_id == 0, tr("Mobile Video Team"));
|
|
}
|
|
|
|
bool EditVideoTeamDialog::apply()
|
|
{
|
|
AudioVideoManagement::VideoTeamModifyRequest request;
|
|
m_id = m_videoTeam.id();
|
|
request.id(m_videoTeam.id());
|
|
request.name(m_videoTeam.name());
|
|
request.ssrc(m_videoTeam.ssrc());
|
|
request.vtPort(m_videoTeam.vtPort());
|
|
request.streamName() = m_ui->leStreamName->text().toStdString();
|
|
request.exerciseId(m_exerciseId);
|
|
emit modifyRequest(request);
|
|
return true;
|
|
}
|
|
|
|
void EditVideoTeamDialog::init()
|
|
{
|
|
onCheckTakenTeams();
|
|
if (m_videoTeam.id() > 0)
|
|
m_ui->cbIdentifier->setEnabled(false);
|
|
|
|
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::videoTeamChanged, this, &EditVideoTeamDialog::onCheckTakenTeams);
|
|
connect(m_ui->cbIdentifier, QOverload<int>::of(&LtsWidgets::LtsComboBox::currentIndexChanged), this, &EditVideoTeamDialog::onCurrentTeamChanged);
|
|
}
|
|
|
|
void EditVideoTeamDialog::onCheckTakenTeams()
|
|
{
|
|
|
|
int currentTeam = m_ui->cbIdentifier->currentData().toInt();
|
|
int index = -1;
|
|
|
|
if (m_ui->cbIdentifier->currentIndex() >= 0)
|
|
return;
|
|
|
|
m_ui->cbIdentifier->clear();
|
|
m_takenTeams.clear();
|
|
m_teamsToIndex.clear();
|
|
|
|
QMap<int32_t, AudioVideoManagement::VideoTeam> teams = m_avmDtc->videoTeams();
|
|
|
|
for (auto it = teams.constBegin(); it != teams.constEnd(); ++it)
|
|
{
|
|
QString team = QString::fromStdString(it.value().name());
|
|
|
|
if (m_avmDtc->isFreeVideoTeam(m_exerciseId, it.key()))
|
|
{
|
|
if (currentTeam == it.key())
|
|
index = m_ui->cbIdentifier->count();
|
|
|
|
m_teamsToIndex.insert(team, m_ui->cbIdentifier->count());
|
|
m_ui->cbIdentifier->addItem(team, QVariant::fromValue(it.value().id()));
|
|
}
|
|
else
|
|
m_takenTeams.insert(team, it.key());
|
|
}
|
|
|
|
if (index > 0)
|
|
m_ui->cbIdentifier->setCurrentIndex(index);
|
|
|
|
}
|
|
|
|
void EditVideoTeamDialog::onCurrentTeamChanged()
|
|
{
|
|
m_videoTeam = m_avmDtc->videoTeam(m_ui->cbIdentifier->currentData().toInt());
|
|
}
|
|
|
|
} //namespace AudioVideoManagement
|