Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+44
@@ -0,0 +1,44 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Hannes Baeuerle, SLSE, 2017-08-18
|
||||
#
|
||||
|
||||
SET(avm_tvc_gui_SRCS
|
||||
avm_training_voice_gui_plugin.cpp
|
||||
avm_training_voice_gui_plugin.h
|
||||
avm_training_voice_communication_dialog_model.h
|
||||
avm_training_voice_communication_dialog_model.cpp
|
||||
avm_training_voice_communication_dialog.cpp
|
||||
avm_training_voice_communication_dialog.h
|
||||
avm_edit_training_voice_communication_dialog.cpp
|
||||
avm_edit_training_voice_communication_dialog.h
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(avm_tvc_gui_SRCS
|
||||
avm_training_voice_communication_dialog.ui
|
||||
avm_edit_training_voice_communication_dialog.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS avmTrainingVoiceGuiPlugin MODULE ${avm_tvc_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(avmTrainingVoiceGuiPlugin
|
||||
LtsPrinting
|
||||
nglwidgets
|
||||
NGLLogger
|
||||
ngltools
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
AvmDataPluginInterface
|
||||
FlmDataPluginInterface
|
||||
svcAvmCommon
|
||||
AvmShared
|
||||
svcExmClient
|
||||
Qt5::Widgets
|
||||
LtsWidgets
|
||||
LtsDataView
|
||||
LtsUtilsGuiDds
|
||||
LtsUtilsSettings
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(avmTrainingVoiceGuiPlugin)
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The EditTrainingVoiceCommunicationDialog allows to set data for a Training Voice Communication Config
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-07-25
|
||||
*/
|
||||
|
||||
#include "avm_edit_training_voice_communication_dialog.h"
|
||||
#include "ui_avm_edit_training_voice_communication_dialog.h"
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/av_helper.h>
|
||||
#include <AudioVideoManagement/Shared/project_settings.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <QSignalBlocker>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool isActive(ExerciseManagement::ExerciseState state)
|
||||
{
|
||||
return (state == ExerciseManagement::ExerciseState::Started ||
|
||||
state == ExerciseManagement::ExerciseState::Paused);
|
||||
}
|
||||
|
||||
const QString &NO_CHANNEL()
|
||||
{
|
||||
static const QString noChannel = QStringLiteral("---");
|
||||
return noChannel;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
EditTrainingVoiceCommunicationDialog::EditTrainingVoiceCommunicationDialog(const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc, int32_t exerciseId, QWidget *parent)
|
||||
: EditTrainingVoiceCommunicationDialog(0, avmDtc, avmFtc, exmDtc, exerciseId, parent)
|
||||
{
|
||||
m_ui->chkRecording->setChecked(true);
|
||||
m_ui->chkIsGlobal->setChecked(false);
|
||||
initCbChannelsForCreate();
|
||||
}
|
||||
|
||||
EditTrainingVoiceCommunicationDialog::EditTrainingVoiceCommunicationDialog(const TvcConfig &config, const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc, int32_t exerciseId, QWidget *parent)
|
||||
: EditTrainingVoiceCommunicationDialog(config.id(), avmDtc, avmFtc, exmDtc, exerciseId, parent)
|
||||
{
|
||||
m_ui->leInfo->setText(QString::fromStdString(config.info()));
|
||||
m_ui->chkRecording->setChecked(config.recording());
|
||||
|
||||
{
|
||||
QSignalBlocker blockSignals(m_ui->chkIsGlobal);
|
||||
m_ui->chkIsGlobal->setChecked(!config.exerciseId().is_set());
|
||||
}
|
||||
|
||||
m_ui->leRadioCircuit->setText(QString::fromStdString(config.radioCircuit()));
|
||||
initCbChannelsForEdit(config.tetraChannelId());
|
||||
}
|
||||
|
||||
EditTrainingVoiceCommunicationDialog::EditTrainingVoiceCommunicationDialog(int32_t id, const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc, int32_t exerciseId, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::EditTrainingVoiceCommunicationDialog)
|
||||
, m_id(id)
|
||||
, m_exerciseId(exerciseId)
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_avmFtc(avmFtc)
|
||||
, m_exmDtc(exmDtc)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger("EditTrainingVoiceCommunicationDialog"))
|
||||
{
|
||||
Q_ASSERT(id >= 0);
|
||||
Q_ASSERT(exmDtc);
|
||||
m_ui->setupUi(this);
|
||||
checkToDisableChkRecording();
|
||||
init();
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Training_Voice_Communication"));
|
||||
}
|
||||
|
||||
EditTrainingVoiceCommunicationDialog::~EditTrainingVoiceCommunicationDialog() = default;
|
||||
|
||||
void EditTrainingVoiceCommunicationDialog::checkToDisableChkRecording()
|
||||
{
|
||||
if (ProjectSettings::isAlwaysRecording())
|
||||
{
|
||||
m_ui->lbRecording->hide();
|
||||
m_ui->chkRecording->hide();
|
||||
}
|
||||
}
|
||||
|
||||
void EditTrainingVoiceCommunicationDialog::retranslate()
|
||||
{
|
||||
translate(m_ui.get(), QString(), m_id == 0 , tr("Training Voice Communication"));
|
||||
}
|
||||
|
||||
bool EditTrainingVoiceCommunicationDialog::apply()
|
||||
{
|
||||
ModifyTvcConfigRequest request;
|
||||
|
||||
request.tetraChannelId(m_ui->cbChannel->currentData().toInt());
|
||||
Q_ASSERT(request.tetraChannelId() > 0);
|
||||
request.radioCircuit(m_ui->leRadioCircuit->text().toStdString());
|
||||
request.recording(m_ui->chkRecording->isChecked());
|
||||
request.info(m_ui->leInfo->text().toStdString());
|
||||
request.id(m_id);
|
||||
|
||||
bool isLocal = !m_ui->chkIsGlobal->isChecked();
|
||||
if (isLocal)
|
||||
request.exerciseId(m_exerciseId);
|
||||
|
||||
return m_requestHelper->startSingleRequest([this, request] () { return m_avmFtc->modifyTvcConfigRequest(request, this); });
|
||||
}
|
||||
|
||||
void EditTrainingVoiceCommunicationDialog::onModifyTvcConfigReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
void EditTrainingVoiceCommunicationDialog::init()
|
||||
{
|
||||
connect(m_ui->chkIsGlobal, &QCheckBox::toggled, this, &EditTrainingVoiceCommunicationDialog::updateFreeChannelsAndTakenNames);
|
||||
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::tvcConfigChanged, this, &EditTrainingVoiceCommunicationDialog::updateFreeChannelsAndTakenNames);
|
||||
connect(m_exmDtc, &ExerciseManagement::Interface::Dtc::exerciseChanged, this, &EditTrainingVoiceCommunicationDialog::updateFreeChannelsAndTakenNames);
|
||||
|
||||
m_uiRequirements->addRequirement({m_ui->lbRadioCircuit, [this] () { return isNameValid(m_ui->leRadioCircuit->text()); }, tr("name invalid")});
|
||||
m_uiRequirements->addRequirement({m_ui->lbChannel, [this] () { return m_ui->cbChannel->currentIndex() > 0; }, tr("channel invalid")});
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when one of the following changed:
|
||||
* - Some Exercise
|
||||
* - Some TvcConfig
|
||||
* - isGlobal-Flag for this TvcConfig
|
||||
*/
|
||||
void EditTrainingVoiceCommunicationDialog::updateFreeChannelsAndTakenNames()
|
||||
{
|
||||
bool isGlobal = m_ui->chkIsGlobal->isChecked();
|
||||
const auto exercises = exercisesToConsider();
|
||||
const auto exercisesIgnore = exercisesToIgnore();
|
||||
|
||||
m_takenNames.clear();
|
||||
QVector<int> freeChannels = m_avmDtc->tvcChannels().keys().toVector();
|
||||
const auto allTvcConfigs = m_avmDtc->tvcConfigs();
|
||||
for (const auto &tvcConfig : allTvcConfigs)
|
||||
{
|
||||
if (m_id > 0 && m_id == tvcConfig.id())
|
||||
continue; // consider the channel of the TvcConfig we are editing right now as free
|
||||
|
||||
if (!isGlobal)
|
||||
{
|
||||
if (tvcConfig.exerciseId().is_set() && !exercises.contains(tvcConfig.exerciseId().get()))
|
||||
continue;
|
||||
}
|
||||
if (tvcConfig.exerciseId().is_set() && exercisesIgnore.contains(tvcConfig.exerciseId().get()))
|
||||
continue;
|
||||
m_takenNames.push_back(QString::fromStdString(tvcConfig.radioCircuit()));
|
||||
freeChannels.removeOne(tvcConfig.tetraChannelId());
|
||||
}
|
||||
|
||||
updateCbChannels(std::move(freeChannels));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the channel-Combobox with the given freeChannels and keep the currently
|
||||
* selected channel if possible.
|
||||
*/
|
||||
void EditTrainingVoiceCommunicationDialog::updateCbChannels(QVector<int> &&freeChannels)
|
||||
{
|
||||
Q_ASSERT(m_ui->cbChannel->currentIndex() != -1); // there must be a selected item
|
||||
|
||||
const auto allChannels = m_avmDtc->tvcChannels();
|
||||
|
||||
const auto byName = [&allChannels] (int leftChannelId, int rightChannelId) { return QLatin1String(allChannels[leftChannelId].name().c_str()) < QLatin1String(allChannels[rightChannelId].name().c_str()); };
|
||||
std::sort(freeChannels.begin(), freeChannels.end(), byName);
|
||||
|
||||
int currentlySelctedChannelId = m_ui->cbChannel->currentData().toInt(); // -1 when no channel was selected
|
||||
// check whether the currently selected channel is still available
|
||||
int newlySelectedIndex = 0;
|
||||
if (currentlySelctedChannelId > 0)
|
||||
newlySelectedIndex = freeChannels.indexOf(currentlySelctedChannelId) + 1;
|
||||
|
||||
m_ui->cbChannel->clear();
|
||||
m_ui->cbChannel->addItem(NO_CHANNEL(), -1);
|
||||
for (const auto &channelId : freeChannels)
|
||||
m_ui->cbChannel->addItem(QString::fromStdString(allChannels[channelId].name()), channelId);
|
||||
m_ui->cbChannel->setCurrentIndex(newlySelectedIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the current exercise is active, return all active exercises.
|
||||
* Otherwise, return only the current exercise.
|
||||
*/
|
||||
QVector<int> EditTrainingVoiceCommunicationDialog::exercisesToConsider() const
|
||||
{
|
||||
const auto allExercises_ = m_exmDtc->exercises();
|
||||
|
||||
if (!isActive(allExercises_[m_exerciseId].state()))
|
||||
return {m_exerciseId};
|
||||
|
||||
auto allExercises = allExercises_.values();
|
||||
auto newEnd = std::remove_if(allExercises.begin(), allExercises.end(), [] (const ExerciseManagement::Exercise &ex) { return ex.isDeleted(); }); // remove deleted exercises
|
||||
allExercises.erase(newEnd, allExercises.end());
|
||||
|
||||
QVector<int> toBeConsidered;
|
||||
for (const auto &exercise : qAsConst(allExercises))
|
||||
{
|
||||
if (::isActive(exercise.state()))
|
||||
toBeConsidered.append(exercise.id());
|
||||
}
|
||||
return toBeConsidered;
|
||||
}
|
||||
|
||||
QVector<int> EditTrainingVoiceCommunicationDialog::exercisesToIgnore() const
|
||||
{
|
||||
const auto allExercises = m_exmDtc->exercises();
|
||||
|
||||
auto canBeIgnored = [] (const ExerciseManagement::Exercise &ex) -> bool
|
||||
{
|
||||
return (ex.state() == ExerciseManagement::ExerciseState::Stopped ||
|
||||
ex.state() == ExerciseManagement::ExerciseState::Terminated ||
|
||||
ex.isDeleted());
|
||||
};
|
||||
|
||||
QVector<int> exercisesToIgnore;
|
||||
for (const auto &ex : allExercises)
|
||||
{
|
||||
if (canBeIgnored(ex))
|
||||
exercisesToIgnore += ex.id();
|
||||
}
|
||||
return exercisesToIgnore;
|
||||
}
|
||||
|
||||
void EditTrainingVoiceCommunicationDialog::initCbChannelsForCreate()
|
||||
{
|
||||
Q_ASSERT(m_id == 0);
|
||||
Q_ASSERT(m_ui->cbChannel->count() == 0);
|
||||
m_ui->cbChannel->addItem(NO_CHANNEL(), -1);
|
||||
m_ui->cbChannel->setCurrentIndex(0);
|
||||
updateFreeChannelsAndTakenNames();
|
||||
if (m_ui->cbChannel->count() > 1)
|
||||
m_ui->cbChannel->setCurrentIndex(1); // select the first free channel
|
||||
}
|
||||
|
||||
void EditTrainingVoiceCommunicationDialog::initCbChannelsForEdit(int channelId)
|
||||
{
|
||||
Q_ASSERT(m_id > 0);
|
||||
Q_ASSERT(m_ui->cbChannel->count() == 0);
|
||||
m_ui->cbChannel->addItem(NO_CHANNEL(), -1);
|
||||
m_ui->cbChannel->addItem(QStringLiteral("dummy"), channelId);
|
||||
m_ui->cbChannel->setCurrentIndex(1);
|
||||
updateFreeChannelsAndTakenNames();
|
||||
}
|
||||
|
||||
bool EditTrainingVoiceCommunicationDialog::isNameValid(const QString &name) const
|
||||
{
|
||||
if (!isStreamNameValid(name))
|
||||
return false;
|
||||
if (m_takenNames.contains(name))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
} //namespace AudioVideoManagement
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The EditTrainingVoiceCommunicationDialog allows to set data for a Training Voice Communication Config
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-07-25
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/avm.hpp>
|
||||
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
|
||||
class QCheckBox;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class EditTrainingVoiceCommunicationDialog;
|
||||
}
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class EditTrainingVoiceCommunicationDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ModifyTvcConfigReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* Used to create a new TvcConfig.
|
||||
*/
|
||||
explicit EditTrainingVoiceCommunicationDialog(const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
int32_t exerciseId,
|
||||
QWidget *parent = nullptr);
|
||||
/**
|
||||
* Used for modifying an existing TvcConfig.
|
||||
*/
|
||||
explicit EditTrainingVoiceCommunicationDialog(const TvcConfig &config,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
int32_t exerciseId,
|
||||
QWidget *parent);
|
||||
|
||||
~EditTrainingVoiceCommunicationDialog();
|
||||
|
||||
void retranslate() override;
|
||||
|
||||
protected:
|
||||
bool apply() override;
|
||||
void onModifyTvcConfigReply(const Core::FunctionReplyObject &reply) override;
|
||||
|
||||
private: // methods
|
||||
EditTrainingVoiceCommunicationDialog(int32_t id,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
int32_t exerciseId,
|
||||
QWidget *parent);
|
||||
|
||||
void init();
|
||||
void checkToDisableChkRecording();
|
||||
|
||||
private slots:
|
||||
void updateFreeChannelsAndTakenNames();
|
||||
|
||||
private:
|
||||
void updateCbChannels(QVector<int> &&freeChannels);
|
||||
QVector<int> exercisesToConsider() const;
|
||||
QVector<int> exercisesToIgnore() const;
|
||||
|
||||
void initCbChannelsForCreate();
|
||||
void initCbChannelsForEdit(int channelId);
|
||||
|
||||
bool isNameValid(const QString &name) const;
|
||||
|
||||
private: // attributes
|
||||
std::unique_ptr<Ui::EditTrainingVoiceCommunicationDialog> m_ui;
|
||||
int32_t m_id;
|
||||
int32_t m_exerciseId;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
ExerciseManagement::Interface::Dtc *m_exmDtc;
|
||||
QVector<QString> m_takenNames;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
}; // class EditTrainingVoiceCommunicationDialog
|
||||
} // namespace AudioVideoManagement
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EditTrainingVoiceCommunicationDialog</class>
|
||||
<widget class="QWidget" name="EditTrainingVoiceCommunicationDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>508</width>
|
||||
<height>275</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Asset Stocks</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="4">
|
||||
<widget class="QLineEdit" name="leInfo"/>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QLabel" name="lbInfo">
|
||||
<property name="text">
|
||||
<string>Info:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="lbRecording">
|
||||
<property name="text">
|
||||
<string>Recording:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbChannel">
|
||||
<property name="text">
|
||||
<string>Channel Number:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="LtsWidgets::LtsComboBox" name="cbChannel"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leRadioCircuit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbRadioCircuit">
|
||||
<property name="text">
|
||||
<string>Radio Circuit:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="5">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbIsGlobal">
|
||||
<property name="text">
|
||||
<string>Global:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2" rowspan="4">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="chkIsGlobal">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QCheckBox" name="chkRecording">
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>LtsWidgets/lts_combo_box.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>cbChannel</tabstop>
|
||||
<tabstop>leRadioCircuit</tabstop>
|
||||
<tabstop>chkIsGlobal</tabstop>
|
||||
<tabstop>chkRecording</tabstop>
|
||||
<tabstop>leInfo</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The TrainingVoiceCommunicationDialog provides interactions for TVC assignment
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-07-24
|
||||
*/
|
||||
|
||||
#include "avm_training_voice_communication_dialog.h"
|
||||
#include "ui_avm_training_voice_communication_dialog.h"
|
||||
#include "avm_training_voice_communication_dialog_model.h"
|
||||
#include "avm_edit_training_voice_communication_dialog.h"
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
TrainingVoiceCommunicationDialog::TrainingVoiceCommunicationDialog(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::TrainingVoiceCommunicationDialog)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_avmDtc(nullptr)
|
||||
, m_avmFtc(nullptr)
|
||||
, m_logger(getLogger("TrainingVoiceCommunicationDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Training_Voice_Communication"));
|
||||
}
|
||||
|
||||
TrainingVoiceCommunicationDialog::~TrainingVoiceCommunicationDialog() = default;
|
||||
|
||||
void TrainingVoiceCommunicationDialog::retranslate()
|
||||
{
|
||||
translate(m_ui.get(), tr("Training Voice Communication"));
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool TrainingVoiceCommunicationDialog::init(const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<Interface::Ftc> &avmFtc, ExerciseManagement::Interface::Dtc *exmDtc)
|
||||
{
|
||||
Q_ASSERT(exmDtc);
|
||||
|
||||
if (!(avmDtc->enableTvcChannel() &&
|
||||
avmDtc->enableTvcConfig() &&
|
||||
avmFtc->enableModifyTvcConfig() &&
|
||||
avmFtc->enableRemoveTvcConfig()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_model.reset(new TrainingVoiceCommunicationDialogModel(this));
|
||||
m_filter.reset(new TrainingVoiceCommunicationDialogFilter(m_session->exerciseId(), m_model.get()));
|
||||
|
||||
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
m_exmDtc = exmDtc;
|
||||
|
||||
if (!m_model->init(m_session->exerciseId(), avmDtc))
|
||||
{
|
||||
m_filter.reset();
|
||||
m_model.reset();
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ui->dataView->setModel(m_filter.get());
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &TrainingVoiceCommunicationDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &TrainingVoiceCommunicationDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &TrainingVoiceCommunicationDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &TrainingVoiceCommunicationDialog::onPrint);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &TrainingVoiceCommunicationDialog::onSelectionChanged);
|
||||
|
||||
onSelectionChanged();
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &TrainingVoiceCommunicationDialog::onEditClicked);
|
||||
|
||||
// Save/Load from Library Button
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&TrainingVoiceCommunicationDialog::onImportButtonClicked,
|
||||
&TrainingVoiceCommunicationDialog::onExportButtonClicked);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->dataView->hideColumn(TrainingVoiceCommunicationDialogModel::RECORDING);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onModifyTvcConfigReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onRemoveTvcConfigReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onAddClicked()
|
||||
{
|
||||
EditTrainingVoiceCommunicationDialog *dialog = new EditTrainingVoiceCommunicationDialog(m_avmDtc, m_avmFtc, m_exmDtc, m_session->exerciseId(), this);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("NewTVCConfig"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onEditClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
TvcConfig config = m_model->getRowData(currentIndex.row());
|
||||
|
||||
EditTrainingVoiceCommunicationDialog *dialog = new EditTrainingVoiceCommunicationDialog(config, m_avmDtc, m_avmFtc, m_exmDtc, m_session->exerciseId(), this);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditTVCConfig%1").arg(config.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onRemoveClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
Core::RemoveElementRequest request(m_model->getRowData(currentIndex.row()).id());
|
||||
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->removeTvcConfigRequest(request, this);
|
||||
});
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onSelectionChanged()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, currentIndex.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, currentIndex.isValid());
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// library
|
||||
void TrainingVoiceCommunicationDialog::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_filter->modelToJson();
|
||||
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Xml, m_session->exerciseId(), byteArray);
|
||||
if (fileId > 0)
|
||||
DEBUG_LOG(m_logger) << "Saved file with id = " << fileId;
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Could not save file in library ";
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AVMTrainingVoiceCommunication));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMTrainingVoiceCommunication)))
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Invalid xml file content"),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QVector<ModifyTvcConfigRequest> requests = m_model->jsonToTvcConfigVector(content);
|
||||
for (const auto &request : requests)
|
||||
{
|
||||
m_requestHelper->addRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->modifyTvcConfigRequest(request, this);
|
||||
});
|
||||
}
|
||||
(void) m_requestHelper->startRequests();
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}// namespace AudioVideoManagement
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The TrainingVoiceCommunicationDialog provides interactions for TVC assignment
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-07-24
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class TrainingVoiceCommunicationDialog;
|
||||
}
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class TrainingVoiceCommunicationDialogModel;
|
||||
class TrainingVoiceCommunicationDialogFilter;
|
||||
|
||||
class TrainingVoiceCommunicationDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ModifyTvcConfigReplyHandler
|
||||
, protected Interface::Ftc::RemoveTvcConfigReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TrainingVoiceCommunicationDialog(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~TrainingVoiceCommunicationDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<Interface::Ftc> &avmFtc, ExerciseManagement::Interface::Dtc *exmDtc);
|
||||
|
||||
void onModifyTvcConfigReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onRemoveTvcConfigReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
private: // methods
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private: // attributes
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::unique_ptr<TrainingVoiceCommunicationDialogModel> m_model;
|
||||
std::unique_ptr<TrainingVoiceCommunicationDialogFilter> m_filter;
|
||||
std::unique_ptr<Ui::TrainingVoiceCommunicationDialog> m_ui;
|
||||
QString m_menuGroup;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
ExerciseManagement::Interface::Dtc *m_exmDtc{nullptr};
|
||||
LOGGER_T m_logger;
|
||||
|
||||
}; // class TrainingVoiceCommunicationDialog
|
||||
} // namespace AudioVideoManagement
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TrainingVoiceCommunicationDialog</class>
|
||||
<widget class="QWidget" name="TrainingVoiceCommunicationDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>692</width>
|
||||
<height>262</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="LtsDataView::LtsDataView" name="dataView" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The TrainingVoiceCommunicationDialogModel provices data for TrainingVoiceCommunicationDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-07-24
|
||||
*/
|
||||
|
||||
#include "avm_training_voice_communication_dialog_model.h"
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
TrainingVoiceCommunicationDialogModel::TrainingVoiceCommunicationDialogModel(QObject *parent)
|
||||
: LtsAbstractTableModel<AudioVideoManagement::TvcConfig>(
|
||||
{
|
||||
tr("Channel Number"),
|
||||
tr("Radio Circuit"),
|
||||
tr("Recording"),
|
||||
tr("Info"),
|
||||
tr("Global")
|
||||
}, parent)
|
||||
, m_exerciseId(-1)
|
||||
, m_logger(getLogger("TrainingVoiceCommunicationDialogModel"))
|
||||
{
|
||||
}
|
||||
|
||||
QVariant TrainingVoiceCommunicationDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const AudioVideoManagement::TvcConfig &config = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case CHANNEL:
|
||||
return QString::fromStdString(m_tetraChannels.value(config.tetraChannelId()).name());
|
||||
case RADIO_CIRCUIT:
|
||||
return QString::fromStdString(config.radioCircuit());
|
||||
case RECORDING:
|
||||
return config.recording() ? tr("On") : tr("Off");
|
||||
case INFO:
|
||||
return QString::fromStdString(config.info());
|
||||
case GLOBAL:
|
||||
return config.exerciseId().is_set() ? tr("No") : tr("Yes");
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool TrainingVoiceCommunicationDialogModel::init(int32_t exerciseId, const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc)
|
||||
{
|
||||
m_avmDtc = avmDtc;
|
||||
m_exerciseId = exerciseId;
|
||||
|
||||
// Sometimes, data is not there yet...
|
||||
avmDtc->waitForHistoricalDataTvcChannel(5000);
|
||||
m_tetraChannels = avmDtc->tvcChannels();
|
||||
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::tvcConfigChanged, this, &TrainingVoiceCommunicationDialogModel::onDataChanged);
|
||||
m_avmDtc->tvcConfigs([this](const TvcConfig &config) { insertRow(config); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// REGG-4433: We need to revise in which way we store the TVC configs in the library.
|
||||
// Shall we store global TVC configs? The global config would not be loadable unless
|
||||
// the previously saved config was removed before. Hmm...
|
||||
QByteArray TrainingVoiceCommunicationDialogFilter::modelToJson() const
|
||||
{
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMTrainingVoiceCommunication);
|
||||
|
||||
for (int row = 0; row < rowCount(); row++)
|
||||
{
|
||||
int sourceRow = mapToSource(index(row, 0)).row();
|
||||
|
||||
QJsonObject inner;
|
||||
const TvcConfig &config = m_sourceModel->getRowData(sourceRow);
|
||||
|
||||
inner[QLatin1String("isGlobal")] = !config.exerciseId().is_set();
|
||||
inner[QLatin1String("info")] = QString::fromStdString(config.info());
|
||||
inner[QLatin1String("radioCircuit")] = QString::fromStdString(config.radioCircuit());
|
||||
inner[QLatin1String("recording")] = config.recording();
|
||||
inner[QLatin1String("tetraChannelId")] = config.tetraChannelId();
|
||||
arr += inner;
|
||||
}
|
||||
|
||||
obj[QLatin1String("tvcConfiguration")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
QVector<ModifyTvcConfigRequest> TrainingVoiceCommunicationDialogModel::jsonToTvcConfigVector(const QByteArray &content) const
|
||||
{
|
||||
// already checked that content is not empty, is pasrseable and contains proper XmlType
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject toplevelObj(doc.object());
|
||||
const QJsonArray arr(toplevelObj.value(QLatin1String("tvcConfiguration")).toArray());
|
||||
QVector<ModifyTvcConfigRequest> result;
|
||||
result.reserve(arr.size());
|
||||
for (const auto &ele : arr)
|
||||
{
|
||||
const QJsonObject obj(ele.toObject());
|
||||
ModifyTvcConfigRequest config;
|
||||
|
||||
if (!obj.contains(QLatin1String("isGlobal")) || !obj[QLatin1String("isGlobal")].toBool())
|
||||
config.exerciseId(m_exerciseId);
|
||||
config.id(0);
|
||||
config.info(obj[QLatin1String("info")].toString().toStdString());
|
||||
config.radioCircuit(obj[QLatin1String("radioCircuit")].toString().toStdString());
|
||||
config.recording(obj[QLatin1String("recording")].toBool());
|
||||
config.tetraChannelId(obj[QLatin1String("tetraChannelId")].toInt());
|
||||
|
||||
INFO_LOG(m_logger) << "insertRow: " << config.radioCircuit()
|
||||
<< " tvcChannelId=" << config.tetraChannelId();
|
||||
result.push_back(std::move(config));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
TrainingVoiceCommunicationDialogFilter::TrainingVoiceCommunicationDialogFilter(int32_t exerciseId, TrainingVoiceCommunicationDialogModel *sourceModel)
|
||||
: m_exerciseId(exerciseId)
|
||||
, m_sourceModel(sourceModel)
|
||||
{
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool TrainingVoiceCommunicationDialogFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
TvcConfig tvcConfig = m_sourceModel->getRowData(sourceRow);
|
||||
|
||||
if (tvcConfig.exerciseId().is_set() && tvcConfig.exerciseId().get() != m_exerciseId)
|
||||
return false;
|
||||
|
||||
return LtsColumnFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
}
|
||||
|
||||
} //namespace AudioVideoManagement
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The TrainingVoiceCommunicationDialogModel provices data for TrainingVoiceCommunicationDialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2017-07-24
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class TrainingVoiceCommunicationDialogModel final
|
||||
: public LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::TvcConfig>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
CHANNEL,
|
||||
RADIO_CIRCUIT,
|
||||
RECORDING,
|
||||
INFO,
|
||||
GLOBAL
|
||||
};
|
||||
|
||||
explicit TrainingVoiceCommunicationDialogModel(QObject *parent = nullptr);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
|
||||
bool init(int32_t exerciseId, const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc);
|
||||
QVector<ModifyTvcConfigRequest> jsonToTvcConfigVector(const QByteArray &content) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
int32_t m_exerciseId;
|
||||
|
||||
QMap<int32_t, AudioVideoManagement::TvcChannel> m_tetraChannels;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
|
||||
class TrainingVoiceCommunicationDialogFilter : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
public:
|
||||
explicit TrainingVoiceCommunicationDialogFilter(int32_t exerciseId, TrainingVoiceCommunicationDialogModel *sourceModel);
|
||||
|
||||
QByteArray modelToJson() const;
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
|
||||
private:
|
||||
/** Don't call directly, use the constructor instead. */
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::setSourceModel;
|
||||
|
||||
int32_t m_exerciseId;
|
||||
TrainingVoiceCommunicationDialogModel *m_sourceModel;
|
||||
};
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::TvcConfig)
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AudioVideoManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#include "avm_training_voice_gui_plugin.h"
|
||||
#include "avm_training_voice_communication_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <Plugins/AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <Services/AudioVideoManagement/avm_operator_rights.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
}
|
||||
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session, getLogger("Plugins.Gui.Avm.CombatNetRadio"))
|
||||
{
|
||||
Q_ASSERT(session);
|
||||
Q_ASSERT(session->partitionType() == IDL::PartitionType::Exercise || session->partitionType() == IDL::PartitionType::Replay);
|
||||
}
|
||||
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getForeignDataInterface_NEW(m_avmDataIfc))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_avmDataIfc = nullptr;
|
||||
}
|
||||
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
return tr("Audio / Video");
|
||||
}
|
||||
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
if (m_session->isReplayPartition())
|
||||
return QVector<LtsWidgets::PluginData>();
|
||||
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableAudioVideoManagement = ps->value(QStringLiteral("avm"),
|
||||
QStringLiteral("enableAudioVideoManagement")).toBool();
|
||||
|
||||
// z.Zt. keine einzelnen Rechte fuer TVC verfuegbar...
|
||||
|
||||
if (enableAudioVideoManagement)
|
||||
{
|
||||
LtsWidgets::PluginData plData;
|
||||
// TVC Dialog
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Training Voice Communication");
|
||||
plData.identifier = QLatin1String("AvmAvcTvcDialog");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:voice_communication.svg"));
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::ePlanning;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return LtsWidgets::initDialog(new TrainingVoiceCommunicationDialog(menuGroup(), m_session, parent),
|
||||
m_avmDataIfc->getDtc(), m_avmDataIfc->getFtc(), m_avmDataIfc->getExmDtc());
|
||||
};
|
||||
ret.append(plData);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for AudioVideoManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, SLSE, 2016-10-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AudioVideoManagement/avm_training_voice_gui_plugin_interface.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class DataInterface;
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:avm.tvc")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QLatin1String("AudioVideoManagementTrainingVoiceGuiPlugin"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise || partition == IDL::PartitionType::Replay; }
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface, public ForeignTrainingVoiceGuiInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
~InterfaceImpl() = default;
|
||||
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QString menuGroup() const override;
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<AudioVideoManagement::DataInterface> m_avmDataIfc;
|
||||
};
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Reference in new issue
Block a user