Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+174
-195
@@ -1,71 +1,60 @@
|
||||
|
||||
|
||||
|
||||
#include "audio_settings_avail_streams_model.h"
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
#include <QFont>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
QDataStream &operator<<(QDataStream &ds, const StreamData &sd)
|
||||
QDataStream& operator<<(QDataStream& ds, const StreamData& sd)
|
||||
{
|
||||
ds << sd.topicId << sd.name << sd.bIsCnr;
|
||||
return ds;
|
||||
}
|
||||
QDataStream &operator>>(QDataStream &ds, StreamData &sd)
|
||||
{
|
||||
ds >> sd.topicId >> sd.name >> sd.bIsCnr ;
|
||||
return ds;
|
||||
ds << sd.topicId << sd.name << sd.bIsCnr;
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
AvailStreamsModel::AvailStreamsModel(Interface::Dtc *avmDtc,
|
||||
int32_t exerciseId,
|
||||
QObject *parent)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant()), {tr("Available")})
|
||||
, m_exerciseId(exerciseId)
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_cnrRoot(new NGLTreeItem(QVariant()))
|
||||
, m_tvcRoot(new NGLTreeItem(QVariant()))
|
||||
, m_changes(false)
|
||||
QDataStream& operator>>(QDataStream& ds, StreamData& sd)
|
||||
{
|
||||
Q_ASSERT(avmDtc);
|
||||
|
||||
qRegisterMetaTypeStreamOperators<StreamData>();
|
||||
|
||||
setMimeType(StreamData::mimeType());
|
||||
|
||||
StreamData data;
|
||||
data.name = tr("CNR");
|
||||
data.bIsCnr = true;
|
||||
m_cnrRoot->setData(QVariant::fromValue(data));
|
||||
m_rootItem->appendChild(m_cnrRoot);
|
||||
|
||||
data.name = tr("TVC");
|
||||
data.bIsCnr = false;
|
||||
m_tvcRoot->setData(QVariant::fromValue(data));
|
||||
m_rootItem->appendChild(m_tvcRoot);
|
||||
ds >> sd.topicId >> sd.name >> sd.bIsCnr;
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void AvailStreamsModel::setStreamChanged(const QVector<StreamData> &streams)
|
||||
AvailStreamsModel::AvailStreamsModel(Interface::Dtc* avmDtc, int32_t exerciseId, QObject* parent)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant()), {tr("Available")}), m_exerciseId(exerciseId), m_avmDtc(avmDtc),
|
||||
m_cnrRoot(new NGLTreeItem(QVariant())), m_tvcRoot(new NGLTreeItem(QVariant())), m_changes(false)
|
||||
{
|
||||
for (const StreamData &d : streams)
|
||||
if (!m_changedStreams.contains(QPair<bool,int>(d.bIsCnr, d.topicId)))
|
||||
m_changedStreams += QPair<bool,int>(d.bIsCnr, d.topicId);
|
||||
emit modelDataChanged();
|
||||
Q_ASSERT(avmDtc);
|
||||
|
||||
qRegisterMetaTypeStreamOperators<StreamData>();
|
||||
|
||||
setMimeType(StreamData::mimeType());
|
||||
|
||||
StreamData data;
|
||||
data.name = tr("CNR");
|
||||
data.bIsCnr = true;
|
||||
m_cnrRoot->setData(QVariant::fromValue(data));
|
||||
m_rootItem->appendChild(m_cnrRoot);
|
||||
|
||||
data.name = tr("TVC");
|
||||
data.bIsCnr = false;
|
||||
m_tvcRoot->setData(QVariant::fromValue(data));
|
||||
m_rootItem->appendChild(m_tvcRoot);
|
||||
}
|
||||
|
||||
void AvailStreamsModel::setStreamChanged(const QVector<StreamData>& streams)
|
||||
{
|
||||
for (const StreamData& d : streams)
|
||||
if (!m_changedStreams.contains(QPair<bool, int>(d.bIsCnr, d.topicId)))
|
||||
m_changedStreams += QPair<bool, int>(d.bIsCnr, d.topicId);
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
bool AvailStreamsModel::initModel()
|
||||
{
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::cnrConfigChanged,
|
||||
this, &AvailStreamsModel::onCnrConfigChanged, Qt::UniqueConnection);
|
||||
m_avmDtc->cnrConfigs([this](const AudioVideoManagement::CnrConfig & ch) { onCnrConfigChanged(ch, DataModification::eAdded); });
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::cnrConfigChanged, this,
|
||||
&AvailStreamsModel::onCnrConfigChanged, Qt::UniqueConnection);
|
||||
m_avmDtc->cnrConfigs(
|
||||
[this](const AudioVideoManagement::CnrConfig& ch) { onCnrConfigChanged(ch, DataModification::eAdded); });
|
||||
|
||||
#if 0
|
||||
AudioVideoManagement::CnrConfig data;
|
||||
@@ -85,200 +74,190 @@ bool AvailStreamsModel::initModel()
|
||||
onTvcConfigChanged(data2, DataModification::eAdded);
|
||||
#endif
|
||||
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::tvcConfigChanged,
|
||||
this, &AvailStreamsModel::onTvcConfigChanged, Qt::UniqueConnection);
|
||||
m_avmDtc->tvcConfigs([this](const AudioVideoManagement::TvcConfig & ch) { onTvcConfigChanged(ch, DataModification::eAdded); });
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::tvcConfigChanged, this,
|
||||
&AvailStreamsModel::onTvcConfigChanged, Qt::UniqueConnection);
|
||||
m_avmDtc->tvcConfigs(
|
||||
[this](const AudioVideoManagement::TvcConfig& ch) { onTvcConfigChanged(ch, DataModification::eAdded); });
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
Qt::ItemFlags AvailStreamsModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags AvailStreamsModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
Qt::ItemFlags f = NGLTreeModel::flags(index) | Qt::ItemIsDropEnabled;
|
||||
if (!index.parent().isValid())
|
||||
f &= ~Qt::ItemIsDragEnabled;
|
||||
Qt::ItemFlags f = NGLTreeModel::flags(index) | Qt::ItemIsDropEnabled;
|
||||
if (!index.parent().isValid())
|
||||
f &= ~Qt::ItemIsDragEnabled;
|
||||
|
||||
return f;
|
||||
return f;
|
||||
}
|
||||
|
||||
QVariant AvailStreamsModel::data(const QModelIndex &index, int role) const
|
||||
QVariant AvailStreamsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
switch (role)
|
||||
{
|
||||
NGLTreeItem *item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
DEBUG_LOG(m_logger) << data.name;
|
||||
return data.name;
|
||||
case Qt::DisplayRole: {
|
||||
NGLTreeItem* item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
DEBUG_LOG(m_logger) << data.name;
|
||||
return data.name;
|
||||
}
|
||||
|
||||
case Qt::FontRole: {
|
||||
NGLTreeItem* item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
if (!m_changedStreams.contains(QPair<bool, int>(data.bIsCnr, data.topicId)))
|
||||
return {};
|
||||
QFont f;
|
||||
f.setBold(true);
|
||||
return f;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case Qt::FontRole:
|
||||
{
|
||||
NGLTreeItem *item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
if (!m_changedStreams.contains(QPair<bool,int>(data.bIsCnr, data.topicId)))
|
||||
return {};
|
||||
QFont f;
|
||||
f.setBold(true);
|
||||
return f;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NGLTreeModel::data(index, role);
|
||||
return NGLTreeModel::data(index, role);
|
||||
}
|
||||
|
||||
bool AvailStreamsModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||
bool AvailStreamsModel::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
if (action != supportedDropActions())
|
||||
return false;
|
||||
return true;
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
if (action != supportedDropActions())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AvailStreamsModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent)
|
||||
bool AvailStreamsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent)
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
Q_UNUSED(action);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
|
||||
const QVector<NGLTreeItem *> droppedItems = getMimeDataItems(data, m_mimeType);
|
||||
QVector<StreamData> streams;
|
||||
streams.reserve(droppedItems.size());
|
||||
for (const NGLTreeItem *item : droppedItems)
|
||||
streams += item->data().value<StreamData>();
|
||||
qDeleteAll(droppedItems);
|
||||
emit droppedStreamNames(streams);
|
||||
m_changes = true;
|
||||
return true;
|
||||
const QVector<NGLTreeItem*> droppedItems = getMimeDataItems(data, m_mimeType);
|
||||
QVector<StreamData> streams;
|
||||
streams.reserve(droppedItems.size());
|
||||
for (const NGLTreeItem* item : droppedItems)
|
||||
streams += item->data().value<StreamData>();
|
||||
qDeleteAll(droppedItems);
|
||||
emit droppedStreamNames(streams);
|
||||
m_changes = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void AvailStreamsModel::onCnrConfigChanged(const AudioVideoManagement::CnrConfig &data, DataModification modType)
|
||||
void AvailStreamsModel::onCnrConfigChanged(const AudioVideoManagement::CnrConfig& data, DataModification modType)
|
||||
{
|
||||
insertUpdateData(data, modType, m_cnrRoot);
|
||||
insertUpdateData(data, modType, m_cnrRoot);
|
||||
}
|
||||
|
||||
void AvailStreamsModel::onTvcConfigChanged(const AudioVideoManagement::TvcConfig &data, DataModification modType)
|
||||
void AvailStreamsModel::onTvcConfigChanged(const AudioVideoManagement::TvcConfig& data, DataModification modType)
|
||||
{
|
||||
insertUpdateData(data, modType, m_tvcRoot);
|
||||
insertUpdateData(data, modType, m_tvcRoot);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void AvailStreamsModel::insertUpdateData(const T &config, DataModification modType, NGLTreeItem *parent)
|
||||
void AvailStreamsModel::insertUpdateData(const T& config, DataModification modType, NGLTreeItem* parent)
|
||||
{
|
||||
DataModification action = modType;
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
|
||||
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() != m_exerciseId)
|
||||
action = DataModification::eRemoved;
|
||||
}
|
||||
|
||||
StreamData newData(config);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() != m_exerciseId)
|
||||
break;
|
||||
Q_FALLTHROUGH();
|
||||
case DataModification::eModified:
|
||||
{
|
||||
bool bFound = false;
|
||||
for (int i = 0; i < parent->childCount(); ++i)
|
||||
DataModification action = modType;
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
NGLTreeItem *child = parent->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == newData)
|
||||
{
|
||||
bFound = true;
|
||||
setItemData(indexFromItem(child), QVariant::fromValue(newData), child->icon());
|
||||
emit updateEntry(newData);
|
||||
break;
|
||||
}
|
||||
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() != m_exerciseId)
|
||||
action = DataModification::eRemoved;
|
||||
}
|
||||
if (!bFound)
|
||||
|
||||
StreamData newData(config);
|
||||
|
||||
switch (action)
|
||||
{
|
||||
NGLTreeItem *child = new NGLTreeItem(QVariant::fromValue(newData));
|
||||
insertRow(parent->childCount(), indexFromItem(parent), child);
|
||||
case DataModification::eAdded:
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() != m_exerciseId)
|
||||
break;
|
||||
Q_FALLTHROUGH();
|
||||
case DataModification::eModified: {
|
||||
bool bFound = false;
|
||||
for (int i = 0; i < parent->childCount(); ++i)
|
||||
{
|
||||
NGLTreeItem* child = parent->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == newData)
|
||||
{
|
||||
bFound = true;
|
||||
setItemData(indexFromItem(child), QVariant::fromValue(newData), child->icon());
|
||||
emit updateEntry(newData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bFound)
|
||||
{
|
||||
NGLTreeItem* child = new NGLTreeItem(QVariant::fromValue(newData));
|
||||
insertRow(parent->childCount(), indexFromItem(parent), child);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved: {
|
||||
for (int i = 0; i < parent->childCount(); ++i)
|
||||
{
|
||||
NGLTreeItem* child = parent->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == newData)
|
||||
{
|
||||
removeRows(i, 1, indexFromItem(parent));
|
||||
emit removeEntry(newData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
for (int i = 0; i < parent->childCount(); ++i)
|
||||
{
|
||||
NGLTreeItem *child = parent->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == newData)
|
||||
{
|
||||
removeRows(i, 1, indexFromItem(parent));
|
||||
emit removeEntry(newData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AvailStreamsFilter::AvailStreamsFilter(AvailStreamsModel *sourceModel, QObject *parent)
|
||||
: QSortFilterProxyModel(parent)
|
||||
, m_sourceModel(sourceModel)
|
||||
AvailStreamsFilter::AvailStreamsFilter(AvailStreamsModel* sourceModel, QObject* parent)
|
||||
: QSortFilterProxyModel(parent), m_sourceModel(sourceModel)
|
||||
{
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(m_sourceModel);
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(m_sourceModel);
|
||||
}
|
||||
|
||||
void AvailStreamsFilter::addAllocatedStreams(const QVector<StreamData> &streams)
|
||||
void AvailStreamsFilter::addAllocatedStreams(const QVector<StreamData>& streams)
|
||||
{
|
||||
m_allocatedStreams.insert(streams.begin(), streams.end());
|
||||
invalidateFilter();
|
||||
m_allocatedStreams.insert(streams.begin(), streams.end());
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void AvailStreamsFilter::setAllocatedStreams(const QVector<StreamData> &streams)
|
||||
void AvailStreamsFilter::setAllocatedStreams(const QVector<StreamData>& streams)
|
||||
{
|
||||
m_allocatedStreams.clear();
|
||||
m_allocatedStreams.insert(streams.begin(), streams.end());
|
||||
invalidateFilter();
|
||||
m_allocatedStreams.clear();
|
||||
m_allocatedStreams.insert(streams.begin(), streams.end());
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void AvailStreamsFilter::removeAllocatedStreams(const QVector<StreamData> &streams)
|
||||
void AvailStreamsFilter::removeAllocatedStreams(const QVector<StreamData>& streams)
|
||||
{
|
||||
for (const StreamData &stream : streams)
|
||||
m_allocatedStreams.erase(stream);
|
||||
invalidateFilter();
|
||||
for (const StreamData& stream : streams)
|
||||
m_allocatedStreams.erase(stream);
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
bool AvailStreamsFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
|
||||
bool AvailStreamsFilter::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||
{
|
||||
if (!m_sourceModel || !source_parent.isValid())
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
if (!m_sourceModel || !source_parent.isValid())
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
NGLTreeItem *parent = m_sourceModel->privateData(source_parent);
|
||||
if (!parent)
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
NGLTreeItem *child = parent->child(source_row);
|
||||
if (!child)
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
NGLTreeItem* parent = m_sourceModel->privateData(source_parent);
|
||||
if (!parent)
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
NGLTreeItem* child = parent->child(source_row);
|
||||
if (!child)
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
return m_allocatedStreams.count(data) == 0;
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
return m_allocatedStreams.count(data) == 0;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+66
-50
@@ -1,13 +1,13 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
#include "audio_stream_type.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QVector>
|
||||
#include "audio_stream_type.h"
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
||||
@@ -15,68 +15,84 @@ namespace AudioVideoManagement
|
||||
{
|
||||
class AvailStreamsModel final : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AvailStreamsModel(AudioVideoManagement::Interface::Dtc *avmDtc, int32_t exerciseId,
|
||||
QObject *parent = nullptr);
|
||||
~AvailStreamsModel() = default;
|
||||
bool getChangeState() {bool result = m_changes; m_changes = false; return result;}
|
||||
void resetChangeState() {m_changes = false;m_changedStreams.clear();}
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AvailStreamsModel(AudioVideoManagement::Interface::Dtc* avmDtc, int32_t exerciseId,
|
||||
QObject* parent = nullptr);
|
||||
~AvailStreamsModel() = default;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
bool getChangeState()
|
||||
{
|
||||
bool result = m_changes;
|
||||
m_changes = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Qt::DropActions supportedDropActions() const override { return Qt::MoveAction; }
|
||||
Qt::DropActions supportedDragActions() const override { return Qt::CopyAction; }
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction, int, int, const QModelIndex &) override;
|
||||
void setStreamChanged(const QVector<StreamData> &streams);
|
||||
void resetChangeState()
|
||||
{
|
||||
m_changes = false;
|
||||
m_changedStreams.clear();
|
||||
}
|
||||
|
||||
bool initModel();
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
|
||||
signals:
|
||||
void droppedStreamNames(const QVector<AudioVideoManagement::StreamData> &streamNamesDropped);
|
||||
void updateEntry(const AudioVideoManagement::StreamData &stream);
|
||||
void removeEntry(const AudioVideoManagement::StreamData &stream);
|
||||
Qt::DropActions supportedDropActions() const override
|
||||
{
|
||||
return Qt::MoveAction;
|
||||
}
|
||||
|
||||
private slots:
|
||||
void onCnrConfigChanged(const AudioVideoManagement::CnrConfig &data, DataModification modType);
|
||||
void onTvcConfigChanged(const AudioVideoManagement::TvcConfig &data, DataModification modType);
|
||||
Qt::DropActions supportedDragActions() const override
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
|
||||
private:
|
||||
bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction, int, int, const QModelIndex&) override;
|
||||
void setStreamChanged(const QVector<StreamData>& streams);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
template <typename T>
|
||||
void insertUpdateData(const T &data, DataModification modType, NGLTreeItem *parent);
|
||||
bool initModel();
|
||||
|
||||
int32_t m_exerciseId;
|
||||
AudioVideoManagement::Interface::Dtc *m_avmDtc;
|
||||
NGLTreeItem *m_cnrRoot;
|
||||
NGLTreeItem *m_tvcRoot;
|
||||
bool m_changes;
|
||||
QVector<QPair<bool , int> > m_changedStreams;
|
||||
signals:
|
||||
void droppedStreamNames(const QVector<AudioVideoManagement::StreamData>& streamNamesDropped);
|
||||
void updateEntry(const AudioVideoManagement::StreamData& stream);
|
||||
void removeEntry(const AudioVideoManagement::StreamData& stream);
|
||||
|
||||
private slots:
|
||||
void onCnrConfigChanged(const AudioVideoManagement::CnrConfig& data, DataModification modType);
|
||||
void onTvcConfigChanged(const AudioVideoManagement::TvcConfig& data, DataModification modType);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
template <typename T> void insertUpdateData(const T& data, DataModification modType, NGLTreeItem* parent);
|
||||
|
||||
int32_t m_exerciseId;
|
||||
AudioVideoManagement::Interface::Dtc* m_avmDtc;
|
||||
NGLTreeItem* m_cnrRoot;
|
||||
NGLTreeItem* m_tvcRoot;
|
||||
bool m_changes;
|
||||
QVector<QPair<bool, int>> m_changedStreams;
|
||||
};
|
||||
|
||||
class AvailStreamsFilter final : public QSortFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AvailStreamsFilter(AvailStreamsModel *sourceModel, QObject *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AvailStreamsFilter(AvailStreamsModel* sourceModel, QObject* parent);
|
||||
|
||||
void addAllocatedStreams(const QVector<StreamData> &streams);
|
||||
void setAllocatedStreams(const QVector<StreamData> &streams);
|
||||
void removeAllocatedStreams(const QVector<StreamData> &streams);
|
||||
void addAllocatedStreams(const QVector<StreamData>& streams);
|
||||
void setAllocatedStreams(const QVector<StreamData>& streams);
|
||||
void removeAllocatedStreams(const QVector<StreamData>& streams);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override;
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override;
|
||||
|
||||
private:
|
||||
|
||||
using QSortFilterProxyModel::setSourceModel;
|
||||
private:
|
||||
using QSortFilterProxyModel::setSourceModel;
|
||||
|
||||
AvailStreamsModel *m_sourceModel;
|
||||
std::set<StreamData> m_allocatedStreams;
|
||||
AvailStreamsModel* m_sourceModel;
|
||||
std::set<StreamData> m_allocatedStreams;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+292
-322
@@ -1,434 +1,404 @@
|
||||
|
||||
|
||||
|
||||
#include "audio_settings_dialog.h"
|
||||
#include <utility>
|
||||
#include "ui_audio_settings_dialog.h"
|
||||
|
||||
#include "audio_settings_avail_streams_model.h"
|
||||
#include "audio_settings_used_streams_model.h"
|
||||
#include "audio_stream_type.h"
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include "ui_audio_settings_dialog.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_ftc_types.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <utility>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
AudioSettingsDialog::AudioSettingsDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::AudioSettingsDialog)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
AudioSettingsDialog::AudioSettingsDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ui(new Ui::AudioSettingsDialog),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
m_ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Voice_Communication_Access"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Voice_Communication_Access"));
|
||||
}
|
||||
|
||||
AudioSettingsDialog::~AudioSettingsDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool AudioSettingsDialog::init(OperatorManagement::Interface::Dtc *opmDtc,
|
||||
Interface::Dtc *avmDtc,
|
||||
Interface::Ftc *avmFtc,
|
||||
LtsSession::LtsSessionDataDds *session)
|
||||
bool AudioSettingsDialog::init(OperatorManagement::Interface::Dtc* opmDtc, Interface::Dtc* avmDtc,
|
||||
Interface::Ftc* avmFtc, LtsSession::LtsSessionDataDds* session)
|
||||
{
|
||||
Q_ASSERT(opmDtc);
|
||||
Q_ASSERT(avmDtc);
|
||||
Q_ASSERT(avmFtc);
|
||||
Q_ASSERT(session);
|
||||
Q_ASSERT(opmDtc);
|
||||
Q_ASSERT(avmDtc);
|
||||
Q_ASSERT(avmFtc);
|
||||
Q_ASSERT(session);
|
||||
|
||||
setUnchangeable(true);
|
||||
setUnchangeable(true);
|
||||
|
||||
m_session = session;
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
|
||||
|
||||
m_session = session;
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
|
||||
m_modelAvailable = new AvailStreamsModel(avmDtc, m_session->exerciseId(), this);
|
||||
if (!m_modelAvailable->initModel())
|
||||
return false;
|
||||
m_modelAvailable = new AvailStreamsModel(avmDtc, m_session->exerciseId(), this);
|
||||
if (!m_modelAvailable->initModel())
|
||||
return false;
|
||||
|
||||
m_filterAvailable = new AvailStreamsFilter(m_modelAvailable, this);
|
||||
m_modelAllocated = new AllocatedStreamsModel(this);
|
||||
m_filterAvailable = new AvailStreamsFilter(m_modelAvailable, this);
|
||||
m_modelAllocated = new AllocatedStreamsModel(this);
|
||||
|
||||
connect(m_modelAvailable, &AvailStreamsModel::droppedStreamNames, this, &AudioSettingsDialog::onDroppedInAvailable);
|
||||
connect(m_modelAllocated, &AllocatedStreamsModel::droppedStreamNames, this, &AudioSettingsDialog::onDroppedInAllocated);
|
||||
connect(m_modelAvailable, &AvailStreamsModel::droppedStreamNames, this, &AudioSettingsDialog::onDroppedInAvailable);
|
||||
connect(m_modelAllocated, &AllocatedStreamsModel::droppedStreamNames, this,
|
||||
&AudioSettingsDialog::onDroppedInAllocated);
|
||||
|
||||
connect(m_modelAvailable, &AvailStreamsModel::updateEntry, m_modelAllocated, &AllocatedStreamsModel::updateEntry);
|
||||
connect(m_modelAvailable, &AvailStreamsModel::removeEntry, this, &AudioSettingsDialog::onEntryRemoved);
|
||||
connect(m_modelAvailable, &AvailStreamsModel::updateEntry, m_modelAllocated, &AllocatedStreamsModel::updateEntry);
|
||||
connect(m_modelAvailable, &AvailStreamsModel::removeEntry, this, &AudioSettingsDialog::onEntryRemoved);
|
||||
|
||||
|
||||
m_ui->treeViewAvailable->setModel(m_filterAvailable);
|
||||
m_ui->treeViewAvailable->expandAll();
|
||||
m_ui->treeViewAllocated->setModel(m_modelAllocated);
|
||||
m_ui->treeViewAvailable->setModel(m_filterAvailable);
|
||||
m_ui->treeViewAvailable->expandAll();
|
||||
m_ui->treeViewAllocated->setModel(m_modelAllocated);
|
||||
|
||||
|
||||
connect(opmDtc, &OperatorManagement::Interface::Dtc::userChanged,
|
||||
this, &AudioSettingsDialog::onOperatorChanged);
|
||||
auto cbOperator = [this](const OperatorManagement::User & u)
|
||||
{
|
||||
onOperatorChanged(u, DataModification::eAdded);
|
||||
};
|
||||
opmDtc->users(cbOperator);
|
||||
connect(opmDtc, &OperatorManagement::Interface::Dtc::userChanged, this, &AudioSettingsDialog::onOperatorChanged);
|
||||
auto cbOperator = [this](const OperatorManagement::User& u) { onOperatorChanged(u, DataModification::eAdded); };
|
||||
opmDtc->users(cbOperator);
|
||||
|
||||
fillOperatorBox();
|
||||
fillOperatorBox();
|
||||
|
||||
connect(m_avmDtc, &Interface::Dtc::cnrTvcProfileChanged,
|
||||
this, &AudioSettingsDialog::onCnrTvcProfileChanged);
|
||||
auto cbRadioCircuits = [this](const CnrTvcProfile & rc)
|
||||
{
|
||||
onCnrTvcProfileChanged(rc, DataModification::eAdded);
|
||||
};
|
||||
m_avmDtc->cnrTvcProfiles(cbRadioCircuits);
|
||||
connect(m_avmDtc, &Interface::Dtc::cnrTvcProfileChanged, this, &AudioSettingsDialog::onCnrTvcProfileChanged);
|
||||
auto cbRadioCircuits = [this](const CnrTvcProfile& rc) { onCnrTvcProfileChanged(rc, DataModification::eAdded); };
|
||||
m_avmDtc->cnrTvcProfiles(cbRadioCircuits);
|
||||
|
||||
connect(m_ui->pushButtonUp, &QPushButton::clicked, this, &AudioSettingsDialog::onUpButtonClicked);
|
||||
connect(m_ui->pushButtonDown, &QPushButton::clicked, this, &AudioSettingsDialog::onDownButtonClicked);
|
||||
connect(m_ui->operatorComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &AudioSettingsDialog::onSelectionOperatorChanged);
|
||||
connect(m_ui->treeViewAllocated->selectionModel(), &QItemSelectionModel::selectionChanged, this, &AudioSettingsDialog::onSelectionChangedAllocation);
|
||||
|
||||
connect(m_ui->pushButtonUp, &QPushButton::clicked, this, &AudioSettingsDialog::onUpButtonClicked);
|
||||
connect(m_ui->pushButtonDown, &QPushButton::clicked, this, &AudioSettingsDialog::onDownButtonClicked);
|
||||
connect(m_ui->operatorComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
&AudioSettingsDialog::onSelectionOperatorChanged);
|
||||
connect(m_ui->treeViewAllocated->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
&AudioSettingsDialog::onSelectionChangedAllocation);
|
||||
|
||||
m_ui->treeViewAllocated->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
m_ui->treeViewAvailable->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
m_ui->treeViewAllocated->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
m_ui->treeViewAvailable->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||
|
||||
m_ui->treeViewAllocated->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_ui->treeViewAvailable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_ui->treeViewAllocated->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_ui->treeViewAvailable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
|
||||
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
m_avmFtc->enableAll();
|
||||
|
||||
m_avmFtc->enableAll();
|
||||
|
||||
int opId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
if (m_ui->operatorComboBox->currentIndex() != m_ui->operatorComboBox->findData(opId))
|
||||
m_ui->operatorComboBox->setCurrentIndex(m_ui->operatorComboBox->findData(opId));
|
||||
else
|
||||
onSelectionOperatorChanged(0);
|
||||
setUnchangeable(false);
|
||||
return true;
|
||||
}
|
||||
int opId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
if (m_ui->operatorComboBox->currentIndex() != m_ui->operatorComboBox->findData(opId))
|
||||
m_ui->operatorComboBox->setCurrentIndex(m_ui->operatorComboBox->findData(opId));
|
||||
else
|
||||
onSelectionOperatorChanged(0);
|
||||
setUnchangeable(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Voice Communication Access"));
|
||||
}
|
||||
translate(m_ui, tr("Voice Communication Access"));
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onOperatorChanged(const OperatorManagement::User &data, DataModification modType)
|
||||
void AudioSettingsDialog::onOperatorChanged(const OperatorManagement::User& data, DataModification modType)
|
||||
{
|
||||
|
||||
DEBUG_LOG(m_logger) << "************** onOperatorChanged ";
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eRemoved:
|
||||
|
||||
DEBUG_LOG(m_logger) << "************** onOperatorChanged ";
|
||||
switch (modType)
|
||||
{
|
||||
Q_ASSERT(m_operatorMap.contains(data.id()));
|
||||
case DataModification::eRemoved: {
|
||||
Q_ASSERT(m_operatorMap.contains(data.id()));
|
||||
|
||||
|
||||
if (m_ui->operatorComboBox->currentData().toInt() == data.id())
|
||||
{
|
||||
__unchange__();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
}
|
||||
if (m_ui->operatorComboBox->currentData().toInt() == data.id())
|
||||
{
|
||||
__unchange__();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
}
|
||||
|
||||
m_operatorMap.remove(data.id());
|
||||
m_ui->operatorComboBox->removeItem(m_ui->operatorComboBox->findData(data.id()));
|
||||
break;
|
||||
m_operatorMap.remove(data.id());
|
||||
m_ui->operatorComboBox->removeItem(m_ui->operatorComboBox->findData(data.id()));
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eAdded: {
|
||||
Q_ASSERT(!m_operatorMap.contains(data.id()));
|
||||
const QString operatorName = QString::fromStdString(data.name());
|
||||
m_operatorMap.insert(data.id(), operatorName);
|
||||
m_ui->operatorComboBox->addItem(operatorName, data.id());
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eModified: {
|
||||
Q_ASSERT(m_operatorMap.contains(data.id()));
|
||||
const QString operatorName = QString::fromStdString(data.name());
|
||||
m_operatorMap.insert(data.id(), operatorName);
|
||||
int i = m_ui->operatorComboBox->findData(data.id());
|
||||
Q_ASSERT(i != -1);
|
||||
m_ui->operatorComboBox->setItemText(i, operatorName);
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case DataModification::eAdded:
|
||||
{
|
||||
Q_ASSERT(!m_operatorMap.contains(data.id()));
|
||||
const QString operatorName = QString::fromStdString(data.name());
|
||||
m_operatorMap.insert(data.id(), operatorName);
|
||||
m_ui->operatorComboBox->addItem(operatorName, data.id());
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eModified:
|
||||
{
|
||||
Q_ASSERT(m_operatorMap.contains(data.id()));
|
||||
const QString operatorName = QString::fromStdString(data.name());
|
||||
m_operatorMap.insert(data.id(), operatorName);
|
||||
int i = m_ui->operatorComboBox->findData(data.id());
|
||||
Q_ASSERT(i != -1);
|
||||
m_ui->operatorComboBox->setItemText(i, operatorName);
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onCnrTvcProfileChanged(const CnrTvcProfile &data, DataModification modType)
|
||||
void AudioSettingsDialog::onCnrTvcProfileChanged(const CnrTvcProfile& data, DataModification modType)
|
||||
{
|
||||
if (m_session->exerciseId() == data.exerciseId())
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
if (m_session->exerciseId() == data.exerciseId())
|
||||
{
|
||||
m_cnrTvcProfileMap.remove(data.id());
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
m_cnrTvcProfileMap.remove(data.id());
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cnrTvcProfileMap.insert(data.id(), data);
|
||||
fillOperatorList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cnrTvcProfileMap.insert(data.id(), data);
|
||||
fillOperatorList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::fillOperatorList()
|
||||
{
|
||||
QVector<StreamData> newStreamData;
|
||||
QVector<StreamData> newStreamData;
|
||||
|
||||
for (const auto &rc : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if ((rc.exerciseId() != m_session->exerciseId())
|
||||
|| (rc.operatorId() != m_ui->operatorComboBox->currentData().toInt()))
|
||||
continue;
|
||||
for (const auto& rc : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if ((rc.exerciseId() != m_session->exerciseId()) ||
|
||||
(rc.operatorId() != m_ui->operatorComboBox->currentData().toInt()))
|
||||
continue;
|
||||
|
||||
|
||||
newStreamData.reserve(rc.data().size());
|
||||
for (const CnrTvcProfileData &profileEntry : rc.data())
|
||||
newStreamData += toStreamData(profileEntry);
|
||||
newStreamData.reserve(rc.data().size());
|
||||
for (const CnrTvcProfileData& profileEntry : rc.data())
|
||||
newStreamData += toStreamData(profileEntry);
|
||||
|
||||
break;
|
||||
}
|
||||
m_modelAllocated->setNewStreamData(newStreamData);
|
||||
m_filterAvailable->setAllocatedStreams(newStreamData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
m_modelAllocated->setNewStreamData(newStreamData);
|
||||
m_filterAvailable->setAllocatedStreams(newStreamData);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::fillOperatorBox()
|
||||
{
|
||||
m_ui->operatorComboBox->clear();
|
||||
QMap<int, QString>::iterator i = m_operatorMap.begin();
|
||||
while (i != m_operatorMap.end())
|
||||
{
|
||||
m_ui->operatorComboBox->addItem(i.value(), i.key());
|
||||
++i;
|
||||
}
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
m_ui->operatorComboBox->clear();
|
||||
QMap<int, QString>::iterator i = m_operatorMap.begin();
|
||||
while (i != m_operatorMap.end())
|
||||
{
|
||||
m_ui->operatorComboBox->addItem(i.value(), i.key());
|
||||
++i;
|
||||
}
|
||||
m_ui->operatorComboBox->model()->sort(0);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onUpButtonClicked()
|
||||
{
|
||||
const QModelIndexList mil = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
if (mil.isEmpty())
|
||||
return;
|
||||
m_modelAllocated->changeOrder(mil.first(), true);
|
||||
const QModelIndexList mil = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
if (mil.isEmpty())
|
||||
return;
|
||||
m_modelAllocated->changeOrder(mil.first(), true);
|
||||
|
||||
if (mil.first().row() > 0)
|
||||
{
|
||||
const QModelIndex newRow = m_modelAllocated->index(mil.first().row() - 1, 0);
|
||||
m_ui->treeViewAllocated->setCurrentIndex(newRow);
|
||||
}
|
||||
if (mil.first().row() > 0)
|
||||
{
|
||||
const QModelIndex newRow = m_modelAllocated->index(mil.first().row() - 1, 0);
|
||||
m_ui->treeViewAllocated->setCurrentIndex(newRow);
|
||||
}
|
||||
|
||||
slotChangesMade();
|
||||
}
|
||||
slotChangesMade();
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onDownButtonClicked()
|
||||
{
|
||||
const QModelIndexList mil = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
if (mil.isEmpty())
|
||||
return;
|
||||
m_modelAllocated->changeOrder(mil.first(), false);
|
||||
const QModelIndex newRow = m_modelAllocated->index(mil.first().row() + 1, 0);
|
||||
m_ui->treeViewAllocated->setCurrentIndex(newRow);
|
||||
slotChangesMade();
|
||||
}
|
||||
const QModelIndexList mil = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
if (mil.isEmpty())
|
||||
return;
|
||||
m_modelAllocated->changeOrder(mil.first(), false);
|
||||
const QModelIndex newRow = m_modelAllocated->index(mil.first().row() + 1, 0);
|
||||
m_ui->treeViewAllocated->setCurrentIndex(newRow);
|
||||
slotChangesMade();
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onSelectionChangedAllocation(const QItemSelection &selected, const QItemSelection &deselected)
|
||||
void AudioSettingsDialog::onSelectionChangedAllocation(const QItemSelection& selected, const QItemSelection& deselected)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onSelectionChangedAllocation selected.isEmpty()=" << selected.isEmpty();
|
||||
Q_UNUSED(deselected);
|
||||
QModelIndex first = m_ui->treeViewAllocated->model()->index(0, 0);
|
||||
int rowCnt = m_ui->treeViewAllocated->model()->rowCount();
|
||||
QModelIndex last = m_ui->treeViewAllocated->model()->index(rowCnt - 1, 0);
|
||||
QModelIndexList selectedRows = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
if (cntSelectedRows > 1)
|
||||
{
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (selected.size() > 0)
|
||||
{
|
||||
m_ui->pushButtonUp->setEnabled(selected.first().indexes().first() != first);
|
||||
m_ui->pushButtonDown->setEnabled(selected.first().indexes().first() != last);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "onSelectionChangedAllocation selected.isEmpty()=" << selected.isEmpty();
|
||||
Q_UNUSED(deselected);
|
||||
QModelIndex first = m_ui->treeViewAllocated->model()->index(0, 0);
|
||||
int rowCnt = m_ui->treeViewAllocated->model()->rowCount();
|
||||
QModelIndex last = m_ui->treeViewAllocated->model()->index(rowCnt - 1, 0);
|
||||
QModelIndexList selectedRows = m_ui->treeViewAllocated->selectionModel()->selectedIndexes();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
if (cntSelectedRows > 1)
|
||||
{
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
if (selected.size() > 0)
|
||||
{
|
||||
m_ui->pushButtonUp->setEnabled(selected.first().indexes().first() != first);
|
||||
m_ui->pushButtonDown->setEnabled(selected.first().indexes().first() != last);
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioSettingsDialog::apply()
|
||||
{
|
||||
if (m_modelAllocated->getStreamDataVector().isEmpty())
|
||||
applyRemove();
|
||||
else
|
||||
applyModify();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
return true;
|
||||
if (m_modelAllocated->getStreamDataVector().isEmpty())
|
||||
applyRemove();
|
||||
else
|
||||
applyModify();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AudioSettingsDialog::applyRemove()
|
||||
{
|
||||
RemoveCnrTvcProfileRequest removeRequest;
|
||||
DEBUG_LOG(m_logger) << "AudioSettingsDialog::applyRemove";
|
||||
RemoveCnrTvcProfileRequest removeRequest;
|
||||
DEBUG_LOG(m_logger) << "AudioSettingsDialog::applyRemove";
|
||||
|
||||
for (const auto& profile : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if (profile.operatorId() != m_operatorId)
|
||||
continue;
|
||||
removeRequest.id(profile.id());
|
||||
break;
|
||||
}
|
||||
if (removeRequest.id() <= 0)
|
||||
return true;
|
||||
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, removeRequest]() { return m_avmFtc->removeCnrTvcProfileRequest(removeRequest, this); });
|
||||
|
||||
for (const auto &profile : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if (profile.operatorId() != m_operatorId)
|
||||
continue;
|
||||
removeRequest.id(profile.id());
|
||||
break;
|
||||
}
|
||||
if (removeRequest.id() <= 0)
|
||||
return true;
|
||||
|
||||
m_requestHelper->startSingleRequest([this, removeRequest]()
|
||||
{
|
||||
return m_avmFtc->removeCnrTvcProfileRequest(removeRequest, this);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioSettingsDialog::applyModify()
|
||||
{
|
||||
ModifyCnrTvcProfileRequest modifyRequest;
|
||||
DEBUG_LOG(m_logger) << "AudioSettingsDialog::applyModify";
|
||||
ModifyCnrTvcProfileRequest modifyRequest;
|
||||
DEBUG_LOG(m_logger) << "AudioSettingsDialog::applyModify";
|
||||
|
||||
for (const auto &profile : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if (profile.operatorId() != m_operatorId)
|
||||
continue;
|
||||
modifyRequest.id(profile.id());
|
||||
break;
|
||||
}
|
||||
for (const auto& profile : std::as_const(m_cnrTvcProfileMap))
|
||||
{
|
||||
if (profile.operatorId() != m_operatorId)
|
||||
continue;
|
||||
modifyRequest.id(profile.id());
|
||||
break;
|
||||
}
|
||||
|
||||
modifyRequest.exerciseId(m_session->exerciseId());
|
||||
modifyRequest.operatorId(m_operatorId);
|
||||
modifyRequest.exerciseId(m_session->exerciseId());
|
||||
modifyRequest.operatorId(m_operatorId);
|
||||
|
||||
const QVector<StreamData> allocatedList = m_modelAllocated->getStreamDataVector();
|
||||
modifyRequest.data().reserve(allocatedList.size());
|
||||
for (const StreamData &stream : allocatedList)
|
||||
{
|
||||
CnrTvcProfileData circuitData;
|
||||
circuitData.radioSystemId(stream.bIsCnr ? RadioSystem::Cnr : RadioSystem::Tvc);
|
||||
circuitData.radioCircuitId(stream.topicId);
|
||||
modifyRequest.data().push_back(std::move(circuitData));
|
||||
}
|
||||
const QVector<StreamData> allocatedList = m_modelAllocated->getStreamDataVector();
|
||||
modifyRequest.data().reserve(allocatedList.size());
|
||||
for (const StreamData& stream : allocatedList)
|
||||
{
|
||||
CnrTvcProfileData circuitData;
|
||||
circuitData.radioSystemId(stream.bIsCnr ? RadioSystem::Cnr : RadioSystem::Tvc);
|
||||
circuitData.radioCircuitId(stream.topicId);
|
||||
modifyRequest.data().push_back(std::move(circuitData));
|
||||
}
|
||||
|
||||
m_requestHelper->startSingleRequest([this, modifyRequest]()
|
||||
{
|
||||
return m_avmFtc->modifyCnrTvcProfileRequest(modifyRequest, this);
|
||||
});
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, modifyRequest]() { return m_avmFtc->modifyCnrTvcProfileRequest(modifyRequest, this); });
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onModifyCnrTvcProfileReply(const Core::FunctionReplyObject &replyObject)
|
||||
void AudioSettingsDialog::onModifyCnrTvcProfileReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
__unchange__();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
__unchange__();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onRemoveCnrTvcProfileReply(const Core::FunctionReplyObject &replyObject)
|
||||
void AudioSettingsDialog::onRemoveCnrTvcProfileReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
__unchange__();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
__unchange__();
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onSelectionOperatorChanged(const int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
if (hasUnsavedChanges() ||
|
||||
m_modelAllocated->getChangeState() ||
|
||||
m_modelAvailable->getChangeState())
|
||||
{
|
||||
switch (askApplyDiscardCancel())
|
||||
Q_UNUSED(index);
|
||||
if (hasUnsavedChanges() || m_modelAllocated->getChangeState() || m_modelAvailable->getChangeState())
|
||||
{
|
||||
case LtsWidgets::Button::Apply:
|
||||
if (!apply())
|
||||
return;
|
||||
break;
|
||||
case LtsWidgets::Button::Cancel:
|
||||
{
|
||||
|
||||
|
||||
|
||||
switch (askApplyDiscardCancel())
|
||||
{
|
||||
QSignalBlocker blockSignals(m_ui->operatorComboBox);
|
||||
m_ui->operatorComboBox->setCurrentIndex(m_ui->operatorComboBox->findData(m_operatorId));
|
||||
case LtsWidgets::Button::Apply:
|
||||
if (!apply())
|
||||
return;
|
||||
break;
|
||||
case LtsWidgets::Button::Cancel: {
|
||||
|
||||
{
|
||||
QSignalBlocker blockSignals(m_ui->operatorComboBox);
|
||||
m_ui->operatorComboBox->setCurrentIndex(m_ui->operatorComboBox->findData(m_operatorId));
|
||||
}
|
||||
return;
|
||||
}
|
||||
case LtsWidgets::Button::Discard:
|
||||
__unchange__();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case LtsWidgets::Button::Discard:
|
||||
__unchange__();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
m_operatorId = m_ui->operatorComboBox->currentData().toInt();
|
||||
DEBUG_LOG(m_logger) << "onSelectionOperatorChanged" << " operatorStr=" << m_ui->operatorComboBox->currentText() << " m_operatorId= " << m_operatorId;
|
||||
fillOperatorList();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
m_ui->pushButtonUp->setEnabled(false);
|
||||
m_ui->pushButtonDown->setEnabled(false);
|
||||
m_operatorId = m_ui->operatorComboBox->currentData().toInt();
|
||||
DEBUG_LOG(m_logger) << "onSelectionOperatorChanged" << " operatorStr=" << m_ui->operatorComboBox->currentText()
|
||||
<< " m_operatorId= " << m_operatorId;
|
||||
fillOperatorList();
|
||||
m_modelAllocated->resetChangeState();
|
||||
m_modelAvailable->resetChangeState();
|
||||
m_filterAvailable->invalidate();
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onDroppedInAllocated(const QVector<StreamData> &streams)
|
||||
void AudioSettingsDialog::onDroppedInAllocated(const QVector<StreamData>& streams)
|
||||
{
|
||||
slotChangesMade();
|
||||
m_filterAvailable->addAllocatedStreams(streams);
|
||||
m_modelAllocated->setStreamChanged(streams);
|
||||
m_modelAvailable->setStreamChanged(streams);
|
||||
slotChangesMade();
|
||||
m_filterAvailable->addAllocatedStreams(streams);
|
||||
m_modelAllocated->setStreamChanged(streams);
|
||||
m_modelAvailable->setStreamChanged(streams);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onDroppedInAvailable(const QVector<StreamData> &streams)
|
||||
void AudioSettingsDialog::onDroppedInAvailable(const QVector<StreamData>& streams)
|
||||
{
|
||||
slotChangesMade();
|
||||
m_filterAvailable->removeAllocatedStreams(streams);
|
||||
m_modelAllocated->setStreamChanged(streams);
|
||||
m_modelAvailable->setStreamChanged(streams);
|
||||
slotChangesMade();
|
||||
m_filterAvailable->removeAllocatedStreams(streams);
|
||||
m_modelAllocated->setStreamChanged(streams);
|
||||
m_modelAvailable->setStreamChanged(streams);
|
||||
}
|
||||
|
||||
void AudioSettingsDialog::onEntryRemoved(const StreamData &stream)
|
||||
void AudioSettingsDialog::onEntryRemoved(const StreamData& stream)
|
||||
{
|
||||
m_modelAllocated->removeEntry(stream);
|
||||
m_filterAvailable->removeAllocatedStreams({stream});
|
||||
m_modelAllocated->removeEntry(stream);
|
||||
m_filterAvailable->removeAllocatedStreams({stream});
|
||||
}
|
||||
|
||||
StreamData AudioSettingsDialog::toStreamData(const CnrTvcProfileData &profileEntry) const
|
||||
StreamData AudioSettingsDialog::toStreamData(const CnrTvcProfileData& profileEntry) const
|
||||
{
|
||||
int configId = profileEntry.radioCircuitId();
|
||||
StreamData streamData;
|
||||
streamData.topicId = configId;
|
||||
int configId = profileEntry.radioCircuitId();
|
||||
StreamData streamData;
|
||||
streamData.topicId = configId;
|
||||
|
||||
if (profileEntry.radioSystemId() == RadioSystem::Cnr)
|
||||
{
|
||||
streamData.name = QString::fromStdString(m_avmDtc->cnrConfig(configId).radioCircuit());
|
||||
streamData.bIsCnr = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
streamData.name = QString::fromStdString(m_avmDtc->tvcConfig(configId).radioCircuit());
|
||||
streamData.bIsCnr = false;
|
||||
}
|
||||
if (profileEntry.radioSystemId() == RadioSystem::Cnr)
|
||||
{
|
||||
streamData.name = QString::fromStdString(m_avmDtc->cnrConfig(configId).radioCircuit());
|
||||
streamData.bIsCnr = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
streamData.name = QString::fromStdString(m_avmDtc->tvcConfig(configId).radioCircuit());
|
||||
streamData.bIsCnr = false;
|
||||
}
|
||||
|
||||
return streamData;
|
||||
return streamData;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+120
-134
@@ -1,179 +1,165 @@
|
||||
|
||||
|
||||
|
||||
#include "audio_settings_used_streams_model.h"
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
#include <QMimeData>
|
||||
|
||||
#include <QFont>
|
||||
#include <QMimeData>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
AllocatedStreamsModel::AllocatedStreamsModel(QObject *parent)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant(QLatin1String("root"))), { tr("Allocated") })
|
||||
AllocatedStreamsModel::AllocatedStreamsModel(QObject* parent)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant(QLatin1String("root"))), {tr("Allocated")})
|
||||
{
|
||||
setMimeType(StreamData::mimeType());
|
||||
setMimeType(StreamData::mimeType());
|
||||
}
|
||||
|
||||
Qt::ItemFlags AllocatedStreamsModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags AllocatedStreamsModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
return NGLTreeModel::flags(index) | Qt::ItemIsDropEnabled;
|
||||
return NGLTreeModel::flags(index) | Qt::ItemIsDropEnabled;
|
||||
}
|
||||
|
||||
QVariant AllocatedStreamsModel::data(const QModelIndex &index, int role) const
|
||||
QVariant AllocatedStreamsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
switch (role)
|
||||
{
|
||||
NGLTreeItem *item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
DEBUG_LOG(m_logger) << data.name;
|
||||
return data.name;
|
||||
case Qt::DisplayRole: {
|
||||
NGLTreeItem* item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
DEBUG_LOG(m_logger) << data.name;
|
||||
return data.name;
|
||||
}
|
||||
|
||||
case Qt::FontRole: {
|
||||
NGLTreeItem* item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
if (!m_changedStreams.contains(QPair<bool, int>(data.bIsCnr, data.topicId)))
|
||||
return {};
|
||||
QFont f;
|
||||
f.setBold(true);
|
||||
return f;
|
||||
}
|
||||
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
case Qt::FontRole:
|
||||
{
|
||||
NGLTreeItem *item = privateData(index);
|
||||
StreamData data = item->data().value<StreamData>();
|
||||
if (!m_changedStreams.contains(QPair<bool,int>(data.bIsCnr, data.topicId)))
|
||||
return {};
|
||||
QFont f;
|
||||
f.setBold(true);
|
||||
return f;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NGLTreeModel::data(index, role);
|
||||
return NGLTreeModel::data(index, role);
|
||||
}
|
||||
|
||||
|
||||
void AllocatedStreamsModel::setStreamChanged(const QVector<StreamData> &streams)
|
||||
void AllocatedStreamsModel::setStreamChanged(const QVector<StreamData>& streams)
|
||||
{
|
||||
for (const StreamData &d : streams)
|
||||
if (!m_changedStreams.contains(QPair<bool,int>(d.bIsCnr, d.topicId)))
|
||||
m_changedStreams += QPair<bool,int>(d.bIsCnr, d.topicId);
|
||||
emit modelDataChanged();
|
||||
for (const StreamData& d : streams)
|
||||
if (!m_changedStreams.contains(QPair<bool, int>(d.bIsCnr, d.topicId)))
|
||||
m_changedStreams += QPair<bool, int>(d.bIsCnr, d.topicId);
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
|
||||
bool AllocatedStreamsModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
|
||||
bool AllocatedStreamsModel::canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
if (action != supportedDropActions())
|
||||
return false;
|
||||
return true;
|
||||
Q_UNUSED(data);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
if (action != supportedDropActions())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool AllocatedStreamsModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent)
|
||||
bool AllocatedStreamsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent)
|
||||
{
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
Q_UNUSED(row);
|
||||
Q_UNUSED(column);
|
||||
Q_UNUSED(parent);
|
||||
|
||||
const QVector<NGLTreeItem *> droppedItems = getMimeDataItems(data, m_mimeType);
|
||||
QVector<StreamData> streams;
|
||||
streams.reserve(droppedItems.size());
|
||||
for (const NGLTreeItem *item : droppedItems)
|
||||
streams += item->data().value<StreamData>();
|
||||
qDeleteAll(droppedItems);
|
||||
emit droppedStreamNames(streams);
|
||||
m_changes = true;
|
||||
DEBUG_LOG(m_logger) << data->data(QStringLiteral("NGLTreeModel/dragDrop"));
|
||||
return NGLTreeModel::dropMimeData(data, action, row, 0, QModelIndex());
|
||||
const QVector<NGLTreeItem*> droppedItems = getMimeDataItems(data, m_mimeType);
|
||||
QVector<StreamData> streams;
|
||||
streams.reserve(droppedItems.size());
|
||||
for (const NGLTreeItem* item : droppedItems)
|
||||
streams += item->data().value<StreamData>();
|
||||
qDeleteAll(droppedItems);
|
||||
emit droppedStreamNames(streams);
|
||||
m_changes = true;
|
||||
DEBUG_LOG(m_logger) << data->data(QStringLiteral("NGLTreeModel/dragDrop"));
|
||||
return NGLTreeModel::dropMimeData(data, action, row, 0, QModelIndex());
|
||||
}
|
||||
|
||||
|
||||
void AllocatedStreamsModel::setNewStreamData(const QVector<StreamData> &newData)
|
||||
void AllocatedStreamsModel::setNewStreamData(const QVector<StreamData>& newData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "set new stream data, count: " << newData.size();
|
||||
resetModel();
|
||||
for (const StreamData &sd : newData)
|
||||
m_rootItem->appendChild(new NGLTreeItem(QVariant::fromValue(sd)));
|
||||
DEBUG_LOG(m_logger) << "set new stream data, count: " << newData.size();
|
||||
resetModel();
|
||||
for (const StreamData& sd : newData)
|
||||
m_rootItem->appendChild(new NGLTreeItem(QVariant::fromValue(sd)));
|
||||
|
||||
emit modelDataChanged();
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
QVector<StreamData> AllocatedStreamsModel::getStreamDataVector() const
|
||||
{
|
||||
QVector<StreamData> result;
|
||||
result.reserve(m_rootItem->childCount());
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
const NGLTreeItem *item = m_rootItem->child(i);
|
||||
const StreamData sd = item->data().value<StreamData>();
|
||||
result.append(sd);
|
||||
DEBUG_LOG(m_logger) << "result.append(sd.name):" << sd.name;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "getStreamDataVector() size: " << result.size();
|
||||
return result;
|
||||
}
|
||||
|
||||
void AllocatedStreamsModel::changeOrder(const QModelIndex &idx, bool up)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "changeOrder "
|
||||
<< " index = " << idx.row()
|
||||
<< " up = " << up
|
||||
<< " m_rootItem->childCount()= " << m_rootItem->childCount();
|
||||
if (up)
|
||||
{
|
||||
moveRow(idx.parent(), idx.row(),
|
||||
idx.parent(), idx.row() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
moveRow(idx.parent(), idx.row(),
|
||||
idx.parent(), idx.row() + 1);
|
||||
}
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
|
||||
void AllocatedStreamsModel::updateEntry(const StreamData &stream)
|
||||
{
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
NGLTreeItem *child = m_rootItem->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
|
||||
if (data == stream)
|
||||
QVector<StreamData> result;
|
||||
result.reserve(m_rootItem->childCount());
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
setItemData(indexFromItem(child), QVariant::fromValue(stream), child->icon());
|
||||
break;
|
||||
const NGLTreeItem* item = m_rootItem->child(i);
|
||||
const StreamData sd = item->data().value<StreamData>();
|
||||
result.append(sd);
|
||||
DEBUG_LOG(m_logger) << "result.append(sd.name):" << sd.name;
|
||||
}
|
||||
}
|
||||
|
||||
emit modelDataChanged();
|
||||
DEBUG_LOG(m_logger) << "getStreamDataVector() size: " << result.size();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void AllocatedStreamsModel::removeEntry(const StreamData &stream)
|
||||
void AllocatedStreamsModel::changeOrder(const QModelIndex& idx, bool up)
|
||||
{
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
NGLTreeItem *child = m_rootItem->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == stream)
|
||||
DEBUG_LOG(m_logger) << "changeOrder "
|
||||
<< " index = " << idx.row() << " up = " << up
|
||||
<< " m_rootItem->childCount()= " << m_rootItem->childCount();
|
||||
if (up)
|
||||
{
|
||||
removeRows(i, 1, indexFromItem(m_rootItem));
|
||||
break;
|
||||
moveRow(idx.parent(), idx.row(), idx.parent(), idx.row() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
emit modelDataChanged();
|
||||
else
|
||||
{
|
||||
moveRow(idx.parent(), idx.row(), idx.parent(), idx.row() + 1);
|
||||
}
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
}
|
||||
void AllocatedStreamsModel::updateEntry(const StreamData& stream)
|
||||
{
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
NGLTreeItem* child = m_rootItem->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
|
||||
if (data == stream)
|
||||
{
|
||||
setItemData(indexFromItem(child), QVariant::fromValue(stream), child->icon());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
void AllocatedStreamsModel::removeEntry(const StreamData& stream)
|
||||
{
|
||||
for (int i = 0; i < m_rootItem->childCount(); i++)
|
||||
{
|
||||
NGLTreeItem* child = m_rootItem->child(i);
|
||||
StreamData data = child->data().value<StreamData>();
|
||||
if (data == stream)
|
||||
{
|
||||
removeRows(i, 1, indexFromItem(m_rootItem));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
emit modelDataChanged();
|
||||
}
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+47
-28
@@ -1,49 +1,68 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include "audio_stream_type.h"
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class AllocatedStreamsModel final : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AllocatedStreamsModel(QObject *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AllocatedStreamsModel(QObject* parent = nullptr);
|
||||
|
||||
bool getChangeState() {bool result = m_changes; m_changes = false; return result;}
|
||||
void resetChangeState() {m_changes = false;m_changedStreams.clear();}
|
||||
bool getChangeState()
|
||||
{
|
||||
bool result = m_changes;
|
||||
m_changes = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
Qt::DropActions supportedDropActions() const override { return Qt::CopyAction; }
|
||||
Qt::DropActions supportedDragActions() const override { return Qt::MoveAction; }
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) override;
|
||||
void setStreamChanged(const QVector<StreamData> &streams);
|
||||
void resetChangeState()
|
||||
{
|
||||
m_changes = false;
|
||||
m_changedStreams.clear();
|
||||
}
|
||||
|
||||
void setNewStreamData(const QVector<StreamData> &newData);
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
QVector<StreamData> getStreamDataVector() const;
|
||||
Qt::DropActions supportedDropActions() const override
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
|
||||
void changeOrder(const QModelIndex &idx, bool up);
|
||||
void updateEntry(const StreamData &stream);
|
||||
void removeEntry(const StreamData &stream);
|
||||
Qt::DropActions supportedDragActions() const override
|
||||
{
|
||||
return Qt::MoveAction;
|
||||
}
|
||||
|
||||
signals:
|
||||
void droppedStreamNames(const QVector<AudioVideoManagement::StreamData> &streamNamesDropped);
|
||||
bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) override;
|
||||
void setStreamChanged(const QVector<StreamData>& streams);
|
||||
|
||||
private:
|
||||
void setNewStreamData(const QVector<StreamData>& newData);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool m_changes{false};
|
||||
QVector<QPair<bool , int> > m_changedStreams;
|
||||
QVector<StreamData> getStreamDataVector() const;
|
||||
|
||||
void changeOrder(const QModelIndex& idx, bool up);
|
||||
void updateEntry(const StreamData& stream);
|
||||
void removeEntry(const StreamData& stream);
|
||||
|
||||
signals:
|
||||
void droppedStreamNames(const QVector<AudioVideoManagement::StreamData>& streamNamesDropped);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool m_changes{false};
|
||||
QVector<QPair<bool, int>> m_changedStreams;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+47
-53
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
@@ -15,67 +13,63 @@ namespace AudioVideoManagement
|
||||
|
||||
class AvsSequence
|
||||
{
|
||||
public:
|
||||
QString internalStreamName;
|
||||
AvaSpeed speed{100};
|
||||
AvaVolume volume{0};
|
||||
AvaTimePoint start;
|
||||
AvaDuration duration;
|
||||
bool pint = false;
|
||||
QString description;
|
||||
public:
|
||||
QString internalStreamName;
|
||||
AvaSpeed speed{100};
|
||||
AvaVolume volume{0};
|
||||
AvaTimePoint start;
|
||||
AvaDuration duration;
|
||||
bool pint = false;
|
||||
QString description;
|
||||
};
|
||||
|
||||
|
||||
class AvmSequenceModel final : public LtsWidgets::LtsAbstractTableModel<AvsSequence>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Order = 0,
|
||||
Start,
|
||||
End,
|
||||
Duration,
|
||||
Streams,
|
||||
Speed,
|
||||
Volume,
|
||||
Description
|
||||
};
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns { Order = 0, Start, End, Duration, Streams, Speed, Volume, Description };
|
||||
|
||||
explicit AvmSequenceModel(QObject *parent = nullptr);
|
||||
void moveUp(const QModelIndex &idx);
|
||||
void moveDown(const QModelIndex &idx);
|
||||
bool initModel(const QJsonArray &data);
|
||||
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) override;
|
||||
QJsonArray getSequencesAsJsonArray() const;
|
||||
QVariant data(const QModelIndex &idx, int role = Qt::DisplayRole) const override;
|
||||
QVector<int> highlightedRows() const { return m_highlightedRows; }
|
||||
void setHighlightedRow(int highlighted, bool reset = true);
|
||||
explicit AvmSequenceModel(QObject* parent = nullptr);
|
||||
void moveUp(const QModelIndex& idx);
|
||||
void moveDown(const QModelIndex& idx);
|
||||
bool initModel(const QJsonArray& data);
|
||||
bool moveRows(const QModelIndex& sourceParent, int sourceRow, int count, const QModelIndex& destinationParent,
|
||||
int destinationChild) override;
|
||||
QJsonArray getSequencesAsJsonArray() const;
|
||||
QVariant data(const QModelIndex& idx, int role = Qt::DisplayRole) const override;
|
||||
|
||||
friend class AvmSequenceProxyModel;
|
||||
QVector<int> highlightedRows() const
|
||||
{
|
||||
return m_highlightedRows;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void setTimezoneHoursOffset(int timezoneHoursOffset);
|
||||
void setHighlightedRow(int highlighted, bool reset = true);
|
||||
|
||||
private:
|
||||
friend class AvmSequenceProxyModel;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
QString dateTimeToStringx(const QDateTime &dt) const;
|
||||
QString msecsSinceEpochToStringx(qint64 msecs) const;
|
||||
public slots:
|
||||
void setTimezoneHoursOffset(int timezoneHoursOffset);
|
||||
|
||||
QVector<int> m_highlightedRows;
|
||||
int m_timezoneHoursOffset = 0;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
QString dateTimeToStringx(const QDateTime& dt) const;
|
||||
QString msecsSinceEpochToStringx(qint64 msecs) const;
|
||||
|
||||
QVector<int> m_highlightedRows;
|
||||
int m_timezoneHoursOffset = 0;
|
||||
};
|
||||
|
||||
class AvmSequenceProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
AvmSequenceModel *m_sourceModel = nullptr;
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel* sourceModel) override;
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override;
|
||||
|
||||
private:
|
||||
AvmSequenceModel* m_sourceModel = nullptr;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+423
-483
File diff suppressed because it is too large.
Load diff
Executable → Regular
+45
-44
@@ -1,10 +1,9 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "avm_sequence_model.h"
|
||||
#include "../avm_playback_menu.h"
|
||||
#include "avm_sequence_model.h"
|
||||
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
@@ -12,63 +11,65 @@
|
||||
#include <Plugins/AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <TopicEditorBase/topic_editor_base.h>
|
||||
|
||||
|
||||
namespace Ui { class AVTopicEditor; }
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AVTopicEditor;
|
||||
}
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class TopicEditor : public TopicEditorBase::TopicEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TopicEditor(LtsSession::LtsSession *session, const TopicEditorBase::TopicData &data, QWidget *parent = nullptr);
|
||||
~TopicEditor();
|
||||
public:
|
||||
explicit TopicEditor(LtsSession::LtsSession* session, const TopicEditorBase::TopicData& data,
|
||||
QWidget* parent = nullptr);
|
||||
~TopicEditor();
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
void updateInternalData() override final;
|
||||
void retranslate() override final;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void updateInternalData() override final;
|
||||
void retranslate() override final;
|
||||
|
||||
AvsSequence createSequence(const AvaTimePoint &start, const AvaTimePoint &end) const;
|
||||
AvsSequence createCurrentSequence() const;
|
||||
void refreshDurationText();
|
||||
void setDurationText(qint64 length);
|
||||
qint64 calcTrackLength(const QJsonArray &arr) const;
|
||||
void playbackDlgNotAvailable(const QString &msg);
|
||||
AvsSequence createSequence(const AvaTimePoint& start, const AvaTimePoint& end) const;
|
||||
AvsSequence createCurrentSequence() const;
|
||||
void refreshDurationText();
|
||||
void setDurationText(qint64 length);
|
||||
qint64 calcTrackLength(const QJsonArray& arr) const;
|
||||
void playbackDlgNotAvailable(const QString& msg);
|
||||
|
||||
private slots:
|
||||
bool apply2() override final;
|
||||
private slots:
|
||||
bool apply2() override final;
|
||||
|
||||
void onEditSequence();
|
||||
void onTimeChanged();
|
||||
void onApplySequence();
|
||||
void onAddSequence();
|
||||
void onDeleteSequences();
|
||||
void onSequenceUp();
|
||||
void onSequenceDown();
|
||||
void onSetTopicButtonStates(bool enable);
|
||||
void onEnaDisa();
|
||||
void onMarkerSelected(const QString &description);
|
||||
void onEditSequence();
|
||||
void onTimeChanged();
|
||||
void onApplySequence();
|
||||
void onAddSequence();
|
||||
void onDeleteSequences();
|
||||
void onSequenceUp();
|
||||
void onSequenceDown();
|
||||
void onSetTopicButtonStates(bool enable);
|
||||
void onEnaDisa();
|
||||
void onMarkerSelected(const QString& description);
|
||||
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
const int s_durationLimit{86400000};
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
const int s_durationLimit{86400000};
|
||||
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
std::shared_ptr<AudioVideoManagement::DataInterface> m_avmDataIfc{nullptr};
|
||||
LtsSession::LtsSession* m_session{nullptr};
|
||||
std::shared_ptr<AudioVideoManagement::DataInterface> m_avmDataIfc{nullptr};
|
||||
|
||||
AvmSequenceModel *m_model{nullptr};
|
||||
AvmSequenceProxyModel *m_proxyModel{nullptr};
|
||||
AvmPlaybackMenu *m_playbackMenu{nullptr};
|
||||
AvmSequenceModel* m_model{nullptr};
|
||||
AvmSequenceProxyModel* m_proxyModel{nullptr};
|
||||
AvmPlaybackMenu* m_playbackMenu{nullptr};
|
||||
|
||||
bool m_isAudio{false};
|
||||
qint64 m_topicStartTime{0};
|
||||
QString m_topicStreamName;
|
||||
bool m_isAudio{false};
|
||||
qint64 m_topicStartTime{0};
|
||||
QString m_topicStreamName;
|
||||
|
||||
Ui::AVTopicEditor *m_ui{nullptr};
|
||||
Ui::AVTopicEditor* m_ui{nullptr};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+195
-239
@@ -1,317 +1,273 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_available_streams_model.h"
|
||||
|
||||
#include <AudioVideoManagement/stream_name_mapping.h>
|
||||
#include <InfrastructureManagement/ism.hpp>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
#include <QSet>
|
||||
#include <QMimeData>
|
||||
#include <QCollator>
|
||||
#include <QMimeData>
|
||||
#include <QSet>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool isMountingPointOfInterest(const InfrastructureManagement::StructureElement &se, bool isAudio)
|
||||
bool isMountingPointOfInterest(const InfrastructureManagement::StructureElement& se, bool isAudio)
|
||||
{
|
||||
if (se.structureElementTypeId() != InfrastructureManagement::StructureElementType::MountingPoint)
|
||||
if (se.structureElementTypeId() != InfrastructureManagement::StructureElementType::MountingPoint)
|
||||
return false;
|
||||
|
||||
if (se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::IndoorCamera ||
|
||||
se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::OutdoorCamera)
|
||||
return true;
|
||||
|
||||
if (isAudio && se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::AnnouncementUnit)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
|
||||
if (se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::IndoorCamera ||
|
||||
se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::OutdoorCamera)
|
||||
return true;
|
||||
|
||||
if (isAudio && se.mountingPointTypeId() == InfrastructureManagement::MountingPointType::AnnouncementUnit)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
const QString AvailableStreamsModel::s_MimeType = QStringLiteral("AvailStreamsModel/DragDrop");
|
||||
|
||||
|
||||
|
||||
struct sorter
|
||||
{
|
||||
bool operator()(const StreamModelData &i, const StreamModelData &j)
|
||||
{
|
||||
QCollator col;
|
||||
col.setNumericMode(true);
|
||||
return col.compare(j.name, i.name) > 0 ;
|
||||
}
|
||||
bool operator()(const StreamModelData& i, const StreamModelData& j)
|
||||
{
|
||||
QCollator col;
|
||||
col.setNumericMode(true);
|
||||
return col.compare(j.name, i.name) > 0;
|
||||
}
|
||||
} sortStuff;
|
||||
|
||||
|
||||
AvailableStreamsModel::AvailableStreamsModel(const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
LtsSession::LtsSession *session,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
QObject *parent,
|
||||
bool isAudio) : NGLTreeModel(parent, new NGLTreeItem(QVariant(), QIcon()),,
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {tr("Available Streams")})
|
||||
, m_isAudio(isAudio)
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_ismDtc(ismDtc)
|
||||
, m_session(session)
|
||||
, m_streamNameMapping(streamNameMapping)
|
||||
AvailableStreamsModel::AvailableStreamsModel(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
LtsSession::LtsSession* session, StreamNameMapping* streamNameMapping,
|
||||
QObject* parent, bool isAudio)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant(), QIcon()), ,
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()){tr("Available Streams")}),
|
||||
m_isAudio(isAudio), m_avmDtc(avmDtc), m_ismDtc(ismDtc), m_session(session), m_streamNameMapping(streamNameMapping)
|
||||
{
|
||||
Q_ASSERT(ismDtc);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
qRegisterMetaTypeStreamOperators<StreamModelData>("StreamModelData");
|
||||
qRegisterMetaType<StreamModelData>("StreamModelData");
|
||||
Q_ASSERT(ismDtc);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
qRegisterMetaTypeStreamOperators<StreamModelData>("StreamModelData");
|
||||
qRegisterMetaType<StreamModelData>("StreamModelData");
|
||||
|
||||
setMimeType(s_MimeType);
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged,
|
||||
this, [ this]()
|
||||
{
|
||||
setMimeType(s_MimeType);
|
||||
connect(m_ismDtc.get(), &InfrastructureManagement::Interface::Dtc::mainStructureElementChanged, this,
|
||||
[this]() { initModel(); });
|
||||
|
||||
connect(m_streamNameMapping, &StreamNameMapping::changed, this, [this]() { initModel(); });
|
||||
|
||||
if (!m_isAudio)
|
||||
{
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::videoTeamChanged, this,
|
||||
[this]() { initModel(); });
|
||||
}
|
||||
initModel();
|
||||
});
|
||||
|
||||
connect(m_streamNameMapping, &StreamNameMapping::changed,
|
||||
this, [ this]()
|
||||
{
|
||||
initModel();
|
||||
});
|
||||
|
||||
if (!m_isAudio)
|
||||
{
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::videoTeamChanged,
|
||||
this, [ this]()
|
||||
{
|
||||
initModel();
|
||||
});
|
||||
}
|
||||
initModel();
|
||||
}
|
||||
|
||||
QVariant AvailableStreamsModel::data(const QModelIndex &index, int role) const
|
||||
QVariant AvailableStreamsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
NGLTreeItem *item = privateData(index);
|
||||
if (!item->data().canConvert<StreamModelData>())
|
||||
return QVariant();
|
||||
NGLTreeItem* item = privateData(index);
|
||||
if (!item->data().canConvert<StreamModelData>())
|
||||
return QVariant();
|
||||
|
||||
const StreamModelData availStream = item->data().value<StreamModelData>();
|
||||
const StreamModelData availStream = item->data().value<StreamModelData>();
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
switch (index.column())
|
||||
switch (role)
|
||||
{
|
||||
case 0 :
|
||||
return availStream.name;
|
||||
default:
|
||||
return QStringLiteral("??");
|
||||
case Qt::DisplayRole: {
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return availStream.name;
|
||||
default:
|
||||
return QStringLiteral("??");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Qt::DecorationRole: {
|
||||
switch (index.column())
|
||||
{
|
||||
case 0: {
|
||||
static const QIcon folder(QStringLiteral("icon:evaluation_folder.svg"));
|
||||
static const QIcon camera(QStringLiteral("icon:camera_control.svg"));
|
||||
return availStream.isGroup ? folder : camera;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
static const QIcon folder(QStringLiteral("icon:evaluation_folder.svg"));
|
||||
static const QIcon camera(QStringLiteral("icon:camera_control.svg"));
|
||||
return availStream.isGroup ? folder : camera;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NGLTreeModel::data(index, role);
|
||||
return NGLTreeModel::data(index, role);
|
||||
}
|
||||
|
||||
|
||||
Qt::ItemFlags AvailableStreamsModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags AvailableStreamsModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
Qt::ItemFlags defaultFlags = NGLTreeModel::flags(index);
|
||||
NGLTreeItem *item = privateData(index);
|
||||
Qt::ItemFlags defaultFlags = NGLTreeModel::flags(index);
|
||||
NGLTreeItem* item = privateData(index);
|
||||
|
||||
if (item == m_rootItem)
|
||||
return defaultFlags;
|
||||
if (item == m_rootItem)
|
||||
return defaultFlags;
|
||||
|
||||
return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
|
||||
return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
|
||||
}
|
||||
|
||||
|
||||
QMimeData *AvailableStreamsModel::mimeData(const QModelIndexList &indexes) const
|
||||
QMimeData* AvailableStreamsModel::mimeData(const QModelIndexList& indexes) const
|
||||
{
|
||||
|
||||
QMimeData *pData = NGLTreeModel::mimeData(indexes);
|
||||
pData->setText(data(indexes[0]).toString());
|
||||
return pData;
|
||||
|
||||
QMimeData* pData = NGLTreeModel::mimeData(indexes);
|
||||
pData->setText(data(indexes[0]).toString());
|
||||
return pData;
|
||||
}
|
||||
|
||||
|
||||
bool AvailableStreamsModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent)
|
||||
bool AvailableStreamsModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent)
|
||||
{
|
||||
INFO_LOG(m_logger) << "dropMimeData: action = " << action
|
||||
<< ", row = " << row
|
||||
<< ", parent: valid = " << parent.isValid();
|
||||
INFO_LOG(m_logger) << "dropMimeData: action = " << action << ", row = " << row
|
||||
<< ", parent: valid = " << parent.isValid();
|
||||
|
||||
if (action == Qt::IgnoreAction)
|
||||
return true;
|
||||
if (action == Qt::IgnoreAction)
|
||||
return true;
|
||||
|
||||
if (!data->hasFormat(s_MimeType))
|
||||
return false;
|
||||
if (!data->hasFormat(s_MimeType))
|
||||
return false;
|
||||
|
||||
if ((action != Qt::MoveAction) && (action != Qt::CopyAction))
|
||||
return false;
|
||||
if ((action != Qt::MoveAction) && (action != Qt::CopyAction))
|
||||
return false;
|
||||
|
||||
return NGLTreeModel::dropMimeData(data, action, row, column, parent);
|
||||
return NGLTreeModel::dropMimeData(data, action, row, column, parent);
|
||||
}
|
||||
|
||||
|
||||
void AvailableStreamsModel::initModel()
|
||||
{
|
||||
beginResetModel();
|
||||
INFO_LOG(m_logger) << "initModel";
|
||||
|
||||
|
||||
m_rootItem->removeAllChildren();
|
||||
|
||||
StreamModelData availStream;
|
||||
availStream.id = 0;
|
||||
availStream.name = tr("New group");
|
||||
availStream.parentId = -1;
|
||||
availStream.isGroup = true;
|
||||
beginResetModel();
|
||||
INFO_LOG(m_logger) << "initModel";
|
||||
|
||||
QVariant data;
|
||||
data.setValue(availStream);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
m_rootItem->removeAllChildren();
|
||||
|
||||
std::vector<StreamModelData> toAddIndoor;
|
||||
std::vector<StreamModelData> toAddOutdoor;
|
||||
StreamModelData availStream;
|
||||
availStream.id = 0;
|
||||
availStream.name = tr("New group");
|
||||
availStream.parentId = -1;
|
||||
availStream.isGroup = true;
|
||||
|
||||
std::vector<StreamModelData> toAddMvs;
|
||||
QVariant data;
|
||||
data.setValue(availStream);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
|
||||
std::vector<StreamModelData> toAddIndoor;
|
||||
std::vector<StreamModelData> toAddOutdoor;
|
||||
|
||||
const auto &mountedAssets = m_ismDtc->mountingPointAssets();
|
||||
const auto &buildings = m_ismDtc->mainStructureElements();
|
||||
for (const auto &building : buildings)
|
||||
{
|
||||
for (const auto &mountingPoint : building.elements())
|
||||
std::vector<StreamModelData> toAddMvs;
|
||||
|
||||
const auto& mountedAssets = m_ismDtc->mountingPointAssets();
|
||||
const auto& buildings = m_ismDtc->mainStructureElements();
|
||||
for (const auto& building : buildings)
|
||||
{
|
||||
if (!isMountingPointOfInterest(mountingPoint, m_isAudio))
|
||||
continue;
|
||||
|
||||
|
||||
bool isMounted = false;
|
||||
for (const auto &mountedAsset : mountedAssets)
|
||||
{
|
||||
if (mountedAsset.structureElementId() == mountingPoint.id())
|
||||
for (const auto& mountingPoint : building.elements())
|
||||
{
|
||||
isMounted = true;
|
||||
break;
|
||||
if (!isMountingPointOfInterest(mountingPoint, m_isAudio))
|
||||
continue;
|
||||
|
||||
bool isMounted = false;
|
||||
for (const auto& mountedAsset : mountedAssets)
|
||||
{
|
||||
if (mountedAsset.structureElementId() == mountingPoint.id())
|
||||
{
|
||||
isMounted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMounted)
|
||||
continue;
|
||||
StreamModelData item;
|
||||
item.name = m_streamNameMapping->displayName(mountingPoint.id());
|
||||
item.mountingPointId = mountingPoint.id();
|
||||
item.isGroup = false;
|
||||
|
||||
if (mountingPoint.mountingPointTypeId() == InfrastructureManagement::MountingPointType::IndoorCamera)
|
||||
toAddIndoor.push_back(item);
|
||||
else
|
||||
toAddOutdoor.push_back(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isMounted)
|
||||
continue;
|
||||
StreamModelData item;
|
||||
item.name = m_streamNameMapping->displayName(mountingPoint.id());
|
||||
item.mountingPointId = mountingPoint.id();
|
||||
item.isGroup = false;
|
||||
|
||||
|
||||
if (mountingPoint.mountingPointTypeId() == InfrastructureManagement::MountingPointType::IndoorCamera)
|
||||
toAddIndoor.push_back(item);
|
||||
else
|
||||
toAddOutdoor.push_back(item);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!m_isAudio)
|
||||
{
|
||||
const auto &mvsStreams = m_avmDtc->videoTeams();
|
||||
for (const auto &videoTeam : mvsStreams)
|
||||
if (!m_isAudio)
|
||||
{
|
||||
if (videoTeam.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
DEBUG_LOG(m_logger) << "add new videoteam" << videoTeam;
|
||||
StreamModelData item;
|
||||
item.name = QString::fromStdString(videoTeam.streamName().c_str());
|
||||
item.mountingPointId = -1 * videoTeam.id();
|
||||
item.isGroup = false;
|
||||
const auto& mvsStreams = m_avmDtc->videoTeams();
|
||||
for (const auto& videoTeam : mvsStreams)
|
||||
{
|
||||
if (videoTeam.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
DEBUG_LOG(m_logger) << "add new videoteam" << videoTeam;
|
||||
StreamModelData item;
|
||||
item.name = QString::fromStdString(videoTeam.streamName().c_str());
|
||||
item.mountingPointId = -1 * videoTeam.id();
|
||||
item.isGroup = false;
|
||||
|
||||
|
||||
toAddMvs.push_back(item);
|
||||
|
||||
toAddMvs.push_back(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
std::sort(toAddOutdoor.begin(), toAddOutdoor.end(), sortStuff);
|
||||
for (const auto& item : toAddOutdoor)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
|
||||
|
||||
std::sort(toAddIndoor.begin(), toAddIndoor.end(), sortStuff);
|
||||
for (const auto& item : toAddIndoor)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
|
||||
|
||||
std::sort(toAddOutdoor.begin(), toAddOutdoor.end(), sortStuff);
|
||||
for (const auto &item : toAddOutdoor)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
|
||||
std::sort(toAddIndoor.begin(), toAddIndoor.end(), sortStuff);
|
||||
for (const auto &item : toAddIndoor)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
|
||||
std::sort(toAddMvs.begin(), toAddMvs.end(), sortStuff);
|
||||
for (const auto &item : toAddMvs)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
endResetModel();
|
||||
std::sort(toAddMvs.begin(), toAddMvs.end(), sortStuff);
|
||||
for (const auto& item : toAddMvs)
|
||||
{
|
||||
data.setValue(item);
|
||||
m_rootItem->appendChild(new NGLTreeItem(data, QIcon()));
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
StreamModelData StreamModelData::createFromServiceItem(const AvMenuEntry &entry, StreamNameMapping *streamNameMapping, const QMap<int, VideoTeam> &videoTeamList)
|
||||
StreamModelData StreamModelData::createFromServiceItem(const AvMenuEntry& entry, StreamNameMapping* streamNameMapping,
|
||||
const QMap<int, VideoTeam>& videoTeamList)
|
||||
{
|
||||
StreamModelData data;
|
||||
data.id = entry.id();
|
||||
data.parentId = entry.parentId();
|
||||
data.isGroup = entry.isGroup();
|
||||
if (entry.isGroup())
|
||||
data.name = QString::fromStdString(entry.name().get());
|
||||
else
|
||||
{
|
||||
if (entry.mountingPointId().is_set() && (entry.mountingPointId().get() > 0))
|
||||
{
|
||||
data.mountingPointId = entry.mountingPointId().get();
|
||||
data.name = streamNameMapping->displayName(entry.mountingPointId().get());
|
||||
}
|
||||
StreamModelData data;
|
||||
data.id = entry.id();
|
||||
data.parentId = entry.parentId();
|
||||
data.isGroup = entry.isGroup();
|
||||
if (entry.isGroup())
|
||||
data.name = QString::fromStdString(entry.name().get());
|
||||
else
|
||||
{
|
||||
data.mountingPointId = entry.mountingPointId().get();
|
||||
data.name = QString::fromStdString(videoTeamList.value(entry.mountingPointId().get() * -1).streamName());
|
||||
if (entry.mountingPointId().is_set() && (entry.mountingPointId().get() > 0))
|
||||
{
|
||||
data.mountingPointId = entry.mountingPointId().get();
|
||||
data.name = streamNameMapping->displayName(entry.mountingPointId().get());
|
||||
}
|
||||
else
|
||||
{
|
||||
data.mountingPointId = entry.mountingPointId().get();
|
||||
data.name = QString::fromStdString(videoTeamList.value(entry.mountingPointId().get() * -1).streamName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+46
-63
@@ -2,103 +2,86 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm.hpp>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <QDataStream>
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
|
||||
class NGLTreeItem;
|
||||
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class StreamNameMapping;
|
||||
|
||||
|
||||
|
||||
struct StreamModelData
|
||||
{
|
||||
qint64 id = 0;
|
||||
qint64 parentId = 0;
|
||||
bool isGroup = false;
|
||||
QString name;
|
||||
qint32 mountingPointId = 0;
|
||||
qint64 id = 0;
|
||||
qint64 parentId = 0;
|
||||
bool isGroup = false;
|
||||
QString name;
|
||||
qint32 mountingPointId = 0;
|
||||
|
||||
static StreamModelData createFromServiceItem(const AvMenuEntry &entry, StreamNameMapping *streamNameMapping, const QMap<int, VideoTeam> &videoTeamList);
|
||||
static StreamModelData createFromServiceItem(const AvMenuEntry& entry, StreamNameMapping* streamNameMapping,
|
||||
const QMap<int, VideoTeam>& videoTeamList);
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out,
|
||||
const StreamModelData &myObj)
|
||||
{
|
||||
out << myObj.id
|
||||
<< myObj.parentId
|
||||
<< myObj.isGroup
|
||||
<< myObj.name
|
||||
<< myObj.mountingPointId;
|
||||
return out;
|
||||
}
|
||||
friend QDataStream& operator<<(QDataStream& out, const StreamModelData& myObj)
|
||||
{
|
||||
out << myObj.id << myObj.parentId << myObj.isGroup << myObj.name << myObj.mountingPointId;
|
||||
return out;
|
||||
}
|
||||
|
||||
friend QDataStream &operator>>(QDataStream &in,
|
||||
StreamModelData &myObj)
|
||||
{
|
||||
in >> myObj.id
|
||||
>> myObj.parentId
|
||||
>> myObj.isGroup
|
||||
>> myObj.name
|
||||
>> myObj.mountingPointId;
|
||||
friend QDataStream& operator>>(QDataStream& in, StreamModelData& myObj)
|
||||
{
|
||||
in >> myObj.id >> myObj.parentId >> myObj.isGroup >> myObj.name >> myObj.mountingPointId;
|
||||
|
||||
return in;
|
||||
}
|
||||
return in;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class AvailableStreamsModel : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const QString s_MimeType;
|
||||
Q_OBJECT
|
||||
public:
|
||||
static const QString s_MimeType;
|
||||
|
||||
AvailableStreamsModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
LtsSession::LtsSession *session,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
QObject *parent,
|
||||
bool isAudio);
|
||||
AvailableStreamsModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
LtsSession::LtsSession* session, StreamNameMapping* streamNameMapping, QObject* parent,
|
||||
bool isAudio);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) override;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QMimeData* mimeData(const QModelIndexList& indexes) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) override;
|
||||
|
||||
Qt::DropActions supportedDragActions() const override { return Qt::CopyAction; }
|
||||
Qt::DropActions supportedDragActions() const override
|
||||
{
|
||||
return Qt::CopyAction;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void initModel();
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void initModel();
|
||||
|
||||
const bool m_isAudio;
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
LtsSession::LtsSession *m_session;
|
||||
StreamNameMapping *m_streamNameMapping;
|
||||
const bool m_isAudio;
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
LtsSession::LtsSession* m_session;
|
||||
StreamNameMapping* m_streamNameMapping;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::StreamModelData)
|
||||
|
||||
Executable → Regular
+64
-77
@@ -1,121 +1,108 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_choose_menu.h"
|
||||
#include "ui_avm_choose_menu.h"
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/avm.hpp>
|
||||
#include <AudioVideoManagement/avs_menus.h>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include "ui_avm_choose_menu.h"
|
||||
|
||||
#include <AudioVideoManagement/avm.hpp>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/avs_menus.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
ChooseMenu::ChooseMenu(Interface::Dtc *dtc, AvsMenus *avsMenus, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_dtc(dtc)
|
||||
, m_avsMenus(avsMenus)
|
||||
, m_ui(new Ui::ChooseMenuStruct)
|
||||
ChooseMenu::ChooseMenu(Interface::Dtc* dtc, AvsMenus* avsMenus, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_dtc(dtc), m_avsMenus(avsMenus),
|
||||
m_ui(new Ui::ChooseMenuStruct)
|
||||
{
|
||||
Q_ASSERT(dtc);
|
||||
Q_ASSERT(avsMenus);
|
||||
Q_ASSERT(dtc);
|
||||
Q_ASSERT(avsMenus);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(dtc, &Interface::Dtc::menuStructChanged, this, &ChooseMenu::onMenuStructChanged);
|
||||
m_dtc->menuStructs([this](const MenuStruct & menu) { onMenuStructChanged(menu, DataModification::eAdded);});
|
||||
selectCurrent();
|
||||
connect(dtc, &Interface::Dtc::menuStructChanged, this, &ChooseMenu::onMenuStructChanged);
|
||||
m_dtc->menuStructs([this](const MenuStruct& menu) { onMenuStructChanged(menu, DataModification::eAdded); });
|
||||
selectCurrent();
|
||||
|
||||
connect(m_ui->cbAudio, &QComboBox::currentTextChanged, this, &ChooseMenu::slotChangesMade);
|
||||
connect(m_ui->cbVideo, &QComboBox::currentTextChanged, this, &ChooseMenu::slotChangesMade);
|
||||
connect(m_ui->cbAudio, &QComboBox::currentTextChanged, this, &ChooseMenu::slotChangesMade);
|
||||
connect(m_ui->cbVideo, &QComboBox::currentTextChanged, this, &ChooseMenu::slotChangesMade);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Choose_AV_Menu"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Choose_AV_Menu"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
ChooseMenu::~ChooseMenu()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ChooseMenu::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Choose AV Menu"));
|
||||
translate(m_ui, tr("Choose AV Menu"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ChooseMenu::onMenuStructChanged(const MenuStruct &data, DataModification modType)
|
||||
void ChooseMenu::onMenuStructChanged(const MenuStruct& data, DataModification modType)
|
||||
{
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
{
|
||||
if (data.isAudio())
|
||||
m_ui->cbAudio->addItem(QString::fromStdString(data.name()), data.id());
|
||||
else
|
||||
m_ui->cbVideo->addItem(QString::fromStdString(data.name()), data.id());
|
||||
break;
|
||||
}
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded: {
|
||||
if (data.isAudio())
|
||||
m_ui->cbAudio->addItem(QString::fromStdString(data.name()), data.id());
|
||||
else
|
||||
m_ui->cbVideo->addItem(QString::fromStdString(data.name()), data.id());
|
||||
break;
|
||||
}
|
||||
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
if (data.isAudio())
|
||||
{
|
||||
int index = m_ui->cbAudio->findData(data.id());
|
||||
m_ui->cbAudio->removeItem(index);
|
||||
case DataModification::eRemoved: {
|
||||
if (data.isAudio())
|
||||
{
|
||||
int index = m_ui->cbAudio->findData(data.id());
|
||||
m_ui->cbAudio->removeItem(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = m_ui->cbVideo->findData(data.id());
|
||||
m_ui->cbVideo->removeItem(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DataModification::eModified:
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
int index = m_ui->cbVideo->findData(data.id());
|
||||
m_ui->cbVideo->removeItem(index);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DataModification::eModified:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ChooseMenu::apply()
|
||||
{
|
||||
int menuId = m_ui->cbAudio->currentData().toInt();
|
||||
INFO_LOG(m_logger) << "MenuId Audio: " << menuId;
|
||||
m_avsMenus->setAnnouncementMenu(menuId);
|
||||
int menuId = m_ui->cbAudio->currentData().toInt();
|
||||
INFO_LOG(m_logger) << "MenuId Audio: " << menuId;
|
||||
m_avsMenus->setAnnouncementMenu(menuId);
|
||||
|
||||
menuId = m_ui->cbVideo->currentData().toInt();
|
||||
INFO_LOG(m_logger) << "MenuId Video: " << menuId;
|
||||
m_avsMenus->setVideoMenu(menuId);
|
||||
|
||||
return true;
|
||||
menuId = m_ui->cbVideo->currentData().toInt();
|
||||
INFO_LOG(m_logger) << "MenuId Video: " << menuId;
|
||||
m_avsMenus->setVideoMenu(menuId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChooseMenu::selectCurrent()
|
||||
{
|
||||
selectMenu(m_avsMenus->currentAnnouncementMenu(), m_ui->cbAudio);
|
||||
selectMenu(m_avsMenus->currentVideoMenu(), m_ui->cbVideo);
|
||||
selectMenu(m_avsMenus->currentAnnouncementMenu(), m_ui->cbAudio);
|
||||
selectMenu(m_avsMenus->currentVideoMenu(), m_ui->cbVideo);
|
||||
}
|
||||
|
||||
void ChooseMenu::selectMenu(int menuId, QComboBox *cb)
|
||||
void ChooseMenu::selectMenu(int menuId, QComboBox* cb)
|
||||
{
|
||||
Q_ASSERT(cb);
|
||||
Q_ASSERT(cb);
|
||||
|
||||
if (menuId < 0)
|
||||
return;
|
||||
if (menuId < 0)
|
||||
return;
|
||||
|
||||
int index = cb->findData(menuId);
|
||||
if (index < 0)
|
||||
return;
|
||||
int index = cb->findData(menuId);
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
cb->setCurrentIndex(index);
|
||||
cb->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+17
-20
@@ -1,11 +1,9 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
enum class DataModification;
|
||||
|
||||
@@ -32,26 +30,25 @@ class AvsMenus;
|
||||
|
||||
class ChooseMenu : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChooseMenu(Interface::Dtc *dtc, AvsMenus *avsMenus, QWidget *parent = nullptr);
|
||||
~ChooseMenu() override;
|
||||
public:
|
||||
ChooseMenu(Interface::Dtc* dtc, AvsMenus* avsMenus, QWidget* parent = nullptr);
|
||||
~ChooseMenu() override;
|
||||
|
||||
private slots:
|
||||
void onMenuStructChanged(const MenuStruct &data, DataModification modType);
|
||||
private slots:
|
||||
void onMenuStructChanged(const MenuStruct& data, DataModification modType);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
void selectCurrent();
|
||||
void selectMenu(int menuId, QComboBox* cb);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
void selectCurrent();
|
||||
void selectMenu(int menuId, QComboBox *cb);
|
||||
|
||||
Interface::Dtc *m_dtc;
|
||||
AvsMenus *m_avsMenus;
|
||||
Ui::ChooseMenuStruct *m_ui;
|
||||
Interface::Dtc* m_dtc;
|
||||
AvsMenus* m_avsMenus;
|
||||
Ui::ChooseMenuStruct* m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+77
-101
@@ -1,152 +1,128 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_menu_edit.h"
|
||||
|
||||
#include "ui_avm_menu_edit.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
MenuEdit::MenuEdit(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ftc(nullptr)
|
||||
, m_ui(new Ui::MenuEdit)
|
||||
, m_availStreamsModel(nullptr)
|
||||
, m_usedStreamsModel(nullptr)
|
||||
, m_isAudio(false)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
MenuEdit::MenuEdit(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ftc(nullptr),
|
||||
m_ui(new Ui::MenuEdit), m_availStreamsModel(nullptr), m_usedStreamsModel(nullptr), m_isAudio(false),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
}
|
||||
|
||||
m_ui->setupUi(this);
|
||||
}
|
||||
|
||||
MenuEdit::~MenuEdit()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void MenuEdit::retranslate()
|
||||
{
|
||||
if (m_isAudio)
|
||||
translate(m_ui, tr("Edit Audio Menu: %1").arg(m_name));
|
||||
else
|
||||
translate(m_ui, tr("Edit Video Menu: %1").arg(m_name));
|
||||
}
|
||||
if (m_isAudio)
|
||||
translate(m_ui, tr("Edit Audio Menu: %1").arg(m_name));
|
||||
else
|
||||
translate(m_ui, tr("Edit Video Menu: %1").arg(m_name));
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool MenuEdit::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
const MenuStruct &ms)
|
||||
bool MenuEdit::init(LtsSession::LtsSession* session, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
StreamNameMapping* streamNameMapping, const MenuStruct& ms)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "MenuEdit::init()";
|
||||
DEBUG_LOG(m_logger) << "MenuEdit::init()";
|
||||
|
||||
if (!ftc || !dtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "MenuEdit::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
if (!ftc || !dtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "MenuEdit::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ftc = ftc;
|
||||
m_isAudio = ms.isAudio();
|
||||
m_name = QString::fromStdString(ms.name());
|
||||
m_ftc = ftc;
|
||||
m_isAudio = ms.isAudio();
|
||||
m_name = QString::fromStdString(ms.name());
|
||||
|
||||
m_availStreamsModel = new AvailableStreamsModel(dtc, ismDtc, session, streamNameMapping, this, m_isAudio);
|
||||
m_ui->availTreeView->setModel(m_availStreamsModel);
|
||||
m_availStreamsModel = new AvailableStreamsModel(dtc, ismDtc, session, streamNameMapping, this, m_isAudio);
|
||||
m_ui->availTreeView->setModel(m_availStreamsModel);
|
||||
|
||||
m_usedStreamsModel = new UsedStreamsModel(dtc, ismDtc, ms, streamNameMapping, this);
|
||||
m_ui->menuTreeView->setModel(m_usedStreamsModel);
|
||||
m_ui->menuTreeView->expandAll();
|
||||
m_usedStreamsModel = new UsedStreamsModel(dtc, ismDtc, ms, streamNameMapping, this);
|
||||
m_ui->menuTreeView->setModel(m_usedStreamsModel);
|
||||
m_ui->menuTreeView->expandAll();
|
||||
|
||||
connect(m_ui->menuTreeView, &QTreeView::clicked,
|
||||
this, &MenuEdit::onStreamSelected);
|
||||
connect(m_usedStreamsModel, &UsedStreamsModel::modelDataChanged,
|
||||
this, &MenuEdit::slotChangesMade);
|
||||
connect(m_ui->menuTreeView, &QTreeView::clicked, this, &MenuEdit::onStreamSelected);
|
||||
connect(m_usedStreamsModel, &UsedStreamsModel::modelDataChanged, this, &MenuEdit::slotChangesMade);
|
||||
|
||||
connect(m_usedStreamsModel, &UsedStreamsModel::modelDataChanged,
|
||||
this, &MenuEdit::onModelDataChanged);
|
||||
connect(m_usedStreamsModel, &UsedStreamsModel::modelDataChanged, this, &MenuEdit::onModelDataChanged);
|
||||
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove);
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Remove), &QPushButton::clicked,
|
||||
this, &MenuEdit::onRemove);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Remove);
|
||||
connect(m_buttonBox->getButton(LtsWidgets::DialogButton::Remove), &QPushButton::clicked, this, &MenuEdit::onRemove);
|
||||
|
||||
onStreamSelected(QModelIndex());
|
||||
onStreamSelected(QModelIndex());
|
||||
|
||||
|
||||
if (m_isAudio)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Audio_Menu"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Video_Menu"));
|
||||
if (m_isAudio)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Audio_Menu"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Video_Menu"));
|
||||
|
||||
if (ms.id() <= 0)
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Apply, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
if (ms.id() <= 0)
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Apply, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MenuEdit::apply()
|
||||
{
|
||||
MenuStruct ms = m_usedStreamsModel->getMenuStruct();
|
||||
ms.isAudio(m_isAudio);
|
||||
MenuStruct ms = m_usedStreamsModel->getMenuStruct();
|
||||
ms.isAudio(m_isAudio);
|
||||
|
||||
bool ret = m_requestHelper->startSingleRequest([this, ms]()
|
||||
{
|
||||
|
||||
return m_ftc->modifyMenuStructRequest(ms, this);
|
||||
});
|
||||
|
||||
return ret;
|
||||
}
|
||||
bool ret = m_requestHelper->startSingleRequest([this, ms]() { return m_ftc->modifyMenuStructRequest(ms, this); });
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void MenuEdit::onRemove()
|
||||
{
|
||||
|
||||
|
||||
if (0 == m_ui->menuTreeView->selectionModel()->selectedIndexes().size())
|
||||
{
|
||||
|
||||
QModelIndex index = m_ui->menuTreeView->currentIndex();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
slotChangesMade();
|
||||
|
||||
DEBUG_LOG(m_logger) << "index row: " << index.row();
|
||||
m_usedStreamsModel->removeRow(index.row(), index.parent());
|
||||
}
|
||||
else
|
||||
{
|
||||
while (m_ui->menuTreeView->selectionModel()->selectedIndexes().size() > 0)
|
||||
if (0 == m_ui->menuTreeView->selectionModel()->selectedIndexes().size())
|
||||
{
|
||||
QModelIndex index = m_ui->menuTreeView->selectionModel()->selectedIndexes().front();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
slotChangesMade();
|
||||
|
||||
DEBUG_LOG(m_logger) << "index row: " << index.row();
|
||||
m_usedStreamsModel->removeRow(index.row(), index.parent());
|
||||
QModelIndex index = m_ui->menuTreeView->currentIndex();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
slotChangesMade();
|
||||
|
||||
DEBUG_LOG(m_logger) << "index row: " << index.row();
|
||||
m_usedStreamsModel->removeRow(index.row(), index.parent());
|
||||
}
|
||||
else
|
||||
{
|
||||
while (m_ui->menuTreeView->selectionModel()->selectedIndexes().size() > 0)
|
||||
{
|
||||
QModelIndex index = m_ui->menuTreeView->selectionModel()->selectedIndexes().front();
|
||||
if (!index.isValid())
|
||||
return;
|
||||
slotChangesMade();
|
||||
|
||||
DEBUG_LOG(m_logger) << "index row: " << index.row();
|
||||
m_usedStreamsModel->removeRow(index.row(), index.parent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MenuEdit::onModelDataChanged()
|
||||
{
|
||||
INFO_LOG(m_logger) << "onModelDataChanged";
|
||||
m_ui->menuTreeView->expandAll();
|
||||
INFO_LOG(m_logger) << "onModelDataChanged";
|
||||
m_ui->menuTreeView->expandAll();
|
||||
}
|
||||
|
||||
void MenuEdit::onStreamSelected(const QModelIndex &idx)
|
||||
void MenuEdit::onStreamSelected(const QModelIndex& idx)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, idx.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, idx.isValid());
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+35
-40
@@ -1,32 +1,28 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "avm_available_streams_model.h"
|
||||
#include "avm_used_streams_model.h"
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MenuEdit;
|
||||
}
|
||||
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
@@ -34,46 +30,45 @@ namespace AudioVideoManagement
|
||||
class StreamNameMapping;
|
||||
|
||||
class MenuEdit : public LtsWidgets::LtsDialog,
|
||||
protected AudioVideoManagement::Interface::Ftc::ModifyMenuStructReplyHandler
|
||||
protected AudioVideoManagement::Interface::Ftc::ModifyMenuStructReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MenuEdit(QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit MenuEdit(QWidget* parent = nullptr);
|
||||
|
||||
~MenuEdit();
|
||||
~MenuEdit();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
const MenuStruct &ms);
|
||||
bool init(LtsSession::LtsSession* session, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
StreamNameMapping* streamNameMapping, const MenuStruct& ms);
|
||||
|
||||
|
||||
void onModifyMenuStructReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
|
||||
void onModifyMenuStructReply(const Core::FunctionReplyObject& replyObject) override
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
public slots:
|
||||
void onRemove();
|
||||
void onModelDataChanged();
|
||||
void onStreamSelected(const QModelIndex &idx);
|
||||
public slots:
|
||||
void onRemove();
|
||||
void onModelDataChanged();
|
||||
void onStreamSelected(const QModelIndex& idx);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override final;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
Ui::MenuEdit* m_ui;
|
||||
AvailableStreamsModel* m_availStreamsModel;
|
||||
UsedStreamsModel* m_usedStreamsModel;
|
||||
bool m_isAudio;
|
||||
QString m_name;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
Ui::MenuEdit *m_ui;
|
||||
AvailableStreamsModel *m_availStreamsModel;
|
||||
UsedStreamsModel *m_usedStreamsModel;
|
||||
bool m_isAudio;
|
||||
QString m_name;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
AudioVideoManagement::MenuStruct m_lastDdsMenuStruct;
|
||||
AudioVideoManagement::MenuStruct m_modifiedMenuStruct;
|
||||
AudioVideoManagement::MenuStruct m_lastDdsMenuStruct;
|
||||
AudioVideoManagement::MenuStruct m_modifiedMenuStruct;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+126
-162
@@ -1,245 +1,209 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_menu_edit_view.h"
|
||||
#include "ui_avm_menu_edit_view.h"
|
||||
|
||||
#include "avm_menu_edit.h"
|
||||
#include "avm_new_menu_struct.h"
|
||||
#include "ui_avm_menu_edit_view.h"
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session_manager.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
MenuEditView::MenuEditView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_model(nullptr)
|
||||
, m_isAudio(false)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_session(session)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::MenuEditView)
|
||||
MenuEditView::MenuEditView(const QString& menuGroup, LtsSession::LtsSession* session, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_menuGroup(menuGroup), m_model(nullptr),
|
||||
m_isAudio(false), m_dtc(nullptr), m_ftc(nullptr), m_session(session),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_ui(new Ui::MenuEditView)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_ui->setupUi(this);
|
||||
m_ui->widget->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &MenuEditView::onSelectionChanged);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &MenuEditView::onSelectionChanged);
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &MenuEditView::onEditMenuStruct);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &MenuEditView::onEditMenuStruct);
|
||||
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MenuEditView::onEditMenuStruct);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &MenuEditView::onRemoveMenuStruct);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &MenuEditView::onAddMenuStruct);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &MenuEditView::onPrint);
|
||||
|
||||
}
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MenuEditView::onEditMenuStruct);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &MenuEditView::onRemoveMenuStruct);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &MenuEditView::onAddMenuStruct);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &MenuEditView::onPrint);
|
||||
}
|
||||
|
||||
MenuEditView::~MenuEditView()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void MenuEditView::retranslate()
|
||||
{
|
||||
if (m_isAudio)
|
||||
translate(m_ui, tr("Audio Menu"));
|
||||
else
|
||||
translate(m_ui, tr("Video Menu"));
|
||||
}
|
||||
if (m_isAudio)
|
||||
translate(m_ui, tr("Audio Menu"));
|
||||
else
|
||||
translate(m_ui, tr("Video Menu"));
|
||||
}
|
||||
|
||||
|
||||
bool MenuEditView::init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
bool isAudio)
|
||||
bool MenuEditView::init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
StreamNameMapping* streamNameMapping, bool isAudio)
|
||||
{
|
||||
Q_ASSERT(dtc);
|
||||
Q_ASSERT(ftc);
|
||||
Q_ASSERT(ismDtc);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
Q_ASSERT(dtc);
|
||||
Q_ASSERT(ftc);
|
||||
Q_ASSERT(ismDtc);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_ismDtc = ismDtc;
|
||||
m_streamNameMapping = streamNameMapping;
|
||||
m_model = new MenuViewModel(this);
|
||||
m_model->initModel(m_dtc, isAudio);
|
||||
m_ui->widget->setModel(m_model);
|
||||
m_isAudio = isAudio;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_ismDtc = ismDtc;
|
||||
m_streamNameMapping = streamNameMapping;
|
||||
m_model = new MenuViewModel(this);
|
||||
m_model->initModel(m_dtc, isAudio);
|
||||
m_ui->widget->setModel(m_model);
|
||||
m_isAudio = isAudio;
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(0);
|
||||
m_ui->widget->hideColumn(0);
|
||||
#endif
|
||||
|
||||
m_ui->widget->setSortIndicator(1, Qt::AscendingOrder);
|
||||
m_ui->widget->setSortIndicator(1, Qt::AscendingOrder);
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&MenuEditView::onImportButtonClicked,
|
||||
&MenuEditView::onExportButtonClicked);
|
||||
m_buttonBox->connectLibraryButton(this, &MenuEditView::onImportButtonClicked, &MenuEditView::onExportButtonClicked);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
if (m_isAudio)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Audio_Menu"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Video_Menu"));
|
||||
|
||||
return true;
|
||||
}
|
||||
if (m_isAudio)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Audio_Menu"));
|
||||
else
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Video_Menu"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MenuEditView::onSelectionChanged()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
int row = idx.row();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, (row >= 0));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (row >= 0));
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
int row = idx.row();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, (row >= 0));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (row >= 0));
|
||||
}
|
||||
|
||||
void MenuEditView::onAddMenuStruct()
|
||||
{
|
||||
NewMenuStruct *newDialog = new NewMenuStruct(this);
|
||||
NewMenuStruct* newDialog = new NewMenuStruct(this);
|
||||
|
||||
connect(newDialog, &NewMenuStruct::newName, this, [this](const QString & name)
|
||||
{
|
||||
MenuStruct ms;
|
||||
ms.name(name.toStdString());
|
||||
ms.isAudio(m_isAudio);
|
||||
MenuEdit *dialog = new MenuEdit(this);
|
||||
dialog->init(m_session, m_dtc, m_ftc, m_ismDtc, m_streamNameMapping, ms);
|
||||
connect(newDialog, &NewMenuStruct::newName, this, [this](const QString& name) {
|
||||
MenuStruct ms;
|
||||
ms.name(name.toStdString());
|
||||
ms.isAudio(m_isAudio);
|
||||
MenuEdit* dialog = new MenuEdit(this);
|
||||
dialog->init(m_session, m_dtc, m_ftc, m_ismDtc, m_streamNameMapping, ms);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("avmNewMenu") + name, LtsWidgets::LayoutArea::eDialogTab);
|
||||
});
|
||||
newDialog->show();
|
||||
|
||||
connect(newDialog, &NewMenuStruct::accepted, newDialog, &NewMenuStruct::deleteLater);
|
||||
|
||||
}
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("avmNewMenu") + name, LtsWidgets::LayoutArea::eDialogTab);
|
||||
});
|
||||
newDialog->show();
|
||||
|
||||
connect(newDialog, &NewMenuStruct::accepted, newDialog, &NewMenuStruct::deleteLater);
|
||||
}
|
||||
|
||||
void MenuEditView::onEditMenuStruct()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
AudioVideoManagement::MenuStruct ms = m_model->getRowData(row);
|
||||
ms.isAudio(m_isAudio);
|
||||
AudioVideoManagement::MenuStruct ms = m_model->getRowData(row);
|
||||
ms.isAudio(m_isAudio);
|
||||
|
||||
DEBUG_LOG(m_logger) << "---onEditMenuStruct () "
|
||||
<< " id: " << ms.id()
|
||||
<< " name: " << ms.name();
|
||||
DEBUG_LOG(m_logger) << "---onEditMenuStruct () "
|
||||
<< " id: " << ms.id() << " name: " << ms.name();
|
||||
|
||||
MenuEdit *dialog = new MenuEdit(this);
|
||||
dialog->init(m_session, m_dtc, m_ftc, m_ismDtc, m_streamNameMapping, ms);
|
||||
MenuEdit* dialog = new MenuEdit(this);
|
||||
dialog->init(m_session, m_dtc, m_ftc, m_ismDtc, m_streamNameMapping, ms);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("avmMenuEdit") + QString::number(ms.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("avmMenuEdit") + QString::number(ms.id()),
|
||||
LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
|
||||
void MenuEditView::onRemoveMenuStruct()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
const AudioVideoManagement::MenuStruct ms = m_model->getRowData(idx.row());
|
||||
const Core::RemoveElementRequest req(ms.id());
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->removeMenuStructRequest(req, this);
|
||||
});
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
const AudioVideoManagement::MenuStruct ms = m_model->getRowData(idx.row());
|
||||
const Core::RemoveElementRequest req(ms.id());
|
||||
m_requestHelper->startSingleRequest([req, this]() { return m_ftc->removeMenuStructRequest(req, this); });
|
||||
|
||||
if (m_model->rowCount() == 0)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
}
|
||||
if (m_model->rowCount() == 0)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuEditView::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
void MenuEditView::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MenuEditView::onExportButtonClicked()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
QByteArray byteArray = m_model->modelToJson(row);
|
||||
|
||||
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 ";
|
||||
QByteArray byteArray = m_model->modelToJson(row);
|
||||
|
||||
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 MenuEditView::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " 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::AVMMenuEditView));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMMenuEditView)))
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMMenuEditView));
|
||||
if (fileId > 0)
|
||||
{
|
||||
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<AudioVideoManagement::MenuStruct> menuStructs = m_model->jsonToMenuStructs(content);
|
||||
for (const AudioVideoManagement::MenuStruct &request : menuStructs)
|
||||
{
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMMenuEditView)))
|
||||
{
|
||||
return m_ftc->modifyMenuStructRequest(request, this);
|
||||
});
|
||||
}
|
||||
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<AudioVideoManagement::MenuStruct> menuStructs = m_model->jsonToMenuStructs(content);
|
||||
for (const AudioVideoManagement::MenuStruct& request : menuStructs)
|
||||
{
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_ftc->modifyMenuStructRequest(request, this); });
|
||||
}
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+47
-45
@@ -1,31 +1,28 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "avm_menu_view_model.h"
|
||||
|
||||
#include <Services/AudioVideoManagement/avm_dtc.h>
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <Services/AudioVideoManagement/avm_dtc.h>
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MenuEditView;
|
||||
}
|
||||
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
@@ -33,51 +30,56 @@ namespace AudioVideoManagement
|
||||
class StreamNameMapping;
|
||||
|
||||
class MenuEditView : public LtsWidgets::LtsDialog,
|
||||
protected AudioVideoManagement::Interface::Ftc::ModifyMenuStructReplyHandler,
|
||||
protected AudioVideoManagement::Interface::Ftc::RemoveMenuStructReplyHandler
|
||||
protected AudioVideoManagement::Interface::Ftc::ModifyMenuStructReplyHandler,
|
||||
protected AudioVideoManagement::Interface::Ftc::RemoveMenuStructReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MenuEditView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~MenuEditView();
|
||||
bool init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
bool isAudio);
|
||||
public:
|
||||
explicit MenuEditView(const QString& menuGroup, LtsSession::LtsSession* session, QWidget* parent = nullptr);
|
||||
~MenuEditView();
|
||||
bool init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
StreamNameMapping* streamNameMapping, bool isAudio);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onAddMenuStruct();
|
||||
void onEditMenuStruct();
|
||||
void onRemoveMenuStruct();
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onAddMenuStruct();
|
||||
void onEditMenuStruct();
|
||||
void onRemoveMenuStruct();
|
||||
void onModifyMenuStructReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void onModifyMenuStructReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onRemoveMenuStructReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
void onRemoveMenuStructReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void onPrint();
|
||||
void tableColumnOrganiserSetting() override;
|
||||
void onPrint();
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private slots:
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
private slots:
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
private:
|
||||
QString m_menuGroup;
|
||||
MenuViewModel *m_model;
|
||||
bool m_isAudio;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
StreamNameMapping *m_streamNameMapping{nullptr};
|
||||
LtsSession::LtsSession *m_session;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
Ui::MenuEditView *m_ui;
|
||||
private:
|
||||
QString m_menuGroup;
|
||||
MenuViewModel* m_model;
|
||||
bool m_isAudio;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
StreamNameMapping* m_streamNameMapping{nullptr};
|
||||
LtsSession::LtsSession* m_session;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
Ui::MenuEditView* m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+99
-113
@@ -1,150 +1,136 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_menu_view_model.h"
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
MenuViewModel::MenuViewModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::MenuStruct>({tr("Id"),
|
||||
tr("Name")},
|
||||
parent)
|
||||
, m_isAudio(false)
|
||||
, m_dtc(nullptr)
|
||||
{}
|
||||
|
||||
|
||||
bool MenuViewModel::initModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc, bool isAudio)
|
||||
MenuViewModel::MenuViewModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::MenuStruct>({tr("Id"), tr("Name")}, parent),
|
||||
m_isAudio(false), m_dtc(nullptr)
|
||||
{
|
||||
m_isAudio = isAudio;
|
||||
m_dtc = dtc;
|
||||
|
||||
connect(m_dtc.get(), &AudioVideoManagement::Interface::Dtc::menuStructChanged,
|
||||
this, &MenuViewModel::onDataChanged);
|
||||
|
||||
|
||||
m_dtc->menuStructs([this](const AudioVideoManagement::MenuStruct &ms) { insertRow(ms); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant MenuViewModel::data(const QModelIndex &index, int role) const
|
||||
bool MenuViewModel::initModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc, bool isAudio)
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
m_isAudio = isAudio;
|
||||
m_dtc = dtc;
|
||||
|
||||
connect(m_dtc.get(), &AudioVideoManagement::Interface::Dtc::menuStructChanged, this, &MenuViewModel::onDataChanged);
|
||||
|
||||
m_dtc->menuStructs([this](const AudioVideoManagement::MenuStruct& ms) { insertRow(ms); });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant MenuViewModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const AudioVideoManagement::MenuStruct& ms = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return ms.id();
|
||||
case 1:
|
||||
return QString::fromStdString(ms.name());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
||||
const AudioVideoManagement::MenuStruct &ms = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case 0:
|
||||
return ms.id();
|
||||
case 1:
|
||||
return QString::fromStdString(ms.name());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool MenuViewModel::isFiltered(const MenuStruct &data, DataModification modType) const
|
||||
bool MenuViewModel::isFiltered(const MenuStruct& data, DataModification modType) const
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (data.isAudio() != m_isAudio)
|
||||
return true;
|
||||
if (data.isDefault())
|
||||
return true;
|
||||
return false;
|
||||
Q_UNUSED(modType);
|
||||
if (data.isAudio() != m_isAudio)
|
||||
return true;
|
||||
if (data.isDefault())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray MenuViewModel::modelToJson(int row) const
|
||||
{
|
||||
if (row < 0 || row >= m_vecData.size())
|
||||
return QByteArray("{}");
|
||||
if (row < 0 || row >= m_vecData.size())
|
||||
return QByteArray("{}");
|
||||
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMMenuEditView);
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMMenuEditView);
|
||||
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
const AudioVideoManagement::MenuStruct &menuStruct = m_vecData.at(row);
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
const AudioVideoManagement::MenuStruct& menuStruct = m_vecData.at(row);
|
||||
|
||||
obj[QStringLiteral("id")] = 0;
|
||||
obj[QStringLiteral("isAudio")] = menuStruct.isAudio();
|
||||
obj[QStringLiteral("isDefault")] = menuStruct.isDefault();
|
||||
obj[QStringLiteral("name")] = QString::fromStdString(menuStruct.name());
|
||||
obj[QStringLiteral("id")] = 0;
|
||||
obj[QStringLiteral("isAudio")] = menuStruct.isAudio();
|
||||
obj[QStringLiteral("isDefault")] = menuStruct.isDefault();
|
||||
obj[QStringLiteral("name")] = QString::fromStdString(menuStruct.name());
|
||||
|
||||
|
||||
QJsonArray arrData;
|
||||
for (const AudioVideoManagement::AvMenuEntry &avMenuEntry : menuStruct.menuEntries())
|
||||
{
|
||||
QJsonObject innerData;
|
||||
innerData[QStringLiteral("id")] = avMenuEntry.id();
|
||||
innerData[QStringLiteral("isGroup")] = avMenuEntry.isGroup();
|
||||
if (avMenuEntry.mountingPointId().is_set())
|
||||
innerData[QStringLiteral("mountingPointId")] = avMenuEntry.mountingPointId().get();
|
||||
if (avMenuEntry.name().is_set())
|
||||
innerData[QStringLiteral("name")] = QString::fromStdString(avMenuEntry.name().get());
|
||||
innerData[QStringLiteral("parentId")] = avMenuEntry.parentId();
|
||||
innerData[QStringLiteral("rowId")] = avMenuEntry.rowId();
|
||||
QJsonArray arrData;
|
||||
for (const AudioVideoManagement::AvMenuEntry& avMenuEntry : menuStruct.menuEntries())
|
||||
{
|
||||
QJsonObject innerData;
|
||||
innerData[QStringLiteral("id")] = avMenuEntry.id();
|
||||
innerData[QStringLiteral("isGroup")] = avMenuEntry.isGroup();
|
||||
if (avMenuEntry.mountingPointId().is_set())
|
||||
innerData[QStringLiteral("mountingPointId")] = avMenuEntry.mountingPointId().get();
|
||||
if (avMenuEntry.name().is_set())
|
||||
innerData[QStringLiteral("name")] = QString::fromStdString(avMenuEntry.name().get());
|
||||
innerData[QStringLiteral("parentId")] = avMenuEntry.parentId();
|
||||
innerData[QStringLiteral("rowId")] = avMenuEntry.rowId();
|
||||
|
||||
arrData += innerData;
|
||||
}
|
||||
obj[QStringLiteral("menuEntries")] = arrData;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
arrData += innerData;
|
||||
}
|
||||
obj[QStringLiteral("menuEntries")] = arrData;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
QVector<AudioVideoManagement::MenuStruct> MenuViewModel::jsonToMenuStructs(const QByteArray &content) const
|
||||
QVector<AudioVideoManagement::MenuStruct> MenuViewModel::jsonToMenuStructs(const QByteArray& content) const
|
||||
{
|
||||
|
||||
QVector<AudioVideoManagement::MenuStruct> result;
|
||||
AudioVideoManagement::MenuStruct menuStruct;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
menuStruct.id(0);
|
||||
menuStruct.isAudio(obj[QStringLiteral("isAudio")].toBool());
|
||||
menuStruct.isDefault(obj[QStringLiteral("isDefault")].toBool());
|
||||
menuStruct.name(obj[QStringLiteral("name")].toString().toStdString());
|
||||
|
||||
|
||||
QVector<AudioVideoManagement::MenuStruct> result;
|
||||
AudioVideoManagement::MenuStruct menuStruct;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
menuStruct.id(0);
|
||||
menuStruct.isAudio(obj[QStringLiteral("isAudio")].toBool());
|
||||
menuStruct.isDefault(obj[QStringLiteral("isDefault")].toBool());
|
||||
menuStruct.name(obj[QStringLiteral("name")].toString().toStdString());
|
||||
|
||||
const QJsonArray arrEntry(obj.value(QStringLiteral("menuEntries")).toArray());
|
||||
menuStruct.menuEntries().resize(arrEntry.size());
|
||||
INFO_LOG(m_logger) << "arrEntry.size()=" << arrEntry.size();
|
||||
for (int j = 0; j < arrEntry.size(); ++j)
|
||||
{
|
||||
const QJsonObject objEntry(arrEntry.at(j).toObject());
|
||||
AudioVideoManagement::AvMenuEntry avMenuEntry;
|
||||
const QJsonArray arrEntry(obj.value(QStringLiteral("menuEntries")).toArray());
|
||||
menuStruct.menuEntries().resize(arrEntry.size());
|
||||
INFO_LOG(m_logger) << "arrEntry.size()=" << arrEntry.size();
|
||||
for (int j = 0; j < arrEntry.size(); ++j)
|
||||
{
|
||||
const QJsonObject objEntry(arrEntry.at(j).toObject());
|
||||
AudioVideoManagement::AvMenuEntry avMenuEntry;
|
||||
|
||||
avMenuEntry.id(-10000000 + objEntry[QStringLiteral("id")].toInt());
|
||||
avMenuEntry.isGroup(objEntry[QStringLiteral("isGroup")].toBool());
|
||||
avMenuEntry.mountingPointId(objEntry[QStringLiteral("mountingPointId")].toInt());
|
||||
if (objEntry.contains(QStringLiteral("name")))
|
||||
avMenuEntry.name().set(objEntry[QStringLiteral("name")].toString().toStdString());
|
||||
if (objEntry[QStringLiteral("isGroup")].toBool())
|
||||
avMenuEntry.parentId(0);
|
||||
else
|
||||
avMenuEntry.parentId(-10000000 + objEntry[QStringLiteral("parentId")].toInt());
|
||||
avMenuEntry.rowId(objEntry[QStringLiteral("rowId")].toInt());
|
||||
avMenuEntry.id(-10000000 + objEntry[QStringLiteral("id")].toInt());
|
||||
avMenuEntry.isGroup(objEntry[QStringLiteral("isGroup")].toBool());
|
||||
avMenuEntry.mountingPointId(objEntry[QStringLiteral("mountingPointId")].toInt());
|
||||
if (objEntry.contains(QStringLiteral("name")))
|
||||
avMenuEntry.name().set(objEntry[QStringLiteral("name")].toString().toStdString());
|
||||
if (objEntry[QStringLiteral("isGroup")].toBool())
|
||||
avMenuEntry.parentId(0);
|
||||
else
|
||||
avMenuEntry.parentId(-10000000 + objEntry[QStringLiteral("parentId")].toInt());
|
||||
avMenuEntry.rowId(objEntry[QStringLiteral("rowId")].toInt());
|
||||
|
||||
menuStruct.menuEntries()[j] = avMenuEntry;
|
||||
}
|
||||
|
||||
result.append(menuStruct);
|
||||
menuStruct.menuEntries()[j] = avMenuEntry;
|
||||
}
|
||||
|
||||
return result;
|
||||
result.append(menuStruct);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
qt6-after/qt6-migrated-legatus/Lts/Plugins/AudioVideoManagement/Gui/AVMenuEdit/avm_menu_view_model.h
Executable → Regular
+15
-19
@@ -1,35 +1,31 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
class MenuViewModel final : public LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::MenuStruct>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MenuViewModel(QObject *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MenuViewModel(QObject* parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc, bool isAudio);
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
QByteArray modelToJson(int row) const;
|
||||
QVector<AudioVideoManagement::MenuStruct> jsonToMenuStructs(const QByteArray &content) const;
|
||||
protected:
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool isFiltered(const MenuStruct &data, DataModification modType) const override final;
|
||||
bool initModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc, bool isAudio);
|
||||
QVariant data(const QModelIndex&, int) const override final;
|
||||
QByteArray modelToJson(int row) const;
|
||||
QVector<AudioVideoManagement::MenuStruct> jsonToMenuStructs(const QByteArray& content) const;
|
||||
|
||||
private:
|
||||
bool m_isAudio;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool isFiltered(const MenuStruct& data, DataModification modType) const override final;
|
||||
|
||||
private:
|
||||
bool m_isAudio;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
qt6-after/qt6-migrated-legatus/Lts/Plugins/AudioVideoManagement/Gui/AVMenuEdit/avm_new_menu_struct.h
Executable → Regular
+13
-15
@@ -1,37 +1,35 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class NewMenuStruct;
|
||||
}
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class NewMenuStruct : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NewMenuStruct(QWidget *parent = nullptr);
|
||||
~NewMenuStruct();
|
||||
public:
|
||||
explicit NewMenuStruct(QWidget* parent = nullptr);
|
||||
~NewMenuStruct();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onSetNewName();
|
||||
private Q_SLOTS:
|
||||
void onSetNewName();
|
||||
|
||||
Q_SIGNALS:
|
||||
void newName(const QString &);
|
||||
Q_SIGNALS:
|
||||
void newName(const QString&);
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
Ui::NewMenuStruct *m_ui;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
Ui::NewMenuStruct* m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
qt6-after/qt6-migrated-legatus/Lts/Plugins/AudioVideoManagement/Gui/AVMenuEdit/avm_playback_menu.cpp
Executable → Regular
+1039
-1179
File diff suppressed because it is too large.
Load diff
Executable → Regular
+143
-149
@@ -1,33 +1,31 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui_avm_playback_menu.h"
|
||||
#include "interval_model.h"
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include "ui_avm_playback_menu.h"
|
||||
|
||||
#include <AudioVideoManagement/Shared/playback_app.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <MarkerManagement/mrk_ftc.h>
|
||||
#include <QString>
|
||||
#include <boost/optional.hpp>
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace MarkerManagement
|
||||
{
|
||||
class MarkerManagementDialogModel;
|
||||
class MarkerSortFilterProxyModel;
|
||||
class ForeignDataInterface;
|
||||
}
|
||||
} // namespace MarkerManagement
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
@@ -37,180 +35,176 @@ class AvsSequence;
|
||||
class StreamNameMapping;
|
||||
class AvmPlaybackMenu;
|
||||
|
||||
|
||||
class QueryTimeline : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
friend class AvmPlaybackMenu;
|
||||
Q_OBJECT
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
friend class AvmPlaybackMenu;
|
||||
|
||||
QueryTimeline(const AvaStream &stream, const AvaTimePoint &start, const AvaTimePoint &end, AvaControl *control);
|
||||
QueryTimeline(const AvaStream& stream, const AvaTimePoint& start, const AvaTimePoint& end, AvaControl* control);
|
||||
|
||||
AvaControl *m_avaCtrl { nullptr };
|
||||
AvaControl* m_avaCtrl{nullptr};
|
||||
|
||||
private slots:
|
||||
|
||||
private slots:
|
||||
|
||||
signals:
|
||||
void signalTimelineComplete(const AvaTimeline &timeline);
|
||||
signals:
|
||||
void signalTimelineComplete(const AvaTimeline& timeline);
|
||||
};
|
||||
|
||||
|
||||
class AvmPlaybackMenu : public QWidget,
|
||||
protected MarkerManagement::Interface::Ftc::MarkerModifyReplyHandler
|
||||
class AvmPlaybackMenu : public QWidget, protected MarkerManagement::Interface::Ftc::MarkerModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AvmPlaybackMenu(QWidget *parent = nullptr);
|
||||
~AvmPlaybackMenu();
|
||||
public:
|
||||
explicit AvmPlaybackMenu(QWidget* parent = nullptr);
|
||||
~AvmPlaybackMenu();
|
||||
|
||||
bool init(LtsSession::LtsSession *session, AvaSession *avaSession, PlaybackAppHandle &&appHandle,
|
||||
StreamNameMapping* streamNameMapping, bool isAudio, bool insideTopicEditor,
|
||||
const boost::optional<QString> &streamName = boost::none,
|
||||
const boost::optional<AvaTimePoint> &startTime = boost::none, bool setInitialSearchContentMarkers = true);
|
||||
bool init(LtsSession::LtsSession* session, AvaSession* avaSession, PlaybackAppHandle&& appHandle,
|
||||
StreamNameMapping* streamNameMapping, bool isAudio, bool insideTopicEditor,
|
||||
const boost::optional<QString>& streamName = boost::none,
|
||||
const boost::optional<AvaTimePoint>& startTime = boost::none, bool setInitialSearchContentMarkers = true);
|
||||
|
||||
void setPlaybackPreset(const QString &streamName, const AvaTimePoint &startTime, bool autostartPresetAfterInit);
|
||||
void setMarkerPreset(int markerId, bool autostartPresetAfterInit);
|
||||
void setPlaybackPreset(const QString& streamName, const AvaTimePoint& startTime, bool autostartPresetAfterInit);
|
||||
void setMarkerPreset(int markerId, bool autostartPresetAfterInit);
|
||||
|
||||
QueryTimeline *queryTimeline(const AvaTimePoint &start, const AvaTimePoint &end);
|
||||
QueryTimeline* queryTimeline(const AvaTimePoint& start, const AvaTimePoint& end);
|
||||
|
||||
void onMarkerModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onMarkerModifyReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
void retranslate();
|
||||
void retranslate();
|
||||
|
||||
|
||||
void setStreamTime(qint64 time);
|
||||
void hideStreamSelection();
|
||||
qint64 getCurrentTime() const;
|
||||
AvaSpeed getSpeed() const;
|
||||
void setSpeed(AvaSpeed newSpeed);
|
||||
int getVolume() const;
|
||||
void setVolume(int newVolume);
|
||||
void setStreamByName(const QString &name);
|
||||
|
||||
QString getInternalStreamName() const;
|
||||
void setStreamName(const QString &internalStreamName);
|
||||
bool getSkipPause() const;
|
||||
void setSkipPause(bool bSkip);
|
||||
void startPlayback(bool usePresets = false);
|
||||
void setSavedPos(qint64 msecs);
|
||||
int currentOffset() const { return m_currentOffset; }
|
||||
void selectMarker(const MarkerManagement::Marker &marker);
|
||||
void selectMarker(int markerId);
|
||||
void setStreamTime(qint64 time);
|
||||
void hideStreamSelection();
|
||||
qint64 getCurrentTime() const;
|
||||
AvaSpeed getSpeed() const;
|
||||
void setSpeed(AvaSpeed newSpeed);
|
||||
int getVolume() const;
|
||||
void setVolume(int newVolume);
|
||||
void setStreamByName(const QString& name);
|
||||
|
||||
signals:
|
||||
void signalSetOverlay(QWidget *widget);
|
||||
void signalUnsetOverlay();
|
||||
QString getInternalStreamName() const;
|
||||
void setStreamName(const QString& internalStreamName);
|
||||
bool getSkipPause() const;
|
||||
void setSkipPause(bool bSkip);
|
||||
void startPlayback(bool usePresets = false);
|
||||
void setSavedPos(qint64 msecs);
|
||||
|
||||
void setTopicButtonStates(bool enable);
|
||||
void markerSelected(const QString &description);
|
||||
int currentOffset() const
|
||||
{
|
||||
return m_currentOffset;
|
||||
}
|
||||
|
||||
|
||||
void signalSetStart(qint64 start);
|
||||
void signalSetEnd(qint64 end);
|
||||
void signalCurrentStreamChanged(const QString &displayName);
|
||||
void signalTimezoneChanged(int timezoneHoursOffset);
|
||||
void selectMarker(const MarkerManagement::Marker& marker);
|
||||
void selectMarker(int markerId);
|
||||
|
||||
public slots:
|
||||
void onStreamSelectionChanged(const QVector<AvaStream> &selectedStreams);
|
||||
signals:
|
||||
void signalSetOverlay(QWidget* widget);
|
||||
void signalUnsetOverlay();
|
||||
|
||||
private slots:
|
||||
void onSessionEstablished();
|
||||
void onDisconnected();
|
||||
void setTopicButtonStates(bool enable);
|
||||
void markerSelected(const QString& description);
|
||||
|
||||
void onStreamListReceived(const QVector<AvaStream> &streams);
|
||||
void onTimelineComplete(const AvaTimeline &timeline);
|
||||
void onStreamPositionReceived(const QString &dialogId, const QString &streamName, AvaTimePoint);
|
||||
void onVolumeReceived(AvaVolume db);
|
||||
void onCommandQueueEmpty();
|
||||
void signalSetStart(qint64 start);
|
||||
void signalSetEnd(qint64 end);
|
||||
void signalCurrentStreamChanged(const QString& displayName);
|
||||
void signalTimezoneChanged(int timezoneHoursOffset);
|
||||
|
||||
void onUiTimeChanged(AvaTimePoint t);
|
||||
void onIntervalActivated(const QModelIndex &index);
|
||||
void onMarkerClicked(const QModelIndex &index);
|
||||
void onSetMarkerClicked();
|
||||
void onStartClicked();
|
||||
void onPauseClicked();
|
||||
void onStopClicked();
|
||||
void onSkipPauseClicked();
|
||||
void onAllStreams();
|
||||
void onIntervalBackwardClicked();
|
||||
void onIntervalForwardClicked();
|
||||
void onSpeedChanged();
|
||||
void onVolumeChanged(int percent);
|
||||
void onCurrentIntervalChanged(bool hasPreviousInterval, bool hasNextInterval, const QModelIndex &rowIndex);
|
||||
void onStreamSelected();
|
||||
void onMarkerStreamSelected();
|
||||
void onStreamNameMappingChanged();
|
||||
void onAddStreamClip();
|
||||
void onAddStreamMarker();
|
||||
void onRemoveSelectedStreams();
|
||||
void onTabChanged(int index);
|
||||
void onPauseFromPlaybackApp();
|
||||
void onResumeFromPlaybackApp();
|
||||
public slots:
|
||||
void onStreamSelectionChanged(const QVector<AvaStream>& selectedStreams);
|
||||
|
||||
private slots:
|
||||
void onSessionEstablished();
|
||||
void onDisconnected();
|
||||
|
||||
private:
|
||||
enum class ButtonStates
|
||||
{
|
||||
AllOff,
|
||||
Started,
|
||||
Paused,
|
||||
Stopped
|
||||
};
|
||||
void onStreamListReceived(const QVector<AvaStream>& streams);
|
||||
void onTimelineComplete(const AvaTimeline& timeline);
|
||||
void onStreamPositionReceived(const QString& dialogId, const QString& streamName, AvaTimePoint);
|
||||
void onVolumeReceived(AvaVolume db);
|
||||
void onCommandQueueEmpty();
|
||||
|
||||
void processPresets();
|
||||
void preselectStream(const QString &fallbackInternalStreamName);
|
||||
AvaSpeed currentSpeed() const;
|
||||
void setButtonStates(ButtonStates);
|
||||
void enableAll(bool enabled = true);
|
||||
void disableAll() { enableAll(false); }
|
||||
bool trySelectedStreams();
|
||||
void addStream(QComboBox *cb);
|
||||
void onUiTimeChanged(AvaTimePoint t);
|
||||
void onIntervalActivated(const QModelIndex& index);
|
||||
void onMarkerClicked(const QModelIndex& index);
|
||||
void onSetMarkerClicked();
|
||||
void onStartClicked();
|
||||
void onPauseClicked();
|
||||
void onStopClicked();
|
||||
void onSkipPauseClicked();
|
||||
void onAllStreams();
|
||||
void onIntervalBackwardClicked();
|
||||
void onIntervalForwardClicked();
|
||||
void onSpeedChanged();
|
||||
void onVolumeChanged(int percent);
|
||||
void onCurrentIntervalChanged(bool hasPreviousInterval, bool hasNextInterval, const QModelIndex& rowIndex);
|
||||
void onStreamSelected();
|
||||
void onMarkerStreamSelected();
|
||||
void onStreamNameMappingChanged();
|
||||
void onAddStreamClip();
|
||||
void onAddStreamMarker();
|
||||
void onRemoveSelectedStreams();
|
||||
void onTabChanged(int index);
|
||||
void onPauseFromPlaybackApp();
|
||||
void onResumeFromPlaybackApp();
|
||||
|
||||
void applyAvsPos();
|
||||
void applyAvsVolume();
|
||||
|
||||
private:
|
||||
enum class ButtonStates { AllOff, Started, Paused, Stopped };
|
||||
|
||||
PlaybackAppHandle m_playbackApp;
|
||||
bool m_isAudio = false;
|
||||
StreamNameMapping *m_streamNameMapping = nullptr;
|
||||
boost::optional<QString> m_presetStreamName;
|
||||
boost::optional<int> m_markerIdPreset;
|
||||
boost::optional<AvaTimePoint> m_presetStartTime;
|
||||
void processPresets();
|
||||
void preselectStream(const QString& fallbackInternalStreamName);
|
||||
AvaSpeed currentSpeed() const;
|
||||
void setButtonStates(ButtonStates);
|
||||
void enableAll(bool enabled = true);
|
||||
|
||||
class TimelineBuilder;
|
||||
std::unique_ptr<TimelineBuilder> m_timelineBuilder;
|
||||
void disableAll()
|
||||
{
|
||||
enableAll(false);
|
||||
}
|
||||
|
||||
std::unique_ptr<Ui::Playback> m_ui;
|
||||
bool trySelectedStreams();
|
||||
void addStream(QComboBox* cb);
|
||||
|
||||
class TimeControl;
|
||||
std::unique_ptr<TimeControl> m_timeControl;
|
||||
void applyAvsPos();
|
||||
void applyAvsVolume();
|
||||
|
||||
boost::optional<QVector<AvaStream>> m_selectedStreams;
|
||||
IntervalModel m_intervalModel;
|
||||
boost::optional<AvaTimePoint> m_savedPos;
|
||||
std::unique_ptr<MarkerManagement::MarkerManagementDialogModel> m_markerModel;
|
||||
std::unique_ptr<MarkerManagement::MarkerSortFilterProxyModel> m_markerProxy;
|
||||
AvaControl *m_avaCtrl = nullptr;
|
||||
LtsSession::LtsSession *m_session = nullptr;
|
||||
bool m_skipEmpty = true;
|
||||
ButtonStates m_currentButtonState;
|
||||
std::shared_ptr<MarkerManagement::ForeignDataInterface> m_mrkDataIfc;
|
||||
boost::optional<AvaTimePoint> m_lastAvsPos;
|
||||
boost::optional<AvaVolume> m_lastAvsVolume;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
QVector<AvaStream> m_streams;
|
||||
boost::optional<AvaStream> m_currentStream;
|
||||
bool m_autostartOnce { false };
|
||||
int m_maxSelectedStreams = 12;
|
||||
bool m_queryTimelineActive { false };
|
||||
int m_currentOffset = 0;
|
||||
PlaybackAppHandle m_playbackApp;
|
||||
bool m_isAudio = false;
|
||||
StreamNameMapping* m_streamNameMapping = nullptr;
|
||||
boost::optional<QString> m_presetStreamName;
|
||||
boost::optional<int> m_markerIdPreset;
|
||||
boost::optional<AvaTimePoint> m_presetStartTime;
|
||||
|
||||
bool m_videoScreenSelectionDone { false };
|
||||
bool m_timelineIsComplete { false };
|
||||
ButtonStates m_buttonStateBeforePlaybackAppPause { ButtonStates::AllOff };
|
||||
class TimelineBuilder;
|
||||
std::unique_ptr<TimelineBuilder> m_timelineBuilder;
|
||||
|
||||
std::unique_ptr<Ui::Playback> m_ui;
|
||||
|
||||
class TimeControl;
|
||||
std::unique_ptr<TimeControl> m_timeControl;
|
||||
|
||||
boost::optional<QVector<AvaStream>> m_selectedStreams;
|
||||
IntervalModel m_intervalModel;
|
||||
boost::optional<AvaTimePoint> m_savedPos;
|
||||
std::unique_ptr<MarkerManagement::MarkerManagementDialogModel> m_markerModel;
|
||||
std::unique_ptr<MarkerManagement::MarkerSortFilterProxyModel> m_markerProxy;
|
||||
AvaControl* m_avaCtrl = nullptr;
|
||||
LtsSession::LtsSession* m_session = nullptr;
|
||||
bool m_skipEmpty = true;
|
||||
ButtonStates m_currentButtonState;
|
||||
std::shared_ptr<MarkerManagement::ForeignDataInterface> m_mrkDataIfc;
|
||||
boost::optional<AvaTimePoint> m_lastAvsPos;
|
||||
boost::optional<AvaVolume> m_lastAvsVolume;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
QVector<AvaStream> m_streams;
|
||||
boost::optional<AvaStream> m_currentStream;
|
||||
bool m_autostartOnce{false};
|
||||
int m_maxSelectedStreams = 12;
|
||||
bool m_queryTimelineActive{false};
|
||||
int m_currentOffset = 0;
|
||||
|
||||
bool m_videoScreenSelectionDone{false};
|
||||
bool m_timelineIsComplete{false};
|
||||
ButtonStates m_buttonStateBeforePlaybackAppPause{ButtonStates::AllOff};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+18
-18
@@ -1,38 +1,38 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui_avm_playback_menu_dialog.h"
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
|
||||
#include <AudioVideoManagement/Shared/playback_app.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class AvmPlaybackMenuDialog;
|
||||
}
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class AvmPlaybackMenuDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AvmPlaybackMenuDialog(bool isAudio, QWidget *parent);
|
||||
AudioVideoManagement::AvmPlaybackMenu *avmPlaybackMenu();
|
||||
Q_OBJECT
|
||||
public:
|
||||
AvmPlaybackMenuDialog(bool isAudio, QWidget* parent);
|
||||
AudioVideoManagement::AvmPlaybackMenu* avmPlaybackMenu();
|
||||
|
||||
~AvmPlaybackMenuDialog();
|
||||
~AvmPlaybackMenuDialog();
|
||||
|
||||
void retranslate() override;
|
||||
void retranslate() override;
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool m_isAudio;
|
||||
Ui::AvmPlaybackMenuDialog *m_ui;
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool m_isAudio;
|
||||
Ui::AvmPlaybackMenuDialog* m_ui;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+500
-542
File diff suppressed because it is too large.
Load diff
Executable → Regular
+49
-50
@@ -2,12 +2,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include "avm_available_streams_model.h"
|
||||
|
||||
#include <AudioVideoManagement/avm.hpp>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
#include "avm_available_streams_model.h"
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
@@ -15,63 +16,61 @@ namespace AudioVideoManagement
|
||||
class MenuStruct;
|
||||
class StreamNameMapping;
|
||||
|
||||
|
||||
|
||||
class UsedStreamsModel final : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UsedStreamsModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc,
|
||||
const MenuStruct &ms,
|
||||
StreamNameMapping *streamNameMapping,
|
||||
QObject *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
UsedStreamsModel(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> ismDtc, const MenuStruct& ms,
|
||||
StreamNameMapping* streamNameMapping, QObject* parent);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex &idx, const QVariant &value,
|
||||
int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const override;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) override;
|
||||
bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) const override;
|
||||
QStringList mimeTypes() const override;
|
||||
Qt::DropActions supportedDragActions() const override { return Qt::MoveAction; }
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
bool setData(const QModelIndex& idx, const QVariant& value, int role = Qt::EditRole) override;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
QMimeData* mimeData(const QModelIndexList& indexes) const override;
|
||||
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) override;
|
||||
bool canDropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
|
||||
const QModelIndex& parent) const override;
|
||||
QStringList mimeTypes() const override;
|
||||
|
||||
Qt::DropActions supportedDragActions() const override
|
||||
{
|
||||
return Qt::MoveAction;
|
||||
}
|
||||
|
||||
MenuStruct getMenuStruct() const;
|
||||
bool initModel();
|
||||
MenuStruct getMenuStruct() const;
|
||||
bool initModel();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
NGLTreeItem* createItem(const QVariant& data, const QIcon& icon) const override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
NGLTreeItem *createItem(const QVariant &data, const QIcon &icon) const override;
|
||||
private slots:
|
||||
void onDataChanged(const InfrastructureManagement::MainStructureElement& data, const DataModification modType);
|
||||
void onDataChangedMvs(const AudioVideoManagement::VideoTeam& data, const DataModification modType);
|
||||
void onStreamNameDataChanged(int32_t mountingPointId, const QString& internalName, const QString& displayName);
|
||||
|
||||
private slots:
|
||||
void onDataChanged(const InfrastructureManagement::MainStructureElement &data,
|
||||
const DataModification modType);
|
||||
void onDataChangedMvs(const AudioVideoManagement::VideoTeam &data,
|
||||
const DataModification modType);
|
||||
void onStreamNameDataChanged(int32_t mountingPointId, const QString &internalName, const QString &displayName);
|
||||
private:
|
||||
void updateStreamNames(const int mountingPointId, const QString &newName, NGLTreeItem *item);
|
||||
private:
|
||||
void updateStreamNames(const int mountingPointId, const QString& newName, NGLTreeItem* item);
|
||||
|
||||
void fixUpData(NGLTreeItem *item);
|
||||
void fixUpData(NGLTreeItem* item);
|
||||
|
||||
static const QString s_MimeTypeOI;
|
||||
QString mimeType(const QModelIndex &index) const;
|
||||
void insertNGLTreeItemChild(NGLTreeItem *item, NGLTreeItem *parent, bool asCopy);
|
||||
void insertChildren(NGLTreeItem *parent, int parentId, const std::vector<AudioVideoManagement::AvMenuEntry> &entries);
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
NGLTreeItem *getItemToCheck(const QModelIndex &index, const QModelIndex &parentIndex) const;
|
||||
bool checkSingleItem(NGLTreeItem * target, StreamModelData & toCheck) const;
|
||||
bool checkDrop(const QMimeData *data, const QModelIndex &index, const QModelIndex &parentIndex, Qt::DropAction action) const;
|
||||
QSet<int> fillTakenCameras(NGLTreeItem *getItem) const;
|
||||
int m_dummyId;
|
||||
MenuStruct m_menuStruct;
|
||||
StreamNameMapping *m_streamNameMapping;
|
||||
static const QString s_MimeTypeOI;
|
||||
QString mimeType(const QModelIndex& index) const;
|
||||
void insertNGLTreeItemChild(NGLTreeItem* item, NGLTreeItem* parent, bool asCopy);
|
||||
void insertChildren(NGLTreeItem* parent, int parentId,
|
||||
const std::vector<AudioVideoManagement::AvMenuEntry>& entries);
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
NGLTreeItem* getItemToCheck(const QModelIndex& index, const QModelIndex& parentIndex) const;
|
||||
bool checkSingleItem(NGLTreeItem* target, StreamModelData& toCheck) const;
|
||||
bool checkDrop(const QMimeData* data, const QModelIndex& index, const QModelIndex& parentIndex,
|
||||
Qt::DropAction action) const;
|
||||
QSet<int> fillTakenCameras(NGLTreeItem* getItem) const;
|
||||
int m_dummyId;
|
||||
MenuStruct m_menuStruct;
|
||||
StreamNameMapping* m_streamNameMapping;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+338
-361
@@ -1,464 +1,441 @@
|
||||
|
||||
|
||||
|
||||
#include "topic_replay.h"
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include <AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/ava_session.h>
|
||||
#include <AudioVideoManagement/ava_types.h>
|
||||
#include <AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <AudioVideoManagement/vd_control.h>
|
||||
#include <AudioVideoManagement/vd_session.h>
|
||||
#include <TopicEditorBase/topic_editor_base.h>
|
||||
#include <LtsUtilsCore/json_object.h>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <QWidget>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QJsonDocument>
|
||||
#include <QDir>
|
||||
#include <QtGlobal>
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
#include <vector>
|
||||
#include <QWidget>
|
||||
#include <QtGlobal>
|
||||
#include <TopicEditorBase/topic_editor_base.h>
|
||||
#include <chrono>
|
||||
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <vector>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class TopicReplay::ExportScript : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ExportScript(const QString &topLevelExportDir, TopicEditorBase::ExportNotifier *exportStep);
|
||||
public:
|
||||
ExportScript(const QString& topLevelExportDir, TopicEditorBase::ExportNotifier* exportStep);
|
||||
|
||||
public slots:
|
||||
void avScriptFinished(const QString &exportDir, AvaStreamType streamType, bool success);
|
||||
public slots:
|
||||
void avScriptFinished(const QString& exportDir, AvaStreamType streamType, bool success);
|
||||
|
||||
private:
|
||||
QString audioVideoPlaylistErstellen(const QString &dir, AvaStreamType streamType);
|
||||
bool writeFile(const QByteArray &data, const QString &fileName);
|
||||
private:
|
||||
QString audioVideoPlaylistErstellen(const QString& dir, AvaStreamType streamType);
|
||||
bool writeFile(const QByteArray& data, const QString& fileName);
|
||||
|
||||
QString m_topLevelExportDir;
|
||||
TopicEditorBase::ExportNotifier *m_exportStep;
|
||||
QString m_topLevelExportDir;
|
||||
TopicEditorBase::ExportNotifier* m_exportStep;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TopicReplay::TopicReplay(DataInterface *dataIfc, bool isAudio)
|
||||
: m_isAudio(isAudio)
|
||||
, m_dataIfc(dataIfc)
|
||||
TopicReplay::TopicReplay(DataInterface* dataIfc, bool isAudio) : m_isAudio(isAudio), m_dataIfc(dataIfc)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::TopicReplay()";
|
||||
Q_ASSERT(dataIfc);
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::TopicReplay()";
|
||||
Q_ASSERT(dataIfc);
|
||||
}
|
||||
|
||||
TopicReplay::~TopicReplay()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::~TopicReplay()";
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::~TopicReplay()";
|
||||
|
||||
if (m_isPlaying)
|
||||
playbackStop();
|
||||
if (m_isPlaying)
|
||||
playbackStop();
|
||||
}
|
||||
|
||||
QWidget *TopicReplay::createWidget()
|
||||
QWidget* TopicReplay::createWidget()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::createWidget()";
|
||||
Q_ASSERT(!m_screenPlacementHelper);
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::createWidget()";
|
||||
Q_ASSERT(!m_screenPlacementHelper);
|
||||
|
||||
if (m_isAudio)
|
||||
return nullptr;
|
||||
if (m_isAudio)
|
||||
return nullptr;
|
||||
|
||||
m_screenPlacementHelper.reset(new ScreenPlacementHelper());
|
||||
connect(m_screenPlacementHelper.data(), &ScreenPlacementHelper::widgetPlaced, this, &TopicReplay::onWidgetPlaced);
|
||||
return m_screenPlacementHelper.data();
|
||||
m_screenPlacementHelper.reset(new ScreenPlacementHelper());
|
||||
connect(m_screenPlacementHelper.data(), &ScreenPlacementHelper::widgetPlaced, this, &TopicReplay::onWidgetPlaced);
|
||||
return m_screenPlacementHelper.data();
|
||||
}
|
||||
|
||||
|
||||
void TopicReplay::slotSetScriptResponse(const AudioVideoManagement::AvaStreamInfo &streamInfo, AudioVideoManagement::AvaStreamState streamState)
|
||||
void TopicReplay::slotSetScriptResponse(const AudioVideoManagement::AvaStreamInfo& streamInfo,
|
||||
AudioVideoManagement::AvaStreamState streamState)
|
||||
{
|
||||
if (streamState == AudioVideoManagement::AvaStreamState::NotPossible)
|
||||
ERROR_LOG(m_logger) << "Script could not be set";
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Script set!";
|
||||
if (streamState == AudioVideoManagement::AvaStreamState::NotPossible)
|
||||
ERROR_LOG(m_logger) << "Script could not be set";
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Script set!";
|
||||
|
||||
ERROR_LOG(m_logger) << "streamInfo: start" << streamInfo.duration.count();
|
||||
ERROR_LOG(m_logger) << "streamState: " << static_cast<int>(streamState);
|
||||
ERROR_LOG(m_logger) << "streamInfo: start" << streamInfo.duration.count();
|
||||
ERROR_LOG(m_logger) << "streamState: " << static_cast<int>(streamState);
|
||||
}
|
||||
|
||||
|
||||
bool TopicReplay::playbackInit(const QJsonObject &attributes)
|
||||
bool TopicReplay::playbackInit(const QJsonObject& attributes)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackInit()";
|
||||
DEBUG_LOG(m_logger) << QJsonDocument(attributes).toJson();
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackInit()";
|
||||
DEBUG_LOG(m_logger) << QJsonDocument(attributes).toJson();
|
||||
|
||||
if (m_screenPlacementHelper && !m_isAudio)
|
||||
m_screenPlacementHelper->show();
|
||||
if (m_screenPlacementHelper && !m_isAudio)
|
||||
m_screenPlacementHelper->show();
|
||||
|
||||
m_playbackAttributes = attributes;
|
||||
m_playbackAttributes = attributes;
|
||||
|
||||
|
||||
AvaControl *ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ava control!";
|
||||
return false;
|
||||
}
|
||||
AvaControl* ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ava control!";
|
||||
return false;
|
||||
}
|
||||
|
||||
AvaTopicData topicData(m_playbackAttributes);
|
||||
AvaTopicData topicData(m_playbackAttributes);
|
||||
|
||||
if (!topicData.isValid)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "topicData is invalid";
|
||||
return false;
|
||||
}
|
||||
if (!topicData.isValid)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "topicData is invalid";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_scriptName = topicData.scriptName();
|
||||
m_scriptName = topicData.scriptName();
|
||||
|
||||
Q_ASSERT(topicData.isAudio() == m_isAudio);
|
||||
Q_ASSERT(topicData.isAudio() == m_isAudio);
|
||||
|
||||
PlaybackApp *app = m_isAudio ? m_dataIfc->audioPresentationApp() : m_dataIfc->videoPresentationApp();
|
||||
if (app == nullptr || app->inUse())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app invalid or in use!";
|
||||
return false;
|
||||
}
|
||||
PlaybackApp* app = m_isAudio ? m_dataIfc->audioPresentationApp() : m_dataIfc->videoPresentationApp();
|
||||
if (app == nullptr || app->inUse())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app invalid or in use!";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!m_dialogGeometry)
|
||||
{
|
||||
if (m_isAudio)
|
||||
m_appHandle = PlaybackAppHandle(app);
|
||||
if (!m_dialogGeometry)
|
||||
{
|
||||
if (m_isAudio)
|
||||
m_appHandle = PlaybackAppHandle(app);
|
||||
else
|
||||
m_appHandle = PlaybackAppHandle(app, QRect(0, 0, 0, 0));
|
||||
}
|
||||
else
|
||||
m_appHandle = PlaybackAppHandle(app, QRect(0, 0, 0, 0));
|
||||
}
|
||||
else
|
||||
m_appHandle = PlaybackAppHandle(app, *m_dialogGeometry);
|
||||
m_appHandle = PlaybackAppHandle(app, *m_dialogGeometry);
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app after creating appHandle!";
|
||||
return false;
|
||||
}
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app after creating appHandle!";
|
||||
return false;
|
||||
}
|
||||
|
||||
NGL::Settings s({});
|
||||
bool isLocal = s.isDatabaseConnectionLocal();
|
||||
|
||||
NGL::Settings s({});
|
||||
bool isLocal = s.isDatabaseConnectionLocal();
|
||||
DEBUG_LOG(m_logger) << "isLocal? " << isLocal;
|
||||
|
||||
DEBUG_LOG(m_logger) << "isLocal? " << isLocal;
|
||||
|
||||
AvaScriptSource source;
|
||||
if (isLocal)
|
||||
{
|
||||
if (m_isAudio)
|
||||
source = AvaScriptSource::LocalAudio;
|
||||
AvaScriptSource source;
|
||||
if (isLocal)
|
||||
{
|
||||
if (m_isAudio)
|
||||
source = AvaScriptSource::LocalAudio;
|
||||
else
|
||||
source = AvaScriptSource::LocalVideo;
|
||||
}
|
||||
else
|
||||
source = AvaScriptSource::LocalVideo;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_isAudio)
|
||||
source = AvaScriptSource::ServerAudio;
|
||||
else
|
||||
source = AvaScriptSource::ServerVideo;
|
||||
}
|
||||
{
|
||||
if (m_isAudio)
|
||||
source = AvaScriptSource::ServerAudio;
|
||||
else
|
||||
source = AvaScriptSource::ServerVideo;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "source: " << static_cast<int>(source);
|
||||
DEBUG_LOG(m_logger) << "source: " << static_cast<int>(source);
|
||||
|
||||
ctrl->setScript(m_appHandle.dialogId(), m_scriptName,
|
||||
source, topicData.streamList(),
|
||||
LtsUtils::createConnection(ctrl, &AudioVideoManagement::AvaControl::setScriptResponse,
|
||||
this, &TopicReplay::slotSetScriptResponse));
|
||||
ctrl->setScript(m_appHandle.dialogId(), m_scriptName, source, topicData.streamList(),
|
||||
LtsUtils::createConnection(ctrl, &AudioVideoManagement::AvaControl::setScriptResponse, this,
|
||||
&TopicReplay::slotSetScriptResponse));
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicReplay::playbackStart(int secondsOffset)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackStart()";
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackStart()";
|
||||
|
||||
if (m_screenPlacementHelper && !m_isAudio)
|
||||
m_screenPlacementHelper->show();
|
||||
if (m_screenPlacementHelper && !m_isAudio)
|
||||
m_screenPlacementHelper->show();
|
||||
|
||||
AvaControl *ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "ctrl == nullptr";
|
||||
return false;
|
||||
}
|
||||
AvaControl* ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "ctrl == nullptr";
|
||||
return false;
|
||||
}
|
||||
|
||||
AvaTimePoint p{AvaDuration{std::chrono::seconds(secondsOffset)}};
|
||||
AvaTimePoint p{AvaDuration{std::chrono::seconds(secondsOffset)}};
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
|
||||
ctrl->setAbsPositionScript(m_appHandle.dialogId(), m_scriptName, p);
|
||||
ctrl->startScript(m_appHandle.dialogId(), m_scriptName);
|
||||
ctrl->setAbsPositionScript(m_appHandle.dialogId(), m_scriptName, p);
|
||||
ctrl->startScript(m_appHandle.dialogId(), m_scriptName);
|
||||
|
||||
m_isPlaying = true;
|
||||
DEBUG_LOG(m_logger) << "m_isPlaying = true";
|
||||
return true;
|
||||
m_isPlaying = true;
|
||||
DEBUG_LOG(m_logger) << "m_isPlaying = true";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicReplay::playbackPause()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackPause()";
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackPause()";
|
||||
|
||||
if (m_screenPlacementHelper)
|
||||
m_screenPlacementHelper->hide();
|
||||
if (m_screenPlacementHelper)
|
||||
m_screenPlacementHelper->hide();
|
||||
|
||||
if (!m_isPlaying)
|
||||
if (!m_isPlaying)
|
||||
return true;
|
||||
|
||||
AvaControl* ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ctrl!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
|
||||
ctrl->pauseScript(m_appHandle.dialogId(), m_scriptName);
|
||||
return true;
|
||||
|
||||
AvaControl *ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ctrl!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
|
||||
ctrl->pauseScript(m_appHandle.dialogId(), m_scriptName);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicReplay::playbackStop()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackStop()";
|
||||
DEBUG_LOG(m_logger) << "TopicReplay::playbackStop()";
|
||||
|
||||
if (m_screenPlacementHelper)
|
||||
m_screenPlacementHelper->hide();
|
||||
if (m_screenPlacementHelper)
|
||||
m_screenPlacementHelper->hide();
|
||||
|
||||
if (!m_isPlaying)
|
||||
if (!m_isPlaying)
|
||||
return true;
|
||||
|
||||
AvaControl* ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ctrl!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
|
||||
ctrl->stopScript(m_appHandle.dialogId(), m_scriptName);
|
||||
ctrl->releaseScript(m_appHandle.dialogId(), m_scriptName);
|
||||
|
||||
m_isPlaying = false;
|
||||
return true;
|
||||
|
||||
AvaControl *ctrl = getAvaControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "no ctrl!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_appHandle)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "appHandle: missing app!";
|
||||
return false;
|
||||
}
|
||||
|
||||
ctrl->stopScript(m_appHandle.dialogId(), m_scriptName);
|
||||
ctrl->releaseScript(m_appHandle.dialogId(), m_scriptName);
|
||||
|
||||
m_isPlaying = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TopicReplay::exportTopic(const QJsonObject &attributes,
|
||||
const QString &folderPath,
|
||||
TopicEditorBase::ExportNotifier *exportNotifier)
|
||||
bool TopicReplay::exportTopic(const QJsonObject& attributes, const QString& folderPath,
|
||||
TopicEditorBase::ExportNotifier* exportNotifier)
|
||||
{
|
||||
Q_ASSERT(!m_exportScript);
|
||||
Q_ASSERT(!m_exportScript);
|
||||
|
||||
VdControl *ctrl = getVdControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "ctrl missing!";
|
||||
exportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_exportScript.reset(new ExportScript(folderPath, exportNotifier));
|
||||
|
||||
AvaTopicData topicData(attributes);
|
||||
m_scriptName = topicData.scriptName();
|
||||
|
||||
if (!topicData.isValid)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "topicData is invalid";
|
||||
exportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo fileInfo(QDir(folderPath).filePath(topicData.scriptName()));
|
||||
|
||||
Q_ASSERT(topicData.isAudio() == m_isAudio);
|
||||
|
||||
ctrl->vdSetScript(m_scriptName,
|
||||
m_isAudio ? AvaStreamType::Audio : AvaStreamType::Video,
|
||||
0, topicData.streamList(), fileInfo.baseName(), fileInfo.absolutePath(),
|
||||
this, &TopicReplay::avScriptFinished);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TopicReplay::onWidgetPlaced(const QRect &geometry)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "TopicReplay::onWidgetPlaced() - geo: " << geometry.x() << "/" << geometry.y()
|
||||
<< " m_isAudio=" << m_isAudio;
|
||||
|
||||
m_dialogGeometry = geometry;
|
||||
|
||||
if (m_isAudio)
|
||||
return;
|
||||
|
||||
PlaybackApp *app = m_isAudio ? m_dataIfc->audioPresentationApp() : m_dataIfc->videoPresentationApp();
|
||||
if (app == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app missing!";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!app->inUse())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app not in use - waiting for playbackInit to aquire it";
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "setGeometry";
|
||||
app->setGeometry(*m_dialogGeometry);
|
||||
}
|
||||
|
||||
AvaControl *TopicReplay::getAvaControl()
|
||||
{
|
||||
if (!m_dataIfc->hasAvsSession())
|
||||
return nullptr;
|
||||
|
||||
AvaSession *avaSession = m_dataIfc->avaSession();
|
||||
if (!avaSession->isEstablished())
|
||||
return nullptr;
|
||||
|
||||
return avaSession->control();
|
||||
}
|
||||
|
||||
VdControl *TopicReplay::getVdControl()
|
||||
{
|
||||
if (!m_dataIfc->hasAvsSession())
|
||||
return nullptr;
|
||||
|
||||
VdSession *vdSession = m_dataIfc->vdSession();
|
||||
if (!vdSession->isEstablished())
|
||||
return nullptr;
|
||||
|
||||
return vdSession->control();
|
||||
}
|
||||
|
||||
void TopicReplay::avScriptFinished(const QString &exportDir, AvaStreamType streamType, bool success)
|
||||
{
|
||||
VdControl *ctrl = getVdControl();
|
||||
ctrl->vdReleaseScript(m_scriptName);
|
||||
m_exportScript->avScriptFinished(exportDir, streamType, success);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
TopicReplay::ExportScript::ExportScript(const QString &topLevelExportDir, TopicEditorBase::ExportNotifier *exportStep)
|
||||
: m_topLevelExportDir(topLevelExportDir)
|
||||
, m_exportStep(exportStep)
|
||||
{
|
||||
connect(exportStep, &QObject::destroyed, this, [this]()
|
||||
{
|
||||
if (static_cast<TopicEditorBase::ExportNotifier *>(sender()) != m_exportStep)
|
||||
return;
|
||||
m_exportStep = nullptr;
|
||||
});
|
||||
Q_ASSERT(exportStep);
|
||||
}
|
||||
|
||||
void TopicReplay::ExportScript::avScriptFinished(const QString &exportDir, AvaStreamType streamType, bool success)
|
||||
{
|
||||
QString absPathToPlaylist = audioVideoPlaylistErstellen(exportDir, streamType);
|
||||
|
||||
QDir toplevelExportDir(m_topLevelExportDir);
|
||||
QString relativePathToPlaylist = toplevelExportDir.relativeFilePath(absPathToPlaylist);
|
||||
|
||||
if (m_exportStep == nullptr)
|
||||
return;
|
||||
|
||||
if (success)
|
||||
m_exportStep->setExportSuccessful(relativePathToPlaylist);
|
||||
else
|
||||
m_exportStep->setExportFailed();
|
||||
}
|
||||
|
||||
QString TopicReplay::ExportScript::audioVideoPlaylistErstellen(const QString &dir, AvaStreamType streamType)
|
||||
{
|
||||
QDir avDir(dir);
|
||||
const QFileInfoList dateienList = avDir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
|
||||
|
||||
QByteArray dataForFile;
|
||||
QString data;
|
||||
dataForFile.append("[playlist]\n");
|
||||
|
||||
int numberOfEntries = 0;
|
||||
int i = 1;
|
||||
const QString tmpl1(QStringLiteral("File %1=%2\n"));
|
||||
const QString tmpl2(QStringLiteral("# File %1=%2\n"));
|
||||
for (const QFileInfo &fileInfo : dateienList)
|
||||
{
|
||||
if (streamType == AvaStreamType::Video && fileInfo.suffix() == QLatin1String(".wav"))
|
||||
VdControl* ctrl = getVdControl();
|
||||
if (ctrl == nullptr)
|
||||
{
|
||||
data += tmpl2.arg(QString::number(i), fileInfo.fileName());
|
||||
i--;
|
||||
ERROR_LOG(m_logger) << "ctrl missing!";
|
||||
exportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_exportScript.reset(new ExportScript(folderPath, exportNotifier));
|
||||
|
||||
AvaTopicData topicData(attributes);
|
||||
m_scriptName = topicData.scriptName();
|
||||
|
||||
if (!topicData.isValid)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "topicData is invalid";
|
||||
exportNotifier->setExportFailed();
|
||||
return false;
|
||||
}
|
||||
|
||||
QFileInfo fileInfo(QDir(folderPath).filePath(topicData.scriptName()));
|
||||
|
||||
Q_ASSERT(topicData.isAudio() == m_isAudio);
|
||||
|
||||
ctrl->vdSetScript(m_scriptName, m_isAudio ? AvaStreamType::Audio : AvaStreamType::Video, 0, topicData.streamList(),
|
||||
fileInfo.baseName(), fileInfo.absolutePath(), this, &TopicReplay::avScriptFinished);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TopicReplay::onWidgetPlaced(const QRect& geometry)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "TopicReplay::onWidgetPlaced() - geo: " << geometry.x() << "/" << geometry.y()
|
||||
<< " m_isAudio=" << m_isAudio;
|
||||
|
||||
m_dialogGeometry = geometry;
|
||||
|
||||
if (m_isAudio)
|
||||
return;
|
||||
|
||||
PlaybackApp* app = m_isAudio ? m_dataIfc->audioPresentationApp() : m_dataIfc->videoPresentationApp();
|
||||
if (app == nullptr)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app missing!";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!app->inUse())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "app not in use - waiting for playbackInit to aquire it";
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "setGeometry";
|
||||
app->setGeometry(*m_dialogGeometry);
|
||||
}
|
||||
|
||||
AvaControl* TopicReplay::getAvaControl()
|
||||
{
|
||||
if (!m_dataIfc->hasAvsSession())
|
||||
return nullptr;
|
||||
|
||||
AvaSession* avaSession = m_dataIfc->avaSession();
|
||||
if (!avaSession->isEstablished())
|
||||
return nullptr;
|
||||
|
||||
return avaSession->control();
|
||||
}
|
||||
|
||||
VdControl* TopicReplay::getVdControl()
|
||||
{
|
||||
if (!m_dataIfc->hasAvsSession())
|
||||
return nullptr;
|
||||
|
||||
VdSession* vdSession = m_dataIfc->vdSession();
|
||||
if (!vdSession->isEstablished())
|
||||
return nullptr;
|
||||
|
||||
return vdSession->control();
|
||||
}
|
||||
|
||||
void TopicReplay::avScriptFinished(const QString& exportDir, AvaStreamType streamType, bool success)
|
||||
{
|
||||
VdControl* ctrl = getVdControl();
|
||||
ctrl->vdReleaseScript(m_scriptName);
|
||||
m_exportScript->avScriptFinished(exportDir, streamType, success);
|
||||
}
|
||||
|
||||
TopicReplay::ExportScript::ExportScript(const QString& topLevelExportDir, TopicEditorBase::ExportNotifier* exportStep)
|
||||
: m_topLevelExportDir(topLevelExportDir), m_exportStep(exportStep)
|
||||
{
|
||||
connect(exportStep, &QObject::destroyed, this, [this]() {
|
||||
if (static_cast<TopicEditorBase::ExportNotifier*>(sender()) != m_exportStep)
|
||||
return;
|
||||
m_exportStep = nullptr;
|
||||
});
|
||||
Q_ASSERT(exportStep);
|
||||
}
|
||||
|
||||
void TopicReplay::ExportScript::avScriptFinished(const QString& exportDir, AvaStreamType streamType, bool success)
|
||||
{
|
||||
QString absPathToPlaylist = audioVideoPlaylistErstellen(exportDir, streamType);
|
||||
|
||||
QDir toplevelExportDir(m_topLevelExportDir);
|
||||
QString relativePathToPlaylist = toplevelExportDir.relativeFilePath(absPathToPlaylist);
|
||||
|
||||
if (m_exportStep == nullptr)
|
||||
return;
|
||||
|
||||
if (success)
|
||||
m_exportStep->setExportSuccessful(relativePathToPlaylist);
|
||||
else
|
||||
{
|
||||
data += tmpl1.arg(QString::number(i), fileInfo.fileName());
|
||||
numberOfEntries++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
QString numberOfEntriesString = QStringLiteral("NumberOfEntries=") + QString::number(numberOfEntries) + QStringLiteral("\n");
|
||||
dataForFile.append(numberOfEntriesString.toUtf8());
|
||||
dataForFile.append(data.toUtf8());
|
||||
|
||||
QString fileName;
|
||||
switch (streamType)
|
||||
{
|
||||
case AvaStreamType::Audio:
|
||||
fileName = avDir.filePath(QStringLiteral("audio.pls"));
|
||||
break;
|
||||
|
||||
case AvaStreamType::Video:
|
||||
fileName = avDir.filePath(QStringLiteral("video.pls"));
|
||||
break;
|
||||
}
|
||||
|
||||
writeFile(dataForFile, fileName);
|
||||
return fileName;
|
||||
m_exportStep->setExportFailed();
|
||||
}
|
||||
|
||||
bool TopicReplay::ExportScript::writeFile(const QByteArray &data, const QString &fileName)
|
||||
QString TopicReplay::ExportScript::audioVideoPlaylistErstellen(const QString& dir, AvaStreamType streamType)
|
||||
{
|
||||
QFile file(fileName);
|
||||
QDir avDir(dir);
|
||||
const QFileInfoList dateienList = avDir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||
return false;
|
||||
QByteArray dataForFile;
|
||||
QString data;
|
||||
dataForFile.append("[playlist]\n");
|
||||
|
||||
if (file.write(data) == -1)
|
||||
{
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
int numberOfEntries = 0;
|
||||
int i = 1;
|
||||
const QString tmpl1(QStringLiteral("File %1=%2\n"));
|
||||
const QString tmpl2(QStringLiteral("# File %1=%2\n"));
|
||||
for (const QFileInfo& fileInfo : dateienList)
|
||||
{
|
||||
if (streamType == AvaStreamType::Video && fileInfo.suffix() == QLatin1String(".wav"))
|
||||
{
|
||||
data += tmpl2.arg(QString::number(i), fileInfo.fileName());
|
||||
i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
data += tmpl1.arg(QString::number(i), fileInfo.fileName());
|
||||
numberOfEntries++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
file.close();
|
||||
QString numberOfEntriesString =
|
||||
QStringLiteral("NumberOfEntries=") + QString::number(numberOfEntries) + QStringLiteral("\n");
|
||||
dataForFile.append(numberOfEntriesString.toUtf8());
|
||||
dataForFile.append(data.toUtf8());
|
||||
|
||||
return true;
|
||||
QString fileName;
|
||||
switch (streamType)
|
||||
{
|
||||
case AvaStreamType::Audio:
|
||||
fileName = avDir.filePath(QStringLiteral("audio.pls"));
|
||||
break;
|
||||
|
||||
case AvaStreamType::Video:
|
||||
fileName = avDir.filePath(QStringLiteral("video.pls"));
|
||||
break;
|
||||
}
|
||||
|
||||
writeFile(dataForFile, fileName);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
}
|
||||
bool TopicReplay::ExportScript::writeFile(const QByteArray& data, const QString& fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||
return false;
|
||||
|
||||
if (file.write(data) == -1)
|
||||
{
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
file.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
#include "topic_replay.moc"
|
||||
Executable → Regular
+133
-158
@@ -1,252 +1,227 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_combat_net_radio_dialog.h"
|
||||
#include "ui_avm_combat_net_radio_dialog.h"
|
||||
|
||||
#include "avm_cnr_json_helper.h"
|
||||
#include "avm_combat_net_radio_dialog_model.h"
|
||||
#include "avm_edit_combat_net_radio_dialog.h"
|
||||
#include "avm_cnr_json_helper.h"
|
||||
#include "avm_load_combat_net_radio_dialog.h"
|
||||
#include "ui_avm_combat_net_radio_dialog.h"
|
||||
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
CombatNetRadioDialog::CombatNetRadioDialog(LtsSession::LtsSession *session, const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::CombatNetRadioDialog)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
CombatNetRadioDialog::CombatNetRadioDialog(LtsSession::LtsSession* session, const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_session(session),
|
||||
m_ui(new Ui::CombatNetRadioDialog), m_menuGroup(menuGroup), m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setUnchangeable(true);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CombatNetRadioDialog::onPrint);
|
||||
m_ui->setupUi(this);
|
||||
setUnchangeable(true);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CombatNetRadioDialog::onPrint);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Combat_Net_Radio_Configuration"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Combat_Net_Radio_Configuration"));
|
||||
}
|
||||
|
||||
CombatNetRadioDialog::~CombatNetRadioDialog() = default;
|
||||
|
||||
void CombatNetRadioDialog::retranslate()
|
||||
{
|
||||
translate(m_ui.get(), tr("Configure Combat Net Radio"));
|
||||
translate(m_ui.get(), tr("Configure Combat Net Radio"));
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool CombatNetRadioDialog::init(const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc)
|
||||
bool CombatNetRadioDialog::init(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc)
|
||||
{
|
||||
if (!(avmDtc->enableCnrChannel() &&
|
||||
avmDtc->enableCnrConfig() &&
|
||||
ppmDtc->enableParty() &&
|
||||
ppmDtc->enableParticipant() &&
|
||||
ppmDtc->enableType() &&
|
||||
avmFtc->enableModifyCnrConfig() &&
|
||||
avmFtc->enableRemoveCnrConfig()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
if (!(avmDtc->enableCnrChannel() && avmDtc->enableCnrConfig() && ppmDtc->enableParty() &&
|
||||
ppmDtc->enableParticipant() && ppmDtc->enableType() && avmFtc->enableModifyCnrConfig() &&
|
||||
avmFtc->enableRemoveCnrConfig()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_model.reset(new CombatNetRadioDialogModel(m_session->exerciseId(), this));
|
||||
m_filter.reset(new CombatNetRadioDialogFilter(m_session->exerciseId(), m_model.get()));
|
||||
m_model.reset(new CombatNetRadioDialogModel(m_session->exerciseId(), this));
|
||||
m_filter.reset(new CombatNetRadioDialogFilter(m_session->exerciseId(), m_model.get()));
|
||||
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_exmDtc = exmDtc;
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_exmDtc = exmDtc;
|
||||
|
||||
m_avmDtc->waitForHistoricalDataCnrChannel(3000);
|
||||
m_ppmDtc->waitForHistoricalDataParty(3000);
|
||||
m_avmDtc->waitForHistoricalDataCnrChannel(3000);
|
||||
m_ppmDtc->waitForHistoricalDataParty(3000);
|
||||
|
||||
if (!m_model->init(avmDtc, ppmDtc))
|
||||
{
|
||||
m_filter.reset();
|
||||
m_model.reset();
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
if (!m_model->init(avmDtc, ppmDtc))
|
||||
{
|
||||
m_filter.reset();
|
||||
m_model.reset();
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ui->dataView->setModel(m_filter.get());
|
||||
m_ui->dataView->setModel(m_filter.get());
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &CombatNetRadioDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &CombatNetRadioDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &CombatNetRadioDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &CombatNetRadioDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &CombatNetRadioDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &CombatNetRadioDialog::onRemoveClicked);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &CombatNetRadioDialog::onSelectionChanged);
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&CombatNetRadioDialog::onSelectionChanged);
|
||||
|
||||
onSelectionChanged();
|
||||
onSelectionChanged();
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &CombatNetRadioDialog::onEditClicked);
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked, this, &CombatNetRadioDialog::onEditClicked);
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&CombatNetRadioDialog::onImportButtonClicked,
|
||||
&CombatNetRadioDialog::onExportButtonClicked);
|
||||
m_buttonBox->connectLibraryButton(this, &CombatNetRadioDialog::onImportButtonClicked,
|
||||
&CombatNetRadioDialog::onExportButtonClicked);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onRemoveCnrConfigReply(const Core::FunctionReplyObject &replyObject)
|
||||
void CombatNetRadioDialog::onRemoveCnrConfigReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onModifyCnrConfigReply(const Core::FunctionReplyObject &replyObject)
|
||||
void CombatNetRadioDialog::onModifyCnrConfigReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onAddClicked()
|
||||
{
|
||||
EditCombatNetRadioDialog *dialog = new EditCombatNetRadioDialog(m_session->exerciseId(), m_session, m_ppmDtc, m_avmDtc, m_avmFtc, m_exmDtc, this);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("NewCNRConfig"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
EditCombatNetRadioDialog* dialog =
|
||||
new EditCombatNetRadioDialog(m_session->exerciseId(), m_session, m_ppmDtc, m_avmDtc, m_avmFtc, m_exmDtc, this);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("NewCNRConfig"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onEditClicked()
|
||||
{
|
||||
|
||||
if (!m_buttonBox->isButtonEnabled(LtsWidgets::DialogButton::Edit))
|
||||
return;
|
||||
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
if (!m_buttonBox->isButtonEnabled(LtsWidgets::DialogButton::Edit))
|
||||
return;
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
CnrConfig config = m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>();
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
EditCombatNetRadioDialog *dialog = new EditCombatNetRadioDialog(config,
|
||||
m_session->exerciseId(),
|
||||
m_session,
|
||||
m_ppmDtc,
|
||||
m_avmDtc,
|
||||
m_avmFtc,
|
||||
m_exmDtc,
|
||||
this);
|
||||
CnrConfig config = m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>();
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditCNRConfig%1").arg(config.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
EditCombatNetRadioDialog* dialog = new EditCombatNetRadioDialog(config, m_session->exerciseId(), m_session,
|
||||
m_ppmDtc, m_avmDtc, m_avmFtc, m_exmDtc, this);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditCNRConfig%1").arg(config.id()),
|
||||
LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onRemoveClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
Core::RemoveElementRequest request(m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>().id());
|
||||
Core::RemoveElementRequest request(m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>().id());
|
||||
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->removeCnrConfigRequest(request, this);
|
||||
});
|
||||
m_requestHelper->startSingleRequest([this, request]() { return m_avmFtc->removeCnrConfigRequest(request, this); });
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onSelectionChanged()
|
||||
{
|
||||
bool rowSelected = m_ui->dataView->selectionModel()->selectedRows().size() > 0;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, rowSelected);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, rowSelected);
|
||||
bool rowSelected = m_ui->dataView->selectionModel()->selectedRows().size() > 0;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, rowSelected);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, rowSelected);
|
||||
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
CnrConfig config = m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>();
|
||||
bool enabled = rowSelected && (config.exerciseId().is_set() || m_session->partitionType() == IDL::PartitionType::Global);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, enabled);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, enabled);
|
||||
CnrConfig config = m_model->data(currentIndex, Qt::UserRole).value<CnrConfig>();
|
||||
bool enabled =
|
||||
rowSelected && (config.exerciseId().is_set() || m_session->partitionType() == IDL::PartitionType::Global);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, enabled);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, enabled);
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
}
|
||||
|
||||
void CombatNetRadioDialog::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_filter->modelToJson();
|
||||
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 ";
|
||||
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 CombatNetRadioDialog::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " 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::AVMCombatNetRadio));
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMCombatNetRadio));
|
||||
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMCombatNetRadio)))
|
||||
if (fileId > 0)
|
||||
{
|
||||
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
|
||||
{
|
||||
LoadCombatNetRadioDialog loadingDialog(content, m_session) ;
|
||||
loadingDialog.exec();
|
||||
|
||||
if (loadingDialog.isApplied())
|
||||
{
|
||||
const QVector<Core::RemoveElementRequest> removeRequests = loadingDialog.removeRequests();
|
||||
|
||||
for (const auto &removeRequest : removeRequests)
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMCombatNetRadio)))
|
||||
{
|
||||
m_requestHelper->addRequest([this, removeRequest]()
|
||||
{
|
||||
return m_avmFtc->removeCnrConfigRequest(removeRequest, this);
|
||||
});
|
||||
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);
|
||||
}
|
||||
|
||||
const QVector<ModifyCnrConfigRequest> modifyRequests = loadingDialog.modifyRequests();
|
||||
|
||||
for (const auto &modifyRequest : modifyRequests)
|
||||
else
|
||||
{
|
||||
m_requestHelper->addRequest([this, modifyRequest]()
|
||||
{
|
||||
return m_avmFtc->modifyCnrConfigRequest(modifyRequest, this);
|
||||
});
|
||||
}
|
||||
LoadCombatNetRadioDialog loadingDialog(content, m_session);
|
||||
loadingDialog.exec();
|
||||
|
||||
if (modifyRequests.size() || removeRequests.size())
|
||||
(void) m_requestHelper->startRequests();
|
||||
}
|
||||
if (loadingDialog.isApplied())
|
||||
{
|
||||
const QVector<Core::RemoveElementRequest> removeRequests = loadingDialog.removeRequests();
|
||||
|
||||
for (const auto& removeRequest : removeRequests)
|
||||
{
|
||||
m_requestHelper->addRequest(
|
||||
[this, removeRequest]() { return m_avmFtc->removeCnrConfigRequest(removeRequest, this); });
|
||||
}
|
||||
|
||||
const QVector<ModifyCnrConfigRequest> modifyRequests = loadingDialog.modifyRequests();
|
||||
|
||||
for (const auto& modifyRequest : modifyRequests)
|
||||
{
|
||||
m_requestHelper->addRequest(
|
||||
[this, modifyRequest]() { return m_avmFtc->modifyCnrConfigRequest(modifyRequest, this); });
|
||||
}
|
||||
|
||||
if (modifyRequests.size() || removeRequests.size())
|
||||
(void)m_requestHelper->startRequests();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+44
-46
@@ -1,14 +1,11 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
@@ -27,7 +24,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
@@ -35,7 +32,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -43,58 +40,59 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class CombatNetRadioDialogModel;
|
||||
class CombatNetRadioDialogFilter;
|
||||
|
||||
class CombatNetRadioDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::RemoveCnrConfigReplyHandler
|
||||
, protected Interface::Ftc::ModifyCnrConfigReplyHandler
|
||||
class CombatNetRadioDialog : public LtsWidgets::LtsDialog,
|
||||
protected Interface::Ftc::RemoveCnrConfigReplyHandler,
|
||||
protected Interface::Ftc::ModifyCnrConfigReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CombatNetRadioDialog(LtsSession::LtsSession *session, const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~CombatNetRadioDialog();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CombatNetRadioDialog(LtsSession::LtsSession* session, const QString& menuGroup, QWidget* parent = nullptr);
|
||||
~CombatNetRadioDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<Interface::Ftc> &avmFtc, const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc, ExerciseManagement::Interface::Dtc *exmDtc);
|
||||
bool init(const std::shared_ptr<Interface::Dtc>& avmDtc, const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc);
|
||||
|
||||
void onRemoveCnrConfigReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onModifyCnrConfigReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onRemoveCnrConfigReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
void onModifyCnrConfigReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session;
|
||||
std::unique_ptr<CombatNetRadioDialogModel> m_model;
|
||||
std::unique_ptr<CombatNetRadioDialogFilter> m_filter;
|
||||
std::unique_ptr<Ui::CombatNetRadioDialog> 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<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
ExerciseManagement::Interface::Dtc *m_exmDtc{nullptr};
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
}
|
||||
private:
|
||||
LtsSession::LtsSession* m_session;
|
||||
std::unique_ptr<CombatNetRadioDialogModel> m_model;
|
||||
std::unique_ptr<CombatNetRadioDialogFilter> m_filter;
|
||||
std::unique_ptr<Ui::CombatNetRadioDialog> 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<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
ExerciseManagement::Interface::Dtc* m_exmDtc{nullptr};
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+103
-111
@@ -1,153 +1,145 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_combat_net_radio_dialog_model.h"
|
||||
#include <utility>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
|
||||
#include "avm_cnr_json_helper.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <utility>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
CombatNetRadioDialogModel::CombatNetRadioDialogModel(int32_t exerciseId, QObject *parent)
|
||||
: LtsAbstractTableModel<CnrConfig>(
|
||||
{
|
||||
tr("Channel Number"),
|
||||
tr("Radio Circuit"),
|
||||
tr("Code Word"),
|
||||
tr("Party"),
|
||||
tr("Unit"),
|
||||
tr("Global")
|
||||
}, parent)
|
||||
, m_exerciseId(exerciseId)
|
||||
CombatNetRadioDialogModel::CombatNetRadioDialogModel(int32_t exerciseId, QObject* parent)
|
||||
: LtsAbstractTableModel<CnrConfig>(
|
||||
{tr("Channel Number"), tr("Radio Circuit"), tr("Code Word"), tr("Party"), tr("Unit"), tr("Global")}, parent),
|
||||
m_exerciseId(exerciseId)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant CombatNetRadioDialogModel::data(const QModelIndex &index, int role) const
|
||||
QVariant CombatNetRadioDialogModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if ((role != Qt::BackgroundRole &&role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
if ((role != Qt::BackgroundRole && role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
return {};
|
||||
|
||||
const CnrConfig& config = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case CHANNEL:
|
||||
INFO_LOG(m_logger) << "CombatNetRadioDialogModel::data role =" << role << " row = " << index.row();
|
||||
return QString::fromStdString(m_cnrChannels.value(config.cnrChannelId()).name());
|
||||
case RADIO_CIRCUIT:
|
||||
return QString::fromStdString(config.radioCircuit());
|
||||
case CALL_SIGN:
|
||||
return QString::fromStdString(config.callSign());
|
||||
case PARTY:
|
||||
if (config.exerciseId().is_set() || config.partyId() > 0)
|
||||
return ParticipantManagement::trPartyName(m_parties.value(config.partyId()).name());
|
||||
else
|
||||
return QStringLiteral("-");
|
||||
case UNIT: {
|
||||
if (!config.unitId().is_set())
|
||||
return {};
|
||||
const int unitId = config.unitId().get();
|
||||
const auto unit = m_units.value(config.unitId().get());
|
||||
if (unit.id() != unitId)
|
||||
return {};
|
||||
|
||||
INFO_LOG(m_logger) << " config.unitId()=" << unitId << " Str=" << unit.name();
|
||||
|
||||
QString unitStr;
|
||||
if (unit.designator().size() > 0)
|
||||
unitStr = QString::fromStdString(unit.designator()) + QLatin1Char('/');
|
||||
unitStr.append(QString::fromStdString(unit.tacticalIdentifier()));
|
||||
INFO_LOG(m_logger) << "unitStr = " << unitStr;
|
||||
|
||||
return unitStr;
|
||||
}
|
||||
case GLOBAL:
|
||||
return config.exerciseId().is_set() ? tr("No") : tr("Yes");
|
||||
}
|
||||
}
|
||||
else if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() == m_exerciseId)
|
||||
return {};
|
||||
if (!config.exerciseId().is_set() && m_exerciseId <= 0)
|
||||
return {};
|
||||
return QColor(Qt::gray);
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return QVariant::fromValue(config);
|
||||
|
||||
return {};
|
||||
|
||||
const CnrConfig &config = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case CHANNEL:
|
||||
INFO_LOG(m_logger)<<"CombatNetRadioDialogModel::data role =" << role
|
||||
<< " row = " << index.row();
|
||||
return QString::fromStdString(m_cnrChannels.value(config.cnrChannelId()).name());
|
||||
case RADIO_CIRCUIT:
|
||||
return QString::fromStdString(config.radioCircuit());
|
||||
case CALL_SIGN:
|
||||
return QString::fromStdString(config.callSign());
|
||||
case PARTY:
|
||||
if(config.exerciseId().is_set() || config.partyId() > 0)
|
||||
return ParticipantManagement::trPartyName(m_parties.value(config.partyId()).name());
|
||||
else
|
||||
return QStringLiteral("-");
|
||||
case UNIT:
|
||||
{
|
||||
if (!config.unitId().is_set())
|
||||
return {};
|
||||
const int unitId = config.unitId().get();
|
||||
const auto unit = m_units.value(config.unitId().get());
|
||||
if (unit.id() != unitId)
|
||||
return {};
|
||||
|
||||
INFO_LOG(m_logger) << " config.unitId()=" << unitId
|
||||
<< " Str=" << unit.name();
|
||||
|
||||
QString unitStr;
|
||||
if (unit.designator().size() > 0)
|
||||
unitStr = QString::fromStdString(unit.designator()) + QLatin1Char('/');
|
||||
unitStr.append(QString::fromStdString(unit.tacticalIdentifier()));
|
||||
INFO_LOG(m_logger) << "unitStr = " << unitStr;
|
||||
|
||||
return unitStr;
|
||||
}
|
||||
case GLOBAL:
|
||||
return config.exerciseId().is_set() ? tr("No") : tr("Yes");
|
||||
}
|
||||
}
|
||||
else if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() == m_exerciseId)
|
||||
return {};
|
||||
if (!config.exerciseId().is_set() && m_exerciseId <= 0)
|
||||
return {};
|
||||
return QColor(Qt::gray);
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return QVariant::fromValue(config);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
bool CombatNetRadioDialogModel::init(const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc)
|
||||
bool CombatNetRadioDialogModel::init(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc)
|
||||
{
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmDtc = avmDtc;
|
||||
|
||||
m_cnrChannels = avmDtc->cnrChannels();
|
||||
m_cnrChannels = avmDtc->cnrChannels();
|
||||
|
||||
if (!ppmDtc->visibleParties(m_parties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(m_exerciseId)))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
m_units = ppmDtc->units();
|
||||
if (!ppmDtc->visibleParties(m_parties,
|
||||
LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(m_exerciseId)))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not retrieve visible Parties!";
|
||||
return false;
|
||||
}
|
||||
m_units = ppmDtc->units();
|
||||
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::cnrConfigChanged, this, &CombatNetRadioDialogModel::onDataChanged);
|
||||
m_avmDtc->cnrConfigs([this](const CnrConfig &c) { insertRow(c); });
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::cnrConfigChanged, this, &CombatNetRadioDialogModel::onDataChanged);
|
||||
m_avmDtc->cnrConfigs([this](const CnrConfig& c) { insertRow(c); });
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CombatNetRadioDialogModel::onlyGlobals()
|
||||
{
|
||||
for(const CnrConfig &config : std::as_const(m_vecData))
|
||||
{
|
||||
if(config.exerciseId().is_set() && config.exerciseId().get() == m_exerciseId)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
for (const CnrConfig& config : std::as_const(m_vecData))
|
||||
{
|
||||
if (config.exerciseId().is_set() && config.exerciseId().get() == m_exerciseId)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray CombatNetRadioDialogFilter::modelToJson() const
|
||||
{
|
||||
QVector<CnrConfig> configs;
|
||||
configs.reserve(rowCount());
|
||||
QVector<CnrConfig> configs;
|
||||
configs.reserve(rowCount());
|
||||
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
int sourceRow = mapToSource(index(row, 0)).row();
|
||||
configs.append(m_sourceModel->getRowData(sourceRow));
|
||||
}
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
int sourceRow = mapToSource(index(row, 0)).row();
|
||||
configs.append(m_sourceModel->getRowData(sourceRow));
|
||||
}
|
||||
|
||||
return cnrConfigVectorToJson(configs, m_exerciseId);
|
||||
return cnrConfigVectorToJson(configs, m_exerciseId);
|
||||
}
|
||||
|
||||
CombatNetRadioDialogFilter::CombatNetRadioDialogFilter(int32_t exerciseId, CombatNetRadioDialogModel *sourceModel)
|
||||
: m_exerciseId(exerciseId)
|
||||
, m_sourceModel(sourceModel)
|
||||
CombatNetRadioDialogFilter::CombatNetRadioDialogFilter(int32_t exerciseId, CombatNetRadioDialogModel* sourceModel)
|
||||
: m_exerciseId(exerciseId), m_sourceModel(sourceModel)
|
||||
{
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(sourceModel);
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool CombatNetRadioDialogFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
bool CombatNetRadioDialogFilter::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
|
||||
{
|
||||
CnrConfig cnrConfig = m_sourceModel->getRowData(sourceRow);
|
||||
CnrConfig cnrConfig = m_sourceModel->getRowData(sourceRow);
|
||||
|
||||
if (cnrConfig.exerciseId().is_set() && cnrConfig.exerciseId().get() != m_exerciseId)
|
||||
return false;
|
||||
if (cnrConfig.exerciseId().is_set() && cnrConfig.exerciseId().get() != m_exerciseId)
|
||||
return false;
|
||||
|
||||
return LtsColumnFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
return LtsColumnFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+30
-47
@@ -1,77 +1,60 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class CombatNetRadioDialogModel final
|
||||
: public LtsWidgets::LtsAbstractTableModel<CnrConfig>
|
||||
class CombatNetRadioDialogModel final : public LtsWidgets::LtsAbstractTableModel<CnrConfig>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
CHANNEL,
|
||||
RADIO_CIRCUIT,
|
||||
CALL_SIGN,
|
||||
PARTY,
|
||||
UNIT,
|
||||
GLOBAL
|
||||
};
|
||||
public:
|
||||
enum Columns { CHANNEL, RADIO_CIRCUIT, CALL_SIGN, PARTY, UNIT, GLOBAL };
|
||||
|
||||
explicit CombatNetRadioDialogModel(int32_t exerciseId, QObject *parent = nullptr);
|
||||
explicit CombatNetRadioDialogModel(int32_t exerciseId, QObject* parent = nullptr);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &avmDtc, const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc);
|
||||
bool onlyGlobals();
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
bool init(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc);
|
||||
bool onlyGlobals();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
int32_t m_exerciseId;
|
||||
QMap<int32_t, CnrChannel> m_cnrChannels;
|
||||
QMap<int32_t, ParticipantManagement::Party> m_parties;
|
||||
QMap<int32_t, ParticipantManagement::Participant> m_units;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
int32_t m_exerciseId;
|
||||
QMap<int32_t, CnrChannel> m_cnrChannels;
|
||||
QMap<int32_t, ParticipantManagement::Party> m_parties;
|
||||
QMap<int32_t, ParticipantManagement::Participant> m_units;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class CombatNetRadioDialogFilter : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
public:
|
||||
explicit CombatNetRadioDialogFilter(int32_t exerciseId, CombatNetRadioDialogModel *sourceModel);
|
||||
public:
|
||||
explicit CombatNetRadioDialogFilter(int32_t exerciseId, CombatNetRadioDialogModel* sourceModel);
|
||||
|
||||
QByteArray modelToJson() const;
|
||||
QByteArray modelToJson() const;
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
|
||||
|
||||
private:
|
||||
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::setSourceModel;
|
||||
private:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::setSourceModel;
|
||||
|
||||
int32_t m_exerciseId;
|
||||
CombatNetRadioDialogModel *m_sourceModel;
|
||||
int32_t m_exerciseId;
|
||||
CombatNetRadioDialogModel* m_sourceModel;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::CnrConfig)
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::FrequencyPlanningData)
|
||||
Executable → Regular
+425
-443
File diff suppressed because it is too large.
Load diff
Executable → Regular
+68
-82
@@ -1,19 +1,17 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <boost/optional.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -25,7 +23,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -34,90 +32,78 @@ class EditCombatNetRadioDialog;
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class EditCombatNetRadioDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ModifyCnrConfigReplyHandler
|
||||
class EditCombatNetRadioDialog : public LtsWidgets::LtsDialog, protected Interface::Ftc::ModifyCnrConfigReplyHandler
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EditCombatNetRadioDialog(int32_t exerciseId, LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc, QWidget* parent);
|
||||
|
||||
explicit EditCombatNetRadioDialog(int32_t exerciseId,
|
||||
LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
QWidget *parent);
|
||||
explicit EditCombatNetRadioDialog(const CnrConfig& cnrConfig, int32_t exerciseId, LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc, QWidget* parent);
|
||||
|
||||
|
||||
~EditCombatNetRadioDialog();
|
||||
|
||||
explicit EditCombatNetRadioDialog(const CnrConfig &cnrConfig,
|
||||
int32_t exerciseId,
|
||||
LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
QWidget *parent);
|
||||
void retranslate() override;
|
||||
|
||||
~EditCombatNetRadioDialog();
|
||||
void onModifyCnrConfigReply(const Core::FunctionReplyObject& replyObject) override final
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void retranslate() override;
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool apply() override;
|
||||
|
||||
void onModifyCnrConfigReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
|
||||
private:
|
||||
EditCombatNetRadioDialog(const boost::optional<int32_t>& id, int32_t exerciseId, LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc, ExerciseManagement::Interface::Dtc* exmDtc,
|
||||
QWidget* parent);
|
||||
|
||||
protected:
|
||||
void init(LtsSession::LtsSession* session);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool apply() override;
|
||||
void initCbChannelsForCreate();
|
||||
void initCbChannels(int channelId);
|
||||
void updateFreeChannelsAndTakenNames();
|
||||
void updateCbChannels(QVector<int>&& freeChannels, QMap<int, QString>&& channelsToDisable);
|
||||
QVector<int> exercisesToConsider() const;
|
||||
QVector<int> exercisesToIgnore() const;
|
||||
bool isNameValid(const QString& name) const;
|
||||
|
||||
private:
|
||||
EditCombatNetRadioDialog(const boost::optional<int32_t> &id,
|
||||
int32_t exerciseId,
|
||||
LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
QWidget *parent);
|
||||
QByteArray cnrConfigRequestToJson();
|
||||
ModifyCnrConfigRequest createRequest();
|
||||
ModifyCnrConfigRequest jsonToModifyCnrConfig(const QByteArray& content);
|
||||
void setUiValues(const CnrConfig& cnrConfig);
|
||||
void setUiValuesForGlobal();
|
||||
|
||||
void init(LtsSession::LtsSession *session);
|
||||
private Q_SLOTS:
|
||||
void onPartyIndexChanged(int index);
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
void onChannelChanged(int index);
|
||||
|
||||
void initCbChannelsForCreate();
|
||||
void initCbChannels(int channelId);
|
||||
void updateFreeChannelsAndTakenNames();
|
||||
void updateCbChannels(QVector<int> &&freeChannels, QMap<int, QString> &&channelsToDisable);
|
||||
QVector<int> exercisesToConsider() const;
|
||||
QVector<int> exercisesToIgnore() const;
|
||||
bool isNameValid(const QString &name) const;
|
||||
|
||||
QByteArray cnrConfigRequestToJson();
|
||||
ModifyCnrConfigRequest createRequest();
|
||||
ModifyCnrConfigRequest jsonToModifyCnrConfig(const QByteArray &content);
|
||||
void setUiValues(const CnrConfig &cnrConfig);
|
||||
void setUiValuesForGlobal();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onPartyIndexChanged(int index);
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
void onChannelChanged(int index);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::EditCombatNetRadioDialog> m_ui;
|
||||
boost::optional<int32_t> m_id;
|
||||
int32_t m_exerciseId;
|
||||
boost::optional<int32_t> m_channelId;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
ExerciseManagement::Interface::Dtc *m_exmDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
QMap<int32_t, ParticipantManagement::Participant> m_units;
|
||||
QVector<QString> m_takenNames;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
bool m_isGlobal;
|
||||
};
|
||||
}
|
||||
private:
|
||||
std::unique_ptr<Ui::EditCombatNetRadioDialog> m_ui;
|
||||
boost::optional<int32_t> m_id;
|
||||
int32_t m_exerciseId;
|
||||
boost::optional<int32_t> m_channelId;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
ExerciseManagement::Interface::Dtc* m_exmDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
QMap<int32_t, ParticipantManagement::Participant> m_units;
|
||||
QVector<QString> m_takenNames;
|
||||
std::unique_ptr<LtsUtils::RequestHelper> m_requestHelper;
|
||||
bool m_isGlobal;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+21
-25
@@ -1,11 +1,10 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -23,7 +22,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -31,36 +30,33 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class LoadCombatNetRadioDialogModel;
|
||||
|
||||
class LoadCombatNetRadioDialog
|
||||
: public LtsWidgets::LtsFramelessDialog
|
||||
class LoadCombatNetRadioDialog : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoadCombatNetRadioDialog(const QByteArray &data,
|
||||
LtsSession::LtsSession *session,
|
||||
QWidget *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoadCombatNetRadioDialog(const QByteArray& data, LtsSession::LtsSession* session,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
~LoadCombatNetRadioDialog();
|
||||
~LoadCombatNetRadioDialog();
|
||||
|
||||
QVector<Core::RemoveElementRequest> removeRequests() const;
|
||||
QVector<ModifyCnrConfigRequest> modifyRequests() const;
|
||||
QVector<Core::RemoveElementRequest> removeRequests() const;
|
||||
QVector<ModifyCnrConfigRequest> modifyRequests() const;
|
||||
|
||||
bool isApplied() const;
|
||||
bool isApplied() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOk();
|
||||
private Q_SLOTS:
|
||||
void onOk();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::unique_ptr<Ui::LoadCombatNetRadioDialog> m_ui;
|
||||
LoadCombatNetRadioDialogModel *m_model;
|
||||
bool m_isApplied = false;
|
||||
};
|
||||
}
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::unique_ptr<Ui::LoadCombatNetRadioDialog> m_ui;
|
||||
LoadCombatNetRadioDialogModel* m_model;
|
||||
bool m_isApplied = false;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+287
-302
@@ -1,427 +1,412 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_load_combat_net_radio_dialog_model.h"
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <Core/core.hpp>
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include "avm_cnr_json_helper.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <AudioVideoManagement/avm_data_plugin_interface.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <Core/core.hpp>
|
||||
#include <ExerciseManagement/exm_data_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
LoadCombatNetRadioDialogModel::LoadCombatNetRadioDialogModel(const QByteArray &data,
|
||||
LtsSession::LtsSession *session,
|
||||
QObject *parent)
|
||||
: LtsAbstractTableModel<CnrConfig>(
|
||||
LoadCombatNetRadioDialogModel::LoadCombatNetRadioDialogModel(const QByteArray& data, LtsSession::LtsSession* session,
|
||||
QObject* parent)
|
||||
: LtsAbstractTableModel<CnrConfig>(
|
||||
{tr("Include"), tr("Channel"), tr("Radio Circuit"), tr("Code Word"), tr("Conflict(s)")}, parent),
|
||||
m_exerciseId(session == nullptr ? 0 : session->exerciseId())
|
||||
{
|
||||
tr("Include"),
|
||||
tr("Channel"),
|
||||
tr("Radio Circuit"),
|
||||
tr("Code Word"),
|
||||
tr("Conflict(s)")
|
||||
}, parent)
|
||||
, m_exerciseId(session == nullptr ? 0 : session->exerciseId())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Own exercise id: " << m_exerciseId;
|
||||
DEBUG_LOG(m_logger) << "Own exercise id: " << m_exerciseId;
|
||||
|
||||
if (session != nullptr)
|
||||
{
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> avmDtc;
|
||||
|
||||
if (!session->getDtc<AudioVideoManagement::DataInterface>(avmDtc)
|
||||
|| !avmDtc->enableCnrChannel()
|
||||
|| !avmDtc->enableCnrConfig())
|
||||
ERROR_LOG(m_logger) << "Could not get AVM data";
|
||||
else
|
||||
if (session != nullptr)
|
||||
{
|
||||
m_cnrChannels = avmDtc->cnrChannels();
|
||||
m_cnrConfigs = avmDtc->cnrConfigs();
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> avmDtc;
|
||||
|
||||
if (!session->getDtc<AudioVideoManagement::DataInterface>(avmDtc) || !avmDtc->enableCnrChannel() ||
|
||||
!avmDtc->enableCnrConfig())
|
||||
ERROR_LOG(m_logger) << "Could not get AVM data";
|
||||
else
|
||||
{
|
||||
m_cnrChannels = avmDtc->cnrChannels();
|
||||
m_cnrConfigs = avmDtc->cnrConfigs();
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "cnrconfigs: " << m_cnrConfigs.size();
|
||||
DEBUG_LOG(m_logger) << "ownExerciseId: " << m_exerciseId;
|
||||
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc;
|
||||
|
||||
if (!session->getDtc<ExerciseManagement::DataInterface>(exmDtc) || !exmDtc->enableExercise())
|
||||
ERROR_LOG(m_logger) << "Could not get EXM data";
|
||||
else
|
||||
m_exercises = exmDtc->exercises();
|
||||
|
||||
DEBUG_LOG(m_logger) << "exercises: " << m_exercises.size();
|
||||
}
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Got invalid session.";
|
||||
|
||||
m_vecData = jsonToCnrConfigVector(data);
|
||||
|
||||
m_includeStates.reserve(m_vecData.size());
|
||||
m_conflicts.reserve(m_vecData.size());
|
||||
|
||||
for (int32_t idxCounter = 0; idxCounter < m_vecData.size(); ++idxCounter)
|
||||
{
|
||||
Conflicts conflicts = getConflicts(idxCounter, m_vecData.at(idxCounter));
|
||||
|
||||
m_conflicts.append(conflicts);
|
||||
m_includeStates.append(conflicts == NO_CONFLICT ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_GLOBAL || conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL)
|
||||
m_disabledRows.append(idxCounter);
|
||||
}
|
||||
}
|
||||
|
||||
Qt::ItemFlags LoadCombatNetRadioDialogModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
if (indexIsValid(index) && m_disabledRows.contains(index.row()))
|
||||
return Qt::NoItemFlags;
|
||||
|
||||
if (index.column() > 0)
|
||||
return LtsAbstractTableModel::flags(index);
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | LtsAbstractTableModel::flags(index);
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
if (indexIsValid(index) && role == Qt::CheckStateRole && index.column() == 0 && value.canConvert<Qt::CheckState>())
|
||||
{
|
||||
m_includeStates[index.row()] = value.value<Qt::CheckState>();
|
||||
|
||||
emit dataChanged(index, index, {role});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "cnrconfigs: " << m_cnrConfigs.size();
|
||||
DEBUG_LOG(m_logger) << "ownExerciseId: " << m_exerciseId;
|
||||
|
||||
std::shared_ptr<ExerciseManagement::Interface::Dtc> exmDtc;
|
||||
|
||||
if (!session->getDtc<ExerciseManagement::DataInterface>(exmDtc)
|
||||
|| !exmDtc->enableExercise())
|
||||
ERROR_LOG(m_logger) << "Could not get EXM data";
|
||||
else
|
||||
m_exercises = exmDtc->exercises();
|
||||
|
||||
DEBUG_LOG(m_logger) << "exercises: " << m_exercises.size();
|
||||
}
|
||||
else
|
||||
ERROR_LOG(m_logger) << "Got invalid session.";
|
||||
|
||||
m_vecData = jsonToCnrConfigVector(data);
|
||||
|
||||
m_includeStates.reserve(m_vecData.size());
|
||||
m_conflicts.reserve(m_vecData.size());
|
||||
|
||||
for (int32_t idxCounter = 0; idxCounter < m_vecData.size(); ++idxCounter)
|
||||
{
|
||||
Conflicts conflicts = getConflicts(idxCounter, m_vecData.at(idxCounter));
|
||||
|
||||
m_conflicts.append(conflicts);
|
||||
m_includeStates.append(conflicts == NO_CONFLICT ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_GLOBAL || conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL)
|
||||
m_disabledRows.append(idxCounter);
|
||||
}
|
||||
return QAbstractTableModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
Qt::ItemFlags LoadCombatNetRadioDialogModel::flags(const QModelIndex &index) const
|
||||
QVariant LoadCombatNetRadioDialogModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (indexIsValid(index) && m_disabledRows.contains(index.row()))
|
||||
return Qt::NoItemFlags;
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
if (index.column() > 0)
|
||||
return LtsAbstractTableModel::flags(index);
|
||||
|
||||
return Qt::ItemIsEnabled | Qt::ItemIsUserCheckable | LtsAbstractTableModel::flags(index);
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
if (indexIsValid(index)
|
||||
&& role == Qt::CheckStateRole
|
||||
&& index.column() == 0
|
||||
&& value.canConvert<Qt::CheckState>())
|
||||
{
|
||||
m_includeStates[index.row()] = value.value<Qt::CheckState>();
|
||||
|
||||
emit dataChanged(index, index, {role});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return QAbstractTableModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
QVariant LoadCombatNetRadioDialogModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
const CnrConfig &config = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
switch (role)
|
||||
{
|
||||
case CHANNEL:
|
||||
return QString::fromStdString(m_cnrChannels.value(config.cnrChannelId()).name());
|
||||
case RADIO_CIRCUIT:
|
||||
return QString::fromStdString(config.radioCircuit());
|
||||
case CALL_SIGN:
|
||||
return QString::fromStdString(config.callSign());
|
||||
case CONFLICTS:
|
||||
return conflictsText(m_conflicts.at(index.row()));
|
||||
default:
|
||||
return QVariant();
|
||||
case Qt::DisplayRole: {
|
||||
const CnrConfig& config = m_vecData.at(index.row());
|
||||
switch (index.column())
|
||||
{
|
||||
case CHANNEL:
|
||||
return QString::fromStdString(m_cnrChannels.value(config.cnrChannelId()).name());
|
||||
case RADIO_CIRCUIT:
|
||||
return QString::fromStdString(config.radioCircuit());
|
||||
case CALL_SIGN:
|
||||
return QString::fromStdString(config.callSign());
|
||||
case CONFLICTS:
|
||||
return conflictsText(m_conflicts.at(index.row()));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
case Qt::CheckStateRole:
|
||||
if (index.column() != 0)
|
||||
return QVariant();
|
||||
return m_includeStates.at(index.row());
|
||||
case Qt::BackgroundRole:
|
||||
return getConflictsRowColor(m_conflicts.at(index.row()));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
case Qt::CheckStateRole:
|
||||
if (index.column() != 0)
|
||||
return QVariant();
|
||||
return m_includeStates.at(index.row());
|
||||
case Qt::BackgroundRole:
|
||||
return getConflictsRowColor(m_conflicts.at(index.row()));
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::allChecked() const
|
||||
{
|
||||
for (int32_t row = 0; row < m_includeStates.size(); ++row)
|
||||
{
|
||||
if (m_disabledRows.contains(row))
|
||||
continue;
|
||||
for (int32_t row = 0; row < m_includeStates.size(); ++row)
|
||||
{
|
||||
if (m_disabledRows.contains(row))
|
||||
continue;
|
||||
|
||||
if (m_includeStates.at(row) == Qt::Unchecked)
|
||||
return false;
|
||||
}
|
||||
if (m_includeStates.at(row) == Qt::Unchecked)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void LoadCombatNetRadioDialogModel::setCheckState(bool isChecked)
|
||||
{
|
||||
const QVariant data = QVariant(isChecked ? Qt::Checked : Qt::Unchecked);
|
||||
const int role = Qt::CheckStateRole;
|
||||
const QVariant data = QVariant(isChecked ? Qt::Checked : Qt::Unchecked);
|
||||
const int role = Qt::CheckStateRole;
|
||||
|
||||
for (int32_t row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
if (m_disabledRows.contains(row))
|
||||
continue;
|
||||
for (int32_t row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
if (m_disabledRows.contains(row))
|
||||
continue;
|
||||
|
||||
setData(createIndex(row, 0), data, role);
|
||||
}
|
||||
setData(createIndex(row, 0), data, role);
|
||||
}
|
||||
}
|
||||
|
||||
LoadCombatNetRadioDialogModel::Conflicts LoadCombatNetRadioDialogModel::getConflicts(int32_t row, const CnrConfig &config)
|
||||
LoadCombatNetRadioDialogModel::Conflicts LoadCombatNetRadioDialogModel::getConflicts(int32_t row,
|
||||
const CnrConfig& config)
|
||||
{
|
||||
Conflicts conflicts = NO_CONFLICT;
|
||||
Conflicts conflicts = NO_CONFLICT;
|
||||
|
||||
for (auto it = m_cnrConfigs.constBegin(); it != m_cnrConfigs.constEnd(); ++it)
|
||||
{
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG) && isRadioCircuitTakenInOwnConfig(config, it.value()))
|
||||
for (auto it = m_cnrConfigs.constBegin(); it != m_cnrConfigs.constEnd(); ++it)
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG) && isRadioCircuitTakenInOwnConfig(config, it.value()))
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE) &&
|
||||
isRadioCircuitTakenInAnotherExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_ACTIVE_EXERCISE) && isChannelTakenInActiveExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_ACTIVE_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_LINKED_EXERCISE) && isChannelTakenInLinkedExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_LINKED_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_OWN_CONFIG) && isChannelTakenInOwnConfig(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_OWN_CONFIG;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_GLOBAL) && isChannelTakenInGlobal(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_GLOBAL;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL) && isRadioCircuitTakenInGlobal(config, it.value()))
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_GLOBAL;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
}
|
||||
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE) && isRadioCircuitTakenInAnotherExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_ACTIVE_EXERCISE) && isChannelTakenInActiveExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_ACTIVE_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_LINKED_EXERCISE) && isChannelTakenInLinkedExercise(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_LINKED_EXERCISE;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_OWN_CONFIG) && isChannelTakenInOwnConfig(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_OWN_CONFIG;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & CHANNEL_TAKEN_IN_GLOBAL) && isChannelTakenInGlobal(config, it.value()))
|
||||
{
|
||||
conflicts |= CHANNEL_TAKEN_IN_GLOBAL;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
|
||||
if (!(conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL) && isRadioCircuitTakenInGlobal(config, it.value()))
|
||||
{
|
||||
conflicts |= RADIO_CIRCUIT_TAKEN_IN_GLOBAL;
|
||||
addConflictedCnr(row, it.value().id());
|
||||
}
|
||||
}
|
||||
|
||||
return conflicts;
|
||||
return conflicts;
|
||||
}
|
||||
|
||||
QString LoadCombatNetRadioDialogModel::conflictsText(Conflicts conflicts) const
|
||||
{
|
||||
QStringList conflictTexts;
|
||||
QStringList conflictTexts;
|
||||
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG)
|
||||
conflictTexts.append(tr("Radio Circuit is already taken in own config."));
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG)
|
||||
conflictTexts.append(tr("Radio Circuit is already taken in own config."));
|
||||
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE)
|
||||
conflictTexts.append(tr("Radio Circuit is already taken in another exercise."));
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE)
|
||||
conflictTexts.append(tr("Radio Circuit is already taken in another exercise."));
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_ACTIVE_EXERCISE)
|
||||
conflictTexts.append(tr("Channel already taken in active exercise."));
|
||||
if (conflicts & CHANNEL_TAKEN_IN_ACTIVE_EXERCISE)
|
||||
conflictTexts.append(tr("Channel already taken in active exercise."));
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_LINKED_EXERCISE)
|
||||
conflictTexts.append(tr("Channel already taken in linked exercise."));
|
||||
if (conflicts & CHANNEL_TAKEN_IN_LINKED_EXERCISE)
|
||||
conflictTexts.append(tr("Channel already taken in linked exercise."));
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_OWN_CONFIG)
|
||||
conflictTexts.append(tr("Channel is already taken in own Cnr Config."));
|
||||
if (conflicts & CHANNEL_TAKEN_IN_OWN_CONFIG)
|
||||
conflictTexts.append(tr("Channel is already taken in own Cnr Config."));
|
||||
|
||||
if (conflicts & CHANNEL_TAKEN_IN_GLOBAL)
|
||||
conflictTexts.append(tr("Channel already taken in global Cnr Config."));
|
||||
if (conflicts & CHANNEL_TAKEN_IN_GLOBAL)
|
||||
conflictTexts.append(tr("Channel already taken in global Cnr Config."));
|
||||
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL)
|
||||
conflictTexts.append(tr("Radio Circuit already taken in global Cnr Config."));
|
||||
if (conflicts & RADIO_CIRCUIT_TAKEN_IN_GLOBAL)
|
||||
conflictTexts.append(tr("Radio Circuit already taken in global Cnr Config."));
|
||||
|
||||
return conflictTexts.isEmpty() ? QLatin1String("-") : conflictTexts.join(QLatin1Char('\n'));
|
||||
return conflictTexts.isEmpty() ? QLatin1String("-") : conflictTexts.join(QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
void LoadCombatNetRadioDialogModel::addConflictedCnr(int32_t row, int32_t cnrConfigId)
|
||||
{
|
||||
m_conflictedCnrIds[row].append(cnrConfigId);
|
||||
m_conflictedCnrIds[row].append(cnrConfigId);
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isActiveExercise(int32_t exerciseId) const
|
||||
{
|
||||
if (exerciseId == 0)
|
||||
return true;
|
||||
if (exerciseId == 0)
|
||||
return true;
|
||||
|
||||
using namespace ExerciseManagement;
|
||||
using namespace ExerciseManagement;
|
||||
|
||||
ExerciseState exerciseState = m_exercises.value(exerciseId).state();
|
||||
ExerciseState exerciseState = m_exercises.value(exerciseId).state();
|
||||
|
||||
return exerciseState == ExerciseState::Started || exerciseState == ExerciseState::Paused;
|
||||
return exerciseState == ExerciseState::Started || exerciseState == ExerciseState::Paused;
|
||||
}
|
||||
|
||||
QColor LoadCombatNetRadioDialogModel::getConflictsRowColor(Conflicts conflicts) const
|
||||
{
|
||||
if (conflicts >= CHANNEL_TAKEN_IN_GLOBAL)
|
||||
return QColor(Qt::red).lighter();
|
||||
if (conflicts >= CHANNEL_TAKEN_IN_GLOBAL)
|
||||
return QColor(Qt::red).lighter();
|
||||
|
||||
if (conflicts > NO_CONFLICT)
|
||||
return QColor(Qt::yellow).lighter();
|
||||
if (conflicts > NO_CONFLICT)
|
||||
return QColor(Qt::yellow).lighter();
|
||||
|
||||
return QColor(Qt::green).lighter();
|
||||
return QColor(Qt::green).lighter();
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInOwnConfig(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInOwnConfig(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
if (m_exerciseId == 0)
|
||||
return !existingConfig.exerciseId().is_set() && existingConfig.radioCircuit() == loadConfig.radioCircuit();
|
||||
if (m_exerciseId == 0)
|
||||
return !existingConfig.exerciseId().is_set() && existingConfig.radioCircuit() == loadConfig.radioCircuit();
|
||||
|
||||
if (!existingConfig.exerciseId().is_set()
|
||||
|| existingConfig.exerciseId().get() != m_exerciseId
|
||||
|| existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
if (!existingConfig.exerciseId().is_set() || existingConfig.exerciseId().get() != m_exerciseId ||
|
||||
existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInAnotherExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInAnotherExercise(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
if (!isActiveExercise(m_exerciseId)
|
||||
|| !existingConfig.exerciseId().is_set()
|
||||
|| !isActiveExercise(existingConfig.exerciseId().get())
|
||||
|| existingConfig.exerciseId().get() == m_exerciseId
|
||||
|| existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
if (!isActiveExercise(m_exerciseId) || !existingConfig.exerciseId().is_set() ||
|
||||
!isActiveExercise(existingConfig.exerciseId().get()) || existingConfig.exerciseId().get() == m_exerciseId ||
|
||||
existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInActiveExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInActiveExercise(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
|
||||
if (!isActiveExercise(m_exerciseId)
|
||||
|| exerciseId == 0
|
||||
|| exerciseId == m_exerciseId
|
||||
|| !isActiveExercise(exerciseId)
|
||||
|| existingConfig.cnrChannelId() != loadConfig.cnrChannelId()
|
||||
|| !isActiveExercise(exerciseId))
|
||||
return false;
|
||||
if (!isActiveExercise(m_exerciseId) || exerciseId == 0 || exerciseId == m_exerciseId ||
|
||||
!isActiveExercise(exerciseId) || existingConfig.cnrChannelId() != loadConfig.cnrChannelId() ||
|
||||
!isActiveExercise(exerciseId))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInLinkedExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInLinkedExercise(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
if (m_exerciseId == 0 || m_exercises.value(m_exerciseId).linkedExerciseId() == 0)
|
||||
return false;
|
||||
if (m_exerciseId == 0 || m_exercises.value(m_exerciseId).linkedExerciseId() == 0)
|
||||
return false;
|
||||
|
||||
int32_t linkedExerciseId = m_exercises.value(m_exerciseId).linkedExerciseId();
|
||||
int32_t linkedExerciseId = m_exercises.value(m_exerciseId).linkedExerciseId();
|
||||
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
|
||||
if (exerciseId != linkedExerciseId || existingConfig.cnrChannelId() != loadConfig.cnrChannelId())
|
||||
return false;
|
||||
if (exerciseId != linkedExerciseId || existingConfig.cnrChannelId() != loadConfig.cnrChannelId())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInOwnConfig(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInOwnConfig(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
int32_t exerciseId = existingConfig.exerciseId().is_set() ? existingConfig.exerciseId().get() : 0;
|
||||
|
||||
return existingConfig.cnrChannelId() == loadConfig.cnrChannelId() && exerciseId == m_exerciseId;
|
||||
return existingConfig.cnrChannelId() == loadConfig.cnrChannelId() && exerciseId == m_exerciseId;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInGlobal(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isChannelTakenInGlobal(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
if (!isActiveExercise(m_exerciseId)
|
||||
|| m_exerciseId == 0
|
||||
|| existingConfig.exerciseId().is_set()
|
||||
|| existingConfig.cnrChannelId() != loadConfig.cnrChannelId())
|
||||
return false;
|
||||
if (!isActiveExercise(m_exerciseId) || m_exerciseId == 0 || existingConfig.exerciseId().is_set() ||
|
||||
existingConfig.cnrChannelId() != loadConfig.cnrChannelId())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInGlobal(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const
|
||||
bool LoadCombatNetRadioDialogModel::isRadioCircuitTakenInGlobal(const CnrConfig& loadConfig,
|
||||
const CnrConfig& existingConfig) const
|
||||
{
|
||||
if (!isActiveExercise(m_exerciseId)
|
||||
|| m_exerciseId == 0
|
||||
|| existingConfig.exerciseId().is_set()
|
||||
|| existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
if (!isActiveExercise(m_exerciseId) || m_exerciseId == 0 || existingConfig.exerciseId().is_set() ||
|
||||
existingConfig.radioCircuit() != loadConfig.radioCircuit())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
QVector<Core::RemoveElementRequest> LoadCombatNetRadioDialogModel::removeRequests() const
|
||||
{
|
||||
QVector<Core::RemoveElementRequest> removeRequestsVec;
|
||||
QVector<Core::RemoveElementRequest> removeRequestsVec;
|
||||
|
||||
for (int32_t idxCounter = 0; idxCounter < m_includeStates.size(); ++idxCounter)
|
||||
{
|
||||
if (m_includeStates.at(idxCounter) == Qt::Checked && m_conflicts.at(idxCounter) != NO_CONFLICT)
|
||||
for (int32_t idxCounter = 0; idxCounter < m_includeStates.size(); ++idxCounter)
|
||||
{
|
||||
if (!m_conflictedCnrIds.contains(idxCounter))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Tried to get remove request for row " << idxCounter << " but it is not present.";
|
||||
continue;
|
||||
}
|
||||
if (m_includeStates.at(idxCounter) == Qt::Checked && m_conflicts.at(idxCounter) != NO_CONFLICT)
|
||||
{
|
||||
if (!m_conflictedCnrIds.contains(idxCounter))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Tried to get remove request for row " << idxCounter
|
||||
<< " but it is not present.";
|
||||
continue;
|
||||
}
|
||||
|
||||
const QVector<int32_t> cnrConfigIds = m_conflictedCnrIds.value(idxCounter);
|
||||
const QVector<int32_t> cnrConfigIds = m_conflictedCnrIds.value(idxCounter);
|
||||
|
||||
for (int32_t cnrConfigId : cnrConfigIds)
|
||||
{
|
||||
Core::RemoveElementRequest removeRequest(cnrConfigId);
|
||||
for (int32_t cnrConfigId : cnrConfigIds)
|
||||
{
|
||||
Core::RemoveElementRequest removeRequest(cnrConfigId);
|
||||
|
||||
if (!removeRequestsVec.contains(removeRequest))
|
||||
removeRequestsVec.append(removeRequest);
|
||||
}
|
||||
if (!removeRequestsVec.contains(removeRequest))
|
||||
removeRequestsVec.append(removeRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return removeRequestsVec;
|
||||
return removeRequestsVec;
|
||||
}
|
||||
|
||||
QVector<ModifyCnrConfigRequest> LoadCombatNetRadioDialogModel::modifyRequests() const
|
||||
{
|
||||
const dds::core::optional<int32_t> exerciseId = m_exerciseId == 0 ? dds::core::optional<int32_t>() : dds::core::optional<int32_t>(m_exerciseId);
|
||||
const int32_t partyId = m_exerciseId == 0 ? 1 : 0;
|
||||
QVector<ModifyCnrConfigRequest> modifyRequestsVec;
|
||||
const dds::core::optional<int32_t> exerciseId =
|
||||
m_exerciseId == 0 ? dds::core::optional<int32_t>() : dds::core::optional<int32_t>(m_exerciseId);
|
||||
const int32_t partyId = m_exerciseId == 0 ? 1 : 0;
|
||||
QVector<ModifyCnrConfigRequest> modifyRequestsVec;
|
||||
|
||||
modifyRequestsVec.reserve(m_includeStates.size());
|
||||
modifyRequestsVec.reserve(m_includeStates.size());
|
||||
|
||||
for (int32_t row = 0; row < m_includeStates.size(); ++row)
|
||||
{
|
||||
if (m_includeStates.at(row) != Qt::Checked)
|
||||
continue;
|
||||
for (int32_t row = 0; row < m_includeStates.size(); ++row)
|
||||
{
|
||||
if (m_includeStates.at(row) != Qt::Checked)
|
||||
continue;
|
||||
|
||||
const CnrConfig &cnrConfig = m_vecData.at(row);
|
||||
const CnrConfig& cnrConfig = m_vecData.at(row);
|
||||
|
||||
modifyRequestsVec.append({0,
|
||||
cnrConfig.cnrChannelId(),
|
||||
exerciseId,
|
||||
cnrConfig.radioCircuit(),
|
||||
cnrConfig.recording(),
|
||||
{},
|
||||
partyId,
|
||||
cnrConfig.callSign()});
|
||||
}
|
||||
modifyRequestsVec.append({0,
|
||||
cnrConfig.cnrChannelId(),
|
||||
exerciseId,
|
||||
cnrConfig.radioCircuit(),
|
||||
cnrConfig.recording(),
|
||||
{},
|
||||
partyId,
|
||||
cnrConfig.callSign()});
|
||||
}
|
||||
|
||||
return modifyRequestsVec;
|
||||
return modifyRequestsVec;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+54
-68
@@ -1,14 +1,13 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
|
||||
namespace Core
|
||||
{
|
||||
@@ -21,7 +20,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
@@ -31,83 +30,70 @@ class LtsSession;
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class LoadCombatNetRadioDialogModel final
|
||||
: public LtsWidgets::LtsAbstractTableModel<CnrConfig>
|
||||
class LoadCombatNetRadioDialogModel final : public LtsWidgets::LtsAbstractTableModel<CnrConfig>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
INCLUDE,
|
||||
CHANNEL,
|
||||
RADIO_CIRCUIT,
|
||||
CALL_SIGN,
|
||||
CONFLICTS
|
||||
};
|
||||
public:
|
||||
enum Columns { INCLUDE, CHANNEL, RADIO_CIRCUIT, CALL_SIGN, CONFLICTS };
|
||||
|
||||
enum Conflict
|
||||
{
|
||||
NO_CONFLICT = 0,
|
||||
RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG = 0b00000001,
|
||||
RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE = 0b00000010,
|
||||
CHANNEL_TAKEN_IN_ACTIVE_EXERCISE = 0b00000100,
|
||||
CHANNEL_TAKEN_IN_LINKED_EXERCISE = 0b00001000,
|
||||
CHANNEL_TAKEN_IN_OWN_CONFIG = 0b00010000,
|
||||
enum Conflict {
|
||||
NO_CONFLICT = 0,
|
||||
RADIO_CIRCUIT_TAKEN_IN_OWN_CONFIG = 0b00000001,
|
||||
RADIO_CIRCUIT_TAKEN_IN_ANOTHER_EXERCISE = 0b00000010,
|
||||
CHANNEL_TAKEN_IN_ACTIVE_EXERCISE = 0b00000100,
|
||||
CHANNEL_TAKEN_IN_LINKED_EXERCISE = 0b00001000,
|
||||
CHANNEL_TAKEN_IN_OWN_CONFIG = 0b00010000,
|
||||
|
||||
|
||||
CHANNEL_TAKEN_IN_GLOBAL = 0b00100000,
|
||||
RADIO_CIRCUIT_TAKEN_IN_GLOBAL = 0b01000000,
|
||||
};
|
||||
Q_DECLARE_FLAGS(Conflicts, Conflict)
|
||||
CHANNEL_TAKEN_IN_GLOBAL = 0b00100000,
|
||||
RADIO_CIRCUIT_TAKEN_IN_GLOBAL = 0b01000000,
|
||||
};
|
||||
Q_DECLARE_FLAGS(Conflicts, Conflict)
|
||||
|
||||
explicit LoadCombatNetRadioDialogModel(const QByteArray &data,
|
||||
LtsSession::LtsSession *session,
|
||||
QObject *parent = nullptr);
|
||||
explicit LoadCombatNetRadioDialogModel(const QByteArray& data, LtsSession::LtsSession* session,
|
||||
QObject* parent = nullptr);
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
|
||||
bool allChecked() const;
|
||||
bool allChecked() const;
|
||||
|
||||
QVector<Core::RemoveElementRequest> removeRequests() const;
|
||||
QVector<AudioVideoManagement::ModifyCnrConfigRequest> modifyRequests() const;
|
||||
QVector<Core::RemoveElementRequest> removeRequests() const;
|
||||
QVector<AudioVideoManagement::ModifyCnrConfigRequest> modifyRequests() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setCheckState(bool isChecked);
|
||||
public Q_SLOTS:
|
||||
void setCheckState(bool isChecked);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
LoadCombatNetRadioDialogModel::Conflicts getConflicts(int32_t row, const CnrConfig& config);
|
||||
QString conflictsText(Conflicts conflicts) const;
|
||||
|
||||
bool isRadioCircuitTakenInOwnConfig(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isRadioCircuitTakenInAnotherExercise(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isChannelTakenInActiveExercise(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isChannelTakenInLinkedExercise(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isChannelTakenInOwnConfig(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isChannelTakenInGlobal(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
bool isRadioCircuitTakenInGlobal(const CnrConfig& loadConfig, const CnrConfig& existingConfig) const;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
LoadCombatNetRadioDialogModel::Conflicts getConflicts(int32_t row, const CnrConfig &config);
|
||||
QString conflictsText(Conflicts conflicts) const;
|
||||
void addConflictedCnr(int32_t row, int32_t cnrConfigId);
|
||||
|
||||
bool isRadioCircuitTakenInOwnConfig(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isRadioCircuitTakenInAnotherExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isChannelTakenInActiveExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isChannelTakenInLinkedExercise(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isChannelTakenInOwnConfig(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isChannelTakenInGlobal(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isRadioCircuitTakenInGlobal(const CnrConfig &loadConfig, const CnrConfig &existingConfig) const;
|
||||
bool isActiveExercise(int32_t exerciseId) const;
|
||||
|
||||
void addConflictedCnr(int32_t row, int32_t cnrConfigId);
|
||||
QColor getConflictsRowColor(Conflicts conflicts) const;
|
||||
|
||||
bool isActiveExercise(int32_t exerciseId) const;
|
||||
|
||||
QColor getConflictsRowColor(Conflicts conflicts) const;
|
||||
|
||||
private:
|
||||
int32_t m_exerciseId;
|
||||
QMap<int32_t, CnrChannel> m_cnrChannels;
|
||||
QMap<int32_t, CnrConfig> m_cnrConfigs;
|
||||
QMap<int32_t, ExerciseManagement::Exercise> m_exercises;
|
||||
QMap<int32_t, QVector<int32_t> > m_conflictedCnrIds;
|
||||
QVector<Qt::CheckState> m_includeStates;
|
||||
QVector<int32_t> m_disabledRows;
|
||||
QVector<Conflicts> m_conflicts;
|
||||
private:
|
||||
int32_t m_exerciseId;
|
||||
QMap<int32_t, CnrChannel> m_cnrChannels;
|
||||
QMap<int32_t, CnrConfig> m_cnrConfigs;
|
||||
QMap<int32_t, ExerciseManagement::Exercise> m_exercises;
|
||||
QMap<int32_t, QVector<int32_t>> m_conflictedCnrIds;
|
||||
QVector<Qt::CheckState> m_includeStates;
|
||||
QVector<int32_t> m_disabledRows;
|
||||
QVector<Conflicts> m_conflicts;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+251
-291
@@ -1,422 +1,382 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_edit_frequency_planning_dialog.h"
|
||||
#include <utility>
|
||||
#include "ui_avm_edit_frequency_planning_dialog.h"
|
||||
|
||||
#include "avm_edit_frequency_planning_frequency_data_model.h"
|
||||
#include "avm_load_frequency_planning_dialog.h"
|
||||
#include "ui_avm_edit_frequency_planning_dialog.h"
|
||||
|
||||
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <LtsDataView/lts_data_view.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <LtsDataView/lts_data_view.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include "avm_load_frequency_planning_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <utility>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
bool isActive(ExerciseManagement::ExerciseState state)
|
||||
{
|
||||
return (state == ExerciseManagement::ExerciseState::Started ||
|
||||
state == ExerciseManagement::ExerciseState::Paused);
|
||||
return (state == ExerciseManagement::ExerciseState::Started || state == ExerciseManagement::ExerciseState::Paused);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
EditFrequencyPlanningDialog::EditFrequencyPlanningDialog(LtsSession::LtsSession *session,
|
||||
const QString &menuGroup,
|
||||
const QString &freqPlanningDialogIdentifier,
|
||||
const FrequencyPlanning &planning,
|
||||
const bool copy,
|
||||
const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc,
|
||||
QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_session(session)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_freqPlanningDialogIdentifier(freqPlanningDialogIdentifier)
|
||||
, m_ui(new Ui::EditFrequencyPlanningDialog)
|
||||
, m_planning(planning)
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_avmFtc(avmFtc)
|
||||
, m_ppmDtc(ppmDtc)
|
||||
, m_ismDtc(ismDtc)
|
||||
, m_exmDtc(exmDtc)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_frequencyDataModel(new EditFrequencyPlanningFrequencyDataModel(planning, m_session->exerciseId(), avmDtc, ismDtc, ppmDtc, this))
|
||||
, m_frequencyPlanningId(copy ? 0 : planning.id())
|
||||
, m_exerciseId(session->exerciseId())
|
||||
, m_isEdit(EditFrequencyPlanningSetResourceDialog::DialogMode::Assign)
|
||||
, m_activeFrequencyPlanningStatus(0)
|
||||
EditFrequencyPlanningDialog::EditFrequencyPlanningDialog(
|
||||
LtsSession::LtsSession* session, const QString& menuGroup, const QString& freqPlanningDialogIdentifier,
|
||||
const FrequencyPlanning& planning, const bool copy, const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc, const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc, ExerciseManagement::Interface::Dtc* exmDtc,
|
||||
QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_session(session),
|
||||
m_menuGroup(menuGroup), m_freqPlanningDialogIdentifier(freqPlanningDialogIdentifier),
|
||||
m_ui(new Ui::EditFrequencyPlanningDialog), m_planning(planning), m_avmDtc(avmDtc), m_avmFtc(avmFtc),
|
||||
m_ppmDtc(ppmDtc), m_ismDtc(ismDtc), m_exmDtc(exmDtc), m_requestHelper(new LtsUtils::RequestHelper(this)),
|
||||
m_frequencyDataModel(
|
||||
new EditFrequencyPlanningFrequencyDataModel(planning, m_session->exerciseId(), avmDtc, ismDtc, ppmDtc, this)),
|
||||
m_frequencyPlanningId(copy ? 0 : planning.id()), m_exerciseId(session->exerciseId()),
|
||||
m_isEdit(EditFrequencyPlanningSetResourceDialog::DialogMode::Assign), m_activeFrequencyPlanningStatus(0)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->leName->setText(QString::fromStdString(m_planning.name()));
|
||||
m_ui->lbDate->setText(DTG::toStringMSec(m_planning.date()));
|
||||
m_ui->leName->setText(QString::fromStdString(m_planning.name()));
|
||||
m_ui->lbDate->setText(DTG::toStringMSec(m_planning.date()));
|
||||
|
||||
|
||||
m_uiRequirements->addRequirement( { m_ui->label, [this]() { return !m_ui->leName->text().isEmpty(); } });
|
||||
m_uiRequirements->addRequirement({m_ui->label, [this]() { return !m_ui->leName->text().isEmpty(); }});
|
||||
|
||||
FPFDelegate *treeDelegate = new FPFDelegate(m_frequencyDataModel);
|
||||
m_ui->dvFrequencyData->treeView()->setItemDelegateForColumn(EditFrequencyPlanningFrequencyDataModel::Columns::PROPERTIES, treeDelegate);
|
||||
FPFDelegate* treeDelegate = new FPFDelegate(m_frequencyDataModel);
|
||||
m_ui->dvFrequencyData->treeView()->setItemDelegateForColumn(
|
||||
EditFrequencyPlanningFrequencyDataModel::Columns::PROPERTIES, treeDelegate);
|
||||
|
||||
m_ui->dvFrequencyData->setModel(m_frequencyDataModel);
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
m_ui->dvFrequencyData->setModel(m_frequencyDataModel);
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::RADIO_CIRCUIT_ID);
|
||||
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::RADIO_CIRCUIT_ID);
|
||||
|
||||
#endif
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::AKW_BUNDLE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::AKW_RADIO_CIRCUIT);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::FSB_BUNDLE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::COMSEC);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::DEVICE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::PILOTTON);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::AKW_BUNDLE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::AKW_RADIO_CIRCUIT);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::FSB_BUNDLE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::COMSEC);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::DEVICE);
|
||||
m_ui->dvFrequencyData->hideColumn(EditFrequencyPlanningFrequencyDataModel::Columns::PILOTTON);
|
||||
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &EditFrequencyPlanningDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &EditFrequencyPlanningDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &EditFrequencyPlanningDialog::onPrint);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &EditFrequencyPlanningDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &EditFrequencyPlanningDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &EditFrequencyPlanningDialog::onPrint);
|
||||
|
||||
connect(m_ui->dvFrequencyData, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &EditFrequencyPlanningDialog::enableSelectedUnassignButton);
|
||||
connect(m_ui->dvFrequencyData, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&EditFrequencyPlanningDialog::enableSelectedUnassignButton);
|
||||
|
||||
connect(m_ui->dvFrequencyData, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &EditFrequencyPlanningDialog::onAddClicked);
|
||||
connect(m_ui->dvFrequencyData, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&EditFrequencyPlanningDialog::onAddClicked);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
if (m_frequencyPlanningId == 0)
|
||||
slotChangesMade();
|
||||
if (m_frequencyPlanningId == 0)
|
||||
slotChangesMade();
|
||||
|
||||
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Assign"));
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Remove, tr("Unassign"));
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Assign"));
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Remove, tr("Unassign"));
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&EditFrequencyPlanningDialog::onImportButtonClicked,
|
||||
&EditFrequencyPlanningDialog::onExportButtonClicked);
|
||||
m_buttonBox->connectLibraryButton(this, &EditFrequencyPlanningDialog::onImportButtonClicked,
|
||||
&EditFrequencyPlanningDialog::onExportButtonClicked);
|
||||
|
||||
if (!session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
if (!session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
}
|
||||
|
||||
EditFrequencyPlanningDialog::~EditFrequencyPlanningDialog()
|
||||
|
||||
{
|
||||
emit aboutToCloseMe(m_frequencyPlanningId);
|
||||
emit aboutToCloseMe(m_frequencyPlanningId);
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::retranslate()
|
||||
{
|
||||
translate(m_ui.get(), m_avmDtc->frequencyPlanning(m_frequencyPlanningId), tr("Frequency Planning"));
|
||||
translate(m_ui.get(), m_avmDtc->frequencyPlanning(m_frequencyPlanningId), tr("Frequency Planning"));
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject &reply)
|
||||
void EditFrequencyPlanningDialog::onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject& reply)
|
||||
{
|
||||
if (reply.error())
|
||||
ERROR_LOG(m_logger) << reply.str();
|
||||
m_requestHelper->requestReply(reply);
|
||||
if (reply.error())
|
||||
ERROR_LOG(m_logger) << reply.str();
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onModifyFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject)
|
||||
void EditFrequencyPlanningDialog::onModifyFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
if (!replyObject.error())
|
||||
m_frequencyDataModel->setFrequencePlanningId(replyObject.id());
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
if (!replyObject.error())
|
||||
m_frequencyDataModel->setFrequencePlanningId(replyObject.id());
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
|
||||
bool EditFrequencyPlanningDialog::apply()
|
||||
{
|
||||
if (!m_frequencyDataModel->checkResourceAssignments())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Multiple assignments with the same resource are not possible. Please correct the selected entries."));
|
||||
return false;
|
||||
}
|
||||
ModifyFrequencyPlanningRequest request = m_frequencyDataModel->modifyFrequencyPlanningRequest();
|
||||
if (!m_frequencyDataModel->checkResourceAssignments())
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(
|
||||
this,
|
||||
tr("Multiple assignments with the same resource are not possible. Please correct the selected entries."));
|
||||
return false;
|
||||
}
|
||||
ModifyFrequencyPlanningRequest request = m_frequencyDataModel->modifyFrequencyPlanningRequest();
|
||||
|
||||
request.date(m_session->partitionTime());
|
||||
m_ui->lbDate->setText(DTG::toStringMSec(request.date()));
|
||||
m_planning.date() = request.date();
|
||||
request.id(m_frequencyPlanningId);
|
||||
request.name(m_ui->leName->text().toStdString());
|
||||
request.date(m_session->partitionTime());
|
||||
m_ui->lbDate->setText(DTG::toStringMSec(request.date()));
|
||||
m_planning.date() = request.date();
|
||||
request.id(m_frequencyPlanningId);
|
||||
request.name(m_ui->leName->text().toStdString());
|
||||
|
||||
return m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->modifyFrequencyPlanningRequest(request, this);
|
||||
});
|
||||
return m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->modifyFrequencyPlanningRequest(request, this); });
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onAddClicked()
|
||||
void EditFrequencyPlanningDialog::onAddClicked()
|
||||
{
|
||||
|
||||
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
CnrConfig cnrConfigRow = m_frequencyDataModel->itemData(idx).cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
CnrConfig cnrConfigRow = m_frequencyDataModel->itemData(idx).cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "---RessourceDialog aufrufen...."
|
||||
<< " cnrConfigId: " << cnrConfigId
|
||||
<< " radioCircuit: " << cnrConfigRow.radioCircuit()
|
||||
<< " FrequencySetId: " << m_frequencyDataModel->getFrequencySetId();
|
||||
DEBUG_LOG(m_logger) << "---RessourceDialog aufrufen...."
|
||||
<< " cnrConfigId: " << cnrConfigId << " radioCircuit: " << cnrConfigRow.radioCircuit()
|
||||
<< " FrequencySetId: " << m_frequencyDataModel->getFrequencySetId();
|
||||
|
||||
FrequencyPlanningData fpd = m_frequencyDataModel->getfrequencyPlanningData(cnrConfigId);
|
||||
if (!fpd.cnrConfigId())
|
||||
{
|
||||
fpd.cnrConfigId(cnrConfigId);
|
||||
}
|
||||
|
||||
|
||||
EditFrequencyPlanningResourceDialog *frequencyPlanningResourceDialog
|
||||
= new EditFrequencyPlanningResourceDialog(m_frequencyDataModel->getFrequencySetId(),
|
||||
m_isEdit,
|
||||
this );
|
||||
FrequencyPlanningData fpd = m_frequencyDataModel->getfrequencyPlanningData(cnrConfigId);
|
||||
if (!fpd.cnrConfigId())
|
||||
{
|
||||
fpd.cnrConfigId(cnrConfigId);
|
||||
}
|
||||
|
||||
frequencyPlanningResourceDialog->init(m_session, fpd, m_frequencyDataModel->getAllocatedFrequencyPlanningSetIds());
|
||||
|
||||
connect(this, &QObject::destroyed,
|
||||
frequencyPlanningResourceDialog, &QObject::deleteLater);
|
||||
EditFrequencyPlanningResourceDialog* frequencyPlanningResourceDialog =
|
||||
new EditFrequencyPlanningResourceDialog(m_frequencyDataModel->getFrequencySetId(), m_isEdit, this);
|
||||
|
||||
addDialog(frequencyPlanningResourceDialog, m_menuGroup, QLatin1String("avmFrequencyPlanning") + QString::number(cnrConfigId), LtsWidgets::LayoutArea::eDialogTab);
|
||||
frequencyPlanningResourceDialog->init(m_session, fpd, m_frequencyDataModel->getAllocatedFrequencyPlanningSetIds());
|
||||
|
||||
connect(frequencyPlanningResourceDialog, &EditFrequencyPlanningResourceDialog::signalAssignRadioCircuit,
|
||||
this, &EditFrequencyPlanningDialog::onAssignRadioCircuit);
|
||||
connect(this, &QObject::destroyed, frequencyPlanningResourceDialog, &QObject::deleteLater);
|
||||
|
||||
addDialog(frequencyPlanningResourceDialog, m_menuGroup,
|
||||
QLatin1String("avmFrequencyPlanning") + QString::number(cnrConfigId), LtsWidgets::LayoutArea::eDialogTab);
|
||||
|
||||
connect(frequencyPlanningResourceDialog, &EditFrequencyPlanningResourceDialog::signalAssignRadioCircuit, this,
|
||||
&EditFrequencyPlanningDialog::onAssignRadioCircuit);
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onRemoveClicked()
|
||||
void EditFrequencyPlanningDialog::onRemoveClicked()
|
||||
{
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
CnrConfig cnrConfigRow = m_frequencyDataModel->itemData(idx).cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
unassignRadioCircuit(cnrConfigId);
|
||||
CnrConfig cnrConfigRow = m_frequencyDataModel->itemData(idx).cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
unassignRadioCircuit(cnrConfigId);
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::enableSelectedUnassignButton()
|
||||
{
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
QModelIndex idx = m_ui->dvFrequencyData->currentIndex();
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
auto itemData = m_frequencyDataModel->itemData(idx);
|
||||
CnrConfig cnrConfigRow = itemData.cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
auto itemData = m_frequencyDataModel->itemData(idx);
|
||||
CnrConfig cnrConfigRow = itemData.cnrConfig;
|
||||
int cnrConfigId = cnrConfigRow.id();
|
||||
if (cnrConfigId <= 0)
|
||||
return;
|
||||
|
||||
|
||||
FrequencyPlanningData fpd = m_frequencyDataModel->getfrequencyPlanningData(cnrConfigId);
|
||||
FrequencyPlanningData fpd = m_frequencyDataModel->getfrequencyPlanningData(cnrConfigId);
|
||||
|
||||
QVector<RadioCircuit*> circuits = AudioVideoManagement::fromJson(fpd.properties());
|
||||
QVector<RadioCircuit*> circuits = AudioVideoManagement::fromJson(fpd.properties());
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, true);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, true);
|
||||
|
||||
if( (!cnrConfigRow.exerciseId().is_set()
|
||||
&& m_planning.exerciseId().is_set())
|
||||
||
|
||||
itemData.readOnly
|
||||
)
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Show"));
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Show;
|
||||
if (circuits.size() == 0)
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, false);
|
||||
}
|
||||
else if (circuits.size() > 0)
|
||||
{
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Edit;
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Edit"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Assign;
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Assign"));
|
||||
}
|
||||
if ((!cnrConfigRow.exerciseId().is_set() && m_planning.exerciseId().is_set()) || itemData.readOnly)
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Show"));
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Show;
|
||||
if (circuits.size() == 0)
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, false);
|
||||
}
|
||||
else if (circuits.size() > 0)
|
||||
{
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Edit;
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Edit"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_isEdit = EditFrequencyPlanningSetResourceDialog::DialogMode::Assign;
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Add, tr("Assign"));
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "---enableAssignUnassignButtons()...."
|
||||
<< " cnrConfigId: " << cnrConfigId
|
||||
<< " radioCircuitId: " << cnrConfigRow.radioCircuit();
|
||||
DEBUG_LOG(m_logger) << "---enableAssignUnassignButtons()...."
|
||||
<< " cnrConfigId: " << cnrConfigId << " radioCircuitId: " << cnrConfigRow.radioCircuit();
|
||||
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, !itemData.readOnly && m_isEdit == EditFrequencyPlanningSetResourceDialog::DialogMode::Edit);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove,
|
||||
!itemData.readOnly &&
|
||||
m_isEdit == EditFrequencyPlanningSetResourceDialog::DialogMode::Edit);
|
||||
|
||||
qDeleteAll(circuits);
|
||||
qDeleteAll(circuits);
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onAssignRadioCircuit(const FrequencyPlanningData &fpd)
|
||||
void EditFrequencyPlanningDialog::onAssignRadioCircuit(const FrequencyPlanningData& fpd)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "---onAssignRadioCircuit()...."
|
||||
<< "CnrConfigId: " << fpd.cnrConfigId();
|
||||
<< "CnrConfigId: " << fpd.cnrConfigId();
|
||||
|
||||
m_frequencyDataModel->setFrequencyPlanningData(fpd);
|
||||
|
||||
if (!m_frequencyDataModel->checkResourceAssignments())
|
||||
{
|
||||
|
||||
focusDialog(m_menuGroup, m_freqPlanningDialogIdentifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Multiple assignments with the same resource are not possible. Please correct the selected entries."));
|
||||
return;
|
||||
}
|
||||
enableSelectedUnassignButton();
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->repaint();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
m_frequencyDataModel->setFrequencyPlanningData(fpd);
|
||||
|
||||
if (!m_frequencyDataModel->checkResourceAssignments())
|
||||
{
|
||||
|
||||
focusDialog(m_menuGroup, m_freqPlanningDialogIdentifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
LtsWidgets::LtsMessageDialog::showMessage(
|
||||
this,
|
||||
tr("Multiple assignments with the same resource are not possible. Please correct the selected entries."));
|
||||
return;
|
||||
}
|
||||
enableSelectedUnassignButton();
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->repaint();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dvFrequencyData->treeView() );
|
||||
LtsPrinting::printView(m_session, this, m_ui->dvFrequencyData->treeView());
|
||||
}
|
||||
|
||||
int32_t EditFrequencyPlanningDialog::currentFrequencySetId() const
|
||||
{
|
||||
QModelIndex currentFrequencySetDataIndex = m_ui->dvFrequencyData->currentIndex();
|
||||
QModelIndex currentFrequencySetDataIndex = m_ui->dvFrequencyData->currentIndex();
|
||||
|
||||
if (!currentFrequencySetDataIndex.isValid())
|
||||
return -1;
|
||||
if (!currentFrequencySetDataIndex.isValid())
|
||||
return -1;
|
||||
|
||||
return m_frequencyDataModel->data(currentFrequencySetDataIndex, Qt::UserRole).toInt();
|
||||
return m_frequencyDataModel->data(currentFrequencySetDataIndex, Qt::UserRole).toInt();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QVector<int> EditFrequencyPlanningDialog::otherActiveExercises() const
|
||||
{
|
||||
const auto allExercises_ = m_exmDtc->exercises();
|
||||
const auto allExercises_ = m_exmDtc->exercises();
|
||||
|
||||
Q_ASSERT(::isActive(allExercises_[m_exerciseId].state()));
|
||||
Q_ASSERT(::isActive(allExercises_[m_exerciseId].state()));
|
||||
|
||||
auto allExercises = allExercises_.values();
|
||||
auto newEnd = std::remove_if(allExercises.begin(), allExercises.end(),
|
||||
[](const ExerciseManagement::Exercise& ex) { return ex.isDeleted(); });
|
||||
allExercises.erase(newEnd, allExercises.end());
|
||||
|
||||
auto allExercises = allExercises_.values();
|
||||
auto newEnd = std::remove_if(allExercises.begin(), allExercises.end(), [] (const ExerciseManagement::Exercise &ex) { return ex.isDeleted(); });
|
||||
allExercises.erase(newEnd, allExercises.end());
|
||||
QVector<int> toBeConsidered;
|
||||
for (const auto& exercise : std::as_const(allExercises))
|
||||
{
|
||||
if (exercise.id() == m_exerciseId)
|
||||
continue;
|
||||
|
||||
QVector<int> toBeConsidered;
|
||||
for (const auto &exercise : std::as_const(allExercises))
|
||||
{
|
||||
if (exercise.id() == m_exerciseId)
|
||||
continue;
|
||||
|
||||
if (::isActive(exercise.state()))
|
||||
toBeConsidered.append(exercise.id());
|
||||
}
|
||||
return toBeConsidered;
|
||||
if (::isActive(exercise.state()))
|
||||
toBeConsidered.append(exercise.id());
|
||||
}
|
||||
return toBeConsidered;
|
||||
}
|
||||
|
||||
|
||||
|
||||
QVector<int> EditFrequencyPlanningDialog::otherActivePlans() const
|
||||
{
|
||||
QVector<int> result;
|
||||
QVector<int> exercises = otherActiveExercises();
|
||||
QVector<int> result;
|
||||
QVector<int> exercises = otherActiveExercises();
|
||||
|
||||
const auto activePlans = m_avmDtc->activeFrequencyPlannings();
|
||||
for (const auto &activePlan : activePlans)
|
||||
{
|
||||
if (exercises.contains(activePlan.exerciseId()))
|
||||
result.append(activePlan.frequencyPlanningId());
|
||||
}
|
||||
return result;
|
||||
const auto activePlans = m_avmDtc->activeFrequencyPlannings();
|
||||
for (const auto& activePlan : activePlans)
|
||||
{
|
||||
if (exercises.contains(activePlan.exerciseId()))
|
||||
result.append(activePlan.frequencyPlanningId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::unassignRadioCircuit(int32_t cnrConfigId)
|
||||
{
|
||||
m_frequencyDataModel->unassignRadioCircuit(cnrConfigId);
|
||||
enableSelectedUnassignButton();
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
m_frequencyDataModel->unassignRadioCircuit(cnrConfigId);
|
||||
enableSelectedUnassignButton();
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
}
|
||||
|
||||
void EditFrequencyPlanningDialog::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_frequencyDataModel->uiToJson();
|
||||
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 ";
|
||||
QByteArray byteArray = m_frequencyDataModel->uiToJson();
|
||||
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 EditFrequencyPlanningDialog::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "--- 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::AVMEditFrequencyPlanning));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMEditFrequencyPlanning)))
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMEditFrequencyPlanning));
|
||||
if (fileId > 0)
|
||||
{
|
||||
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);
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMEditFrequencyPlanning)))
|
||||
{
|
||||
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
|
||||
{
|
||||
LoadFrequencyPlanningDialog loadingDialog(content, m_frequencyDataModel->toFrequencyPlanning(), m_avmDtc,
|
||||
m_ismDtc);
|
||||
loadingDialog.exec();
|
||||
|
||||
if (loadingDialog.isApplied())
|
||||
{
|
||||
const QVector<int> unassignments = loadingDialog.unassignments();
|
||||
|
||||
for (int idToUnassign : unassignments)
|
||||
m_frequencyDataModel->unassignRadioCircuit(idToUnassign);
|
||||
|
||||
const QVector<FrequencyPlanningData> planningData = loadingDialog.newPlanningData();
|
||||
|
||||
for (const FrequencyPlanningData& currentData : planningData)
|
||||
m_frequencyDataModel->setFrequencyPlanningData(currentData);
|
||||
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadFrequencyPlanningDialog loadingDialog(content, m_frequencyDataModel->toFrequencyPlanning(), m_avmDtc, m_ismDtc) ;
|
||||
loadingDialog.exec();
|
||||
|
||||
if (loadingDialog.isApplied())
|
||||
{
|
||||
const QVector<int> unassignments = loadingDialog.unassignments();
|
||||
|
||||
for (int idToUnassign : unassignments)
|
||||
m_frequencyDataModel->unassignRadioCircuit(idToUnassign);
|
||||
|
||||
const QVector<FrequencyPlanningData> planningData = loadingDialog.newPlanningData();
|
||||
|
||||
for (const FrequencyPlanningData ¤tData : planningData)
|
||||
m_frequencyDataModel->setFrequencyPlanningData(currentData);
|
||||
|
||||
slotChangesMade();
|
||||
m_ui->dvFrequencyData->expandAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+742
-806
File diff suppressed because it is too large.
Load diff
Executable → Regular
+69
-74
@@ -1,99 +1,94 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_edit_frequency_planning_resource_data_model.h"
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
|
||||
#include <AudioVideoManagement/avm_translation.h>
|
||||
#include <Proxies/CombatNetRadio/Helper/cnr_frequency_planning_helper.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
EditFrequencyPlanningResourceDataModel::EditFrequencyPlanningResourceDataModel(const QSet<int> &assignedFrequencySetDataIds,
|
||||
const FrequencyBand frequencyBand,
|
||||
QObject *parent)
|
||||
: LtsAbstractTableModel<FrequencySetDataWithId>(
|
||||
{
|
||||
tr("FSD id"),
|
||||
tr("Function"),
|
||||
tr("Device"),
|
||||
tr("Frequency"),
|
||||
tr("AKW Bundle"),
|
||||
tr("FSB Bundle"),
|
||||
tr("AKW Radio Circuit"),
|
||||
tr("COMSEC"),
|
||||
}, parent)
|
||||
, m_assignedFrequencySetDataIds(assignedFrequencySetDataIds)
|
||||
, m_frequencyBand(frequencyBand)
|
||||
EditFrequencyPlanningResourceDataModel::EditFrequencyPlanningResourceDataModel(
|
||||
const QSet<int>& assignedFrequencySetDataIds, const FrequencyBand frequencyBand, QObject* parent)
|
||||
: LtsAbstractTableModel<FrequencySetDataWithId>(
|
||||
{
|
||||
tr("FSD id"),
|
||||
tr("Function"),
|
||||
tr("Device"),
|
||||
tr("Frequency"),
|
||||
tr("AKW Bundle"),
|
||||
tr("FSB Bundle"),
|
||||
tr("AKW Radio Circuit"),
|
||||
tr("COMSEC"),
|
||||
},
|
||||
parent),
|
||||
m_assignedFrequencySetDataIds(assignedFrequencySetDataIds), m_frequencyBand(frequencyBand)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant EditFrequencyPlanningResourceDataModel::data(const QModelIndex &index, int role) const
|
||||
QVariant EditFrequencyPlanningResourceDataModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if ((role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
return QVariant();
|
||||
if ((role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const FrequencySetDataWithId &setData = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
QLocale locale(QLocale::German);
|
||||
switch (index.column())
|
||||
const FrequencySetDataWithId& setData = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
case FREQ_SET_DATA_ID:
|
||||
return setData.id();
|
||||
case FUNCTION:
|
||||
return QString::fromStdString(setData.function());
|
||||
case DEVICE:
|
||||
return toString(setData.frequencyBand());
|
||||
case FREQUENCY:
|
||||
return tr("%1 MHz").arg(locale.toString(setData.frequency() / 1000., 'f', 3));
|
||||
case AKW_BUNDLE:
|
||||
if (setData.akwBundle().is_set())
|
||||
return setData.akwBundle().get();
|
||||
return QStringLiteral("-");
|
||||
case FSB_BUNDLE:
|
||||
if (setData.fsbBundle().is_set())
|
||||
return setData.fsbBundle().get();
|
||||
return QStringLiteral("-");
|
||||
case AKW_RADIO_CIRCUIT:
|
||||
if (setData.akwRadioCircuit())
|
||||
return setData.akwRadioCircuit().get();
|
||||
return QStringLiteral("-");
|
||||
case COMSEC:
|
||||
if (setData.comsec().is_set())
|
||||
return setData.comsec().get();
|
||||
return QStringLiteral("-");
|
||||
QLocale locale(QLocale::German);
|
||||
switch (index.column())
|
||||
{
|
||||
case FREQ_SET_DATA_ID:
|
||||
return setData.id();
|
||||
case FUNCTION:
|
||||
return QString::fromStdString(setData.function());
|
||||
case DEVICE:
|
||||
return toString(setData.frequencyBand());
|
||||
case FREQUENCY:
|
||||
return tr("%1 MHz").arg(locale.toString(setData.frequency() / 1000., 'f', 3));
|
||||
case AKW_BUNDLE:
|
||||
if (setData.akwBundle().is_set())
|
||||
return setData.akwBundle().get();
|
||||
return QStringLiteral("-");
|
||||
case FSB_BUNDLE:
|
||||
if (setData.fsbBundle().is_set())
|
||||
return setData.fsbBundle().get();
|
||||
return QStringLiteral("-");
|
||||
case AKW_RADIO_CIRCUIT:
|
||||
if (setData.akwRadioCircuit())
|
||||
return setData.akwRadioCircuit().get();
|
||||
return QStringLiteral("-");
|
||||
case COMSEC:
|
||||
if (setData.comsec().is_set())
|
||||
return setData.comsec().get();
|
||||
return QStringLiteral("-");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return setData.id();
|
||||
else if (role == Qt::UserRole)
|
||||
return setData.id();
|
||||
|
||||
return QVariant();
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool EditFrequencyPlanningResourceDataModel::isFiltered(const AudioVideoManagement::FrequencySetDataWithId &data, DataModification modType) const
|
||||
bool EditFrequencyPlanningResourceDataModel::isFiltered(const AudioVideoManagement::FrequencySetDataWithId& data,
|
||||
DataModification modType) const
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (m_frequencyBand != FrequencyBand_def::REL &&
|
||||
data.frequencyBand() != m_frequencyBand)
|
||||
return true;
|
||||
if (m_frequencyBand != FrequencyBand_def::REL && data.frequencyBand() != m_frequencyBand)
|
||||
return true;
|
||||
|
||||
|
||||
if(m_frequencyBand == FrequencyBand_def::REL &&
|
||||
data.frequencyBand() != FrequencyBand_def::VHF)
|
||||
return true;
|
||||
if (m_frequencyBand == FrequencyBand_def::REL && data.frequencyBand() != FrequencyBand_def::VHF)
|
||||
return true;
|
||||
|
||||
Q_UNUSED(modType);
|
||||
|
||||
if (m_assignedFrequencySetDataIds.contains(data.id()))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "---m_assignments.size(): " << m_assignedFrequencySetDataIds.size()
|
||||
<< " frequencySetDataId: " << data.id() << " ist bereits enthalten";
|
||||
return true;
|
||||
}
|
||||
Q_UNUSED(modType);
|
||||
|
||||
return false;
|
||||
if (m_assignedFrequencySetDataIds.contains(data.id()))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "---m_assignments.size(): " << m_assignedFrequencySetDataIds.size()
|
||||
<< " frequencySetDataId: " << data.id() << " ist bereits enthalten";
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+344
-364
@@ -1,491 +1,471 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_frequency_planning_dialog.h"
|
||||
#include "ui_avm_frequency_planning_dialog.h"
|
||||
#include "avm_frequency_planning_dialog_model.h"
|
||||
|
||||
#include "avm_edit_frequency_planning_dialog.h"
|
||||
#include "avm_frequency_planning_dialog_model.h"
|
||||
#include "avm_init_frequency_planning_dialog.h"
|
||||
#include "ui_avm_frequency_planning_dialog.h"
|
||||
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <AudioVideoManagement/avm_translation.h>
|
||||
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <InfrastructureManagement/ism_dtc.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QMessageBox>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
FrequencyPlanningDialog::FrequencyPlanningDialog(LtsSession::LtsSession *session, const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ui(new Ui::FrequencyPlanningDialog)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_copy(false)
|
||||
, m_session(session)
|
||||
, m_model(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_activePlanning( { -1, -1 })
|
||||
, m_avmDtc(nullptr)
|
||||
, m_avmFtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_ismDtc(nullptr)
|
||||
, m_flmGui(nullptr)
|
||||
, m_activeFrequencyPlanningStatus(0)
|
||||
FrequencyPlanningDialog::FrequencyPlanningDialog(LtsSession::LtsSession* session, const QString& menuGroup,
|
||||
QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_ui(new Ui::FrequencyPlanningDialog),
|
||||
m_menuGroup(menuGroup), m_copy(false), m_session(session), m_model(nullptr),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_activePlanning({-1, -1}), m_avmDtc(nullptr),
|
||||
m_avmFtc(nullptr), m_ppmDtc(nullptr), m_ismDtc(nullptr), m_flmGui(nullptr), m_activeFrequencyPlanningStatus(0)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
DEBUG_LOG(m_logger) << "---FrequencyPlanningDialog() ";
|
||||
m_ui->dataView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_ui->dataView->treeView()->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &FrequencyPlanningDialog::onPrint);
|
||||
DEBUG_LOG(m_logger) << "---FrequencyPlanningDialog() ";
|
||||
m_ui->dataView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_ui->dataView->treeView()->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &FrequencyPlanningDialog::onPrint);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
}
|
||||
|
||||
FrequencyPlanningDialog::~FrequencyPlanningDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Frequency Planning"));
|
||||
translate(m_ui, tr("Frequency Planning"));
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::unsetActiveFrequencyPlanning()
|
||||
{
|
||||
m_ui->lbActiveFrequencyPlanning->setText(tr("No Frequency Planning set"));
|
||||
m_activePlanning = { -1, -1 };
|
||||
m_model->unsetActivePlanning();
|
||||
onSelectionChanged();
|
||||
m_ui->lbActiveFrequencyPlanning->setText(tr("No Frequency Planning set"));
|
||||
m_activePlanning = {-1, -1};
|
||||
m_model->unsetActivePlanning();
|
||||
onSelectionChanged();
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::setActiveFrequencyPlanning(const ActiveFrequencyPlanning &activePlanning)
|
||||
void FrequencyPlanningDialog::setActiveFrequencyPlanning(const ActiveFrequencyPlanning& activePlanning)
|
||||
{
|
||||
m_ui->lbActiveFrequencyPlanning->setText(QString::fromStdString(m_avmDtc->frequencyPlanning(activePlanning.frequencyPlanningId()).name()));
|
||||
m_activePlanning = activePlanning;
|
||||
m_model->setActivePlanning(m_activePlanning.frequencyPlanningId());
|
||||
onSelectionChanged();
|
||||
m_ui->lbActiveFrequencyPlanning->setText(
|
||||
QString::fromStdString(m_avmDtc->frequencyPlanning(activePlanning.frequencyPlanningId()).name()));
|
||||
m_activePlanning = activePlanning;
|
||||
m_model->setActivePlanning(m_activePlanning.frequencyPlanningId());
|
||||
onSelectionChanged();
|
||||
}
|
||||
|
||||
bool FrequencyPlanningDialog::init(const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc)
|
||||
bool FrequencyPlanningDialog::init(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc)
|
||||
{
|
||||
if (!(ppmDtc->enableParty() &&
|
||||
ppmDtc->enableParticipant() &&
|
||||
ppmDtc->enableType() &&
|
||||
avmDtc->enableCnrConfig() &&
|
||||
avmDtc->enableFrequencyPlanning() &&
|
||||
avmDtc->enableFrequencySet() &&
|
||||
avmDtc->enableActiveFrequencyPlanning() &&
|
||||
ismDtc->enableMainStructureElement()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
if (!(ppmDtc->enableParty() && ppmDtc->enableParticipant() && ppmDtc->enableType() && avmDtc->enableCnrConfig() &&
|
||||
avmDtc->enableFrequencyPlanning() && avmDtc->enableFrequencySet() &&
|
||||
avmDtc->enableActiveFrequencyPlanning() && ismDtc->enableMainStructureElement()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
|
||||
delete m_model;
|
||||
m_model = new FrequencyPlanningDialogModel(m_session->exerciseId(), this);
|
||||
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_ismDtc = ismDtc;
|
||||
m_exmDtc = exmDtc;
|
||||
|
||||
if (!m_model->init(avmDtc))
|
||||
{
|
||||
delete m_model;
|
||||
m_model = nullptr;
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
m_model = new FrequencyPlanningDialogModel(m_session->exerciseId(), this);
|
||||
|
||||
m_proxyModel = new FrequencyPlanningDialogProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->dataView->setModel(m_proxyModel);
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_ismDtc = ismDtc;
|
||||
m_exmDtc = exmDtc;
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &FrequencyPlanningDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &FrequencyPlanningDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &FrequencyPlanningDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &FrequencyPlanningDialog::onActivateDeactivatePlanningClicked);
|
||||
if (!m_model->init(avmDtc))
|
||||
{
|
||||
delete m_model;
|
||||
m_model = nullptr;
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &FrequencyPlanningDialog::onSelectionChanged);
|
||||
m_proxyModel = new FrequencyPlanningDialogProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->dataView->setModel(m_proxyModel);
|
||||
|
||||
unsetActiveFrequencyPlanning();
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &FrequencyPlanningDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &FrequencyPlanningDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &FrequencyPlanningDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this,
|
||||
&FrequencyPlanningDialog::onActivateDeactivatePlanningClicked);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&FrequencyPlanningDialog::onSelectionChanged);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &FrequencyPlanningDialog::onEditClicked);
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::activeFrequencyPlanningChanged,
|
||||
this, &FrequencyPlanningDialog::onActiveFrequencyPlanningChanged);
|
||||
unsetActiveFrequencyPlanning();
|
||||
|
||||
m_ui->dataView->hideColumn(FrequencyPlanningDialogModel::Columns::SET);
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&FrequencyPlanningDialog::onEditClicked);
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::activeFrequencyPlanningChanged, this,
|
||||
&FrequencyPlanningDialog::onActiveFrequencyPlanningChanged);
|
||||
|
||||
m_avmDtc->activeFrequencyPlannings([this](const ActiveFrequencyPlanning & data)
|
||||
{
|
||||
onActiveFrequencyPlanningChanged(data, DataModification::eAdded);
|
||||
});
|
||||
onSelectionChanged();
|
||||
m_ui->dataView->hideColumn(FrequencyPlanningDialogModel::Columns::SET);
|
||||
|
||||
setStatus(tr("No active Radio Controller connected."), {}, time(0) * 1000, TransmissionReason::TR_Unknown, Qt::red);
|
||||
for(auto &elem : m_avmDtc->frequencyPlanningStatuss())
|
||||
{
|
||||
if (!elem.isActive())
|
||||
continue;
|
||||
m_activeFrequencyPlanningStatus = elem.id();
|
||||
onFrequencyPlanningStatusChanged(elem, DataModification::eAdded);
|
||||
}
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::frequencyPlanningStatusChanged, this, &FrequencyPlanningDialog::onFrequencyPlanningStatusChanged);
|
||||
m_avmDtc->activeFrequencyPlannings([this](const ActiveFrequencyPlanning& data) {
|
||||
onActiveFrequencyPlanningChanged(data, DataModification::eAdded);
|
||||
});
|
||||
onSelectionChanged();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onFrequencyPlanningStatusChanged(const AudioVideoManagement::FrequencyPlanningStatus &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
if (data.id() != m_activeFrequencyPlanningStatus)
|
||||
return;
|
||||
}
|
||||
else if (modType == DataModification::eRemoved)
|
||||
{
|
||||
if (data.id() != m_activeFrequencyPlanningStatus)
|
||||
return;
|
||||
|
||||
m_activeFrequencyPlanningStatus = 0;
|
||||
setStatus(tr("No active Radio Controller connected."), {}, time(0) * 1000, TransmissionReason::TR_Unknown, Qt::red);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!data.isActive())
|
||||
return;
|
||||
m_activeFrequencyPlanningStatus = data.id();
|
||||
}
|
||||
for (auto& elem : m_avmDtc->frequencyPlanningStatuss())
|
||||
{
|
||||
if (!elem.isActive())
|
||||
continue;
|
||||
m_activeFrequencyPlanningStatus = elem.id();
|
||||
onFrequencyPlanningStatusChanged(elem, DataModification::eAdded);
|
||||
}
|
||||
connect(m_avmDtc.get(), &Interface::Dtc::frequencyPlanningStatusChanged, this,
|
||||
&FrequencyPlanningDialog::onFrequencyPlanningStatusChanged);
|
||||
|
||||
|
||||
|
||||
if (data.activated().is_set())
|
||||
{
|
||||
setStatus(tr("Activated"), QString::fromStdString(data.requester()), data.activated().get(), data.reason(), Qt::green);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.received().is_set())
|
||||
{
|
||||
setStatus(tr("In Progress"), QString::fromStdString(data.requester()), data.received().get(), data.reason(), Qt::yellow);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.sent().is_set())
|
||||
{
|
||||
setStatus(tr("Sent"), QString::fromStdString(data.requester()), data.sent().get(), TransmissionReason::TR_Unknown, Qt::yellow);
|
||||
return;
|
||||
}
|
||||
setStatus(tr("Connection established, status unknown."), {}, time(0) * 1000, TransmissionReason::TR_Unknown, Qt::yellow);
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::setStatus(const QString &statusText, const QString &requester, qint64 timeStampMsecs, TransmissionReason reason, Qt::GlobalColor color)
|
||||
void FrequencyPlanningDialog::onFrequencyPlanningStatusChanged(
|
||||
const AudioVideoManagement::FrequencyPlanningStatus& data, DataModification modType)
|
||||
{
|
||||
m_ui->lblStatus->setText(statusText);
|
||||
m_ui->lblStatusTime->setText(DTG::toStringMSec(timeStampMsecs));
|
||||
m_ui->lblStatus->setToolTip(toString(reason));
|
||||
m_ui->lblStatusTime->setToolTip(requester);
|
||||
setBackgroundColor(m_ui->lblStatus, color, color != Qt::black);
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
if (data.id() != m_activeFrequencyPlanningStatus)
|
||||
return;
|
||||
}
|
||||
else if (modType == DataModification::eRemoved)
|
||||
{
|
||||
if (data.id() != m_activeFrequencyPlanningStatus)
|
||||
return;
|
||||
|
||||
m_activeFrequencyPlanningStatus = 0;
|
||||
setStatus(tr("No active Radio Controller connected."), {}, time(0) * 1000, TransmissionReason::TR_Unknown,
|
||||
Qt::red);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!data.isActive())
|
||||
return;
|
||||
m_activeFrequencyPlanningStatus = data.id();
|
||||
}
|
||||
|
||||
if (data.activated().is_set())
|
||||
{
|
||||
setStatus(tr("Activated"), QString::fromStdString(data.requester()), data.activated().get(), data.reason(),
|
||||
Qt::green);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.received().is_set())
|
||||
{
|
||||
setStatus(tr("In Progress"), QString::fromStdString(data.requester()), data.received().get(), data.reason(),
|
||||
Qt::yellow);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.sent().is_set())
|
||||
{
|
||||
setStatus(tr("Sent"), QString::fromStdString(data.requester()), data.sent().get(),
|
||||
TransmissionReason::TR_Unknown, Qt::yellow);
|
||||
return;
|
||||
}
|
||||
setStatus(tr("Connection established, status unknown."), {}, time(0) * 1000, TransmissionReason::TR_Unknown,
|
||||
Qt::yellow);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::setStatus(const QString& statusText, const QString& requester, qint64 timeStampMsecs,
|
||||
TransmissionReason reason, Qt::GlobalColor color)
|
||||
{
|
||||
m_ui->lblStatus->setText(statusText);
|
||||
m_ui->lblStatusTime->setText(DTG::toStringMSec(timeStampMsecs));
|
||||
m_ui->lblStatus->setToolTip(toString(reason));
|
||||
m_ui->lblStatusTime->setToolTip(requester);
|
||||
setBackgroundColor(m_ui->lblStatus, color, color != Qt::black);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::setBackgroundColor(QWidget *w, Qt::GlobalColor color, bool bSetColor)
|
||||
void FrequencyPlanningDialog::setBackgroundColor(QWidget* w, Qt::GlobalColor color, bool bSetColor)
|
||||
{
|
||||
if (!w)
|
||||
return;
|
||||
if (!w)
|
||||
return;
|
||||
|
||||
if (bSetColor)
|
||||
{
|
||||
QPalette pal = QApplication::palette(w);
|
||||
pal.setColor(QPalette::Window, color);
|
||||
w->setPalette(pal);
|
||||
w->setAutoFillBackground(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
w->setPalette(QApplication::palette(w));
|
||||
w->setAutoFillBackground(false);
|
||||
}
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onModifyFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onRemoveActiveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onModifyActiveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onAddClicked()
|
||||
{
|
||||
const QModelIndexList selectedRows = m_ui->dataView->selectedRows();
|
||||
Q_ASSERT(selectedRows.empty() || selectedRows.size() == 1);
|
||||
QMap<int32_t, FrequencySet> frequencySets = m_avmDtc->frequencySets();
|
||||
if (selectedRows.empty())
|
||||
{
|
||||
if(frequencySets.size() == 1)
|
||||
if (bSetColor)
|
||||
{
|
||||
FrequencyPlanning planning;
|
||||
|
||||
planning.id(0);
|
||||
if(m_session->exerciseId() != 0)
|
||||
planning.exerciseId(m_session->exerciseId());
|
||||
planning.frequencySetId(frequencySets.first().id());
|
||||
planning.date(m_session->partitionTime());
|
||||
showEditDialog(planning);
|
||||
QPalette pal = QApplication::palette(w);
|
||||
pal.setColor(QPalette::Window, color);
|
||||
w->setPalette(pal);
|
||||
w->setAutoFillBackground(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
InitFrequencyPlanningDialog *initDialog = new InitFrequencyPlanningDialog(m_session, m_avmDtc, this);
|
||||
|
||||
connect(initDialog, &InitFrequencyPlanningDialog::newInitFrequencyPlanning,
|
||||
this, &FrequencyPlanningDialog::showEditDialog);
|
||||
w->setPalette(QApplication::palette(w));
|
||||
w->setAutoFillBackground(false);
|
||||
}
|
||||
}
|
||||
|
||||
m_copy = false;
|
||||
addDialog(initDialog, m_menuGroup, QStringLiteral("NewFrequencyPlanning"));
|
||||
void FrequencyPlanningDialog::onModifyFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onRemoveActiveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onModifyActiveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onAddClicked()
|
||||
{
|
||||
const QModelIndexList selectedRows = m_ui->dataView->selectedRows();
|
||||
Q_ASSERT(selectedRows.empty() || selectedRows.size() == 1);
|
||||
QMap<int32_t, FrequencySet> frequencySets = m_avmDtc->frequencySets();
|
||||
if (selectedRows.empty())
|
||||
{
|
||||
if (frequencySets.size() == 1)
|
||||
{
|
||||
FrequencyPlanning planning;
|
||||
|
||||
planning.id(0);
|
||||
if (m_session->exerciseId() != 0)
|
||||
planning.exerciseId(m_session->exerciseId());
|
||||
planning.frequencySetId(frequencySets.first().id());
|
||||
planning.date(m_session->partitionTime());
|
||||
showEditDialog(planning);
|
||||
}
|
||||
else
|
||||
{
|
||||
InitFrequencyPlanningDialog* initDialog = new InitFrequencyPlanningDialog(m_session, m_avmDtc, this);
|
||||
|
||||
connect(initDialog, &InitFrequencyPlanningDialog::newInitFrequencyPlanning, this,
|
||||
&FrequencyPlanningDialog::showEditDialog);
|
||||
|
||||
m_copy = false;
|
||||
addDialog(initDialog, m_menuGroup, QStringLiteral("NewFrequencyPlanning"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_copy = true;
|
||||
qint64 dateOfCreation = m_session->partitionTime();
|
||||
FrequencyPlanning planning = m_model->data(selectedRows.constFirst(), Qt::UserRole).value<FrequencyPlanning>();
|
||||
planning.date(dateOfCreation);
|
||||
showEditDialog(planning);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_copy = true;
|
||||
qint64 dateOfCreation = m_session->partitionTime();
|
||||
FrequencyPlanning planning = m_model->data(selectedRows.constFirst(), Qt::UserRole).value<FrequencyPlanning>();
|
||||
planning.date(dateOfCreation);
|
||||
showEditDialog(planning);
|
||||
}
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onEditClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
const FrequencyPlanning &fp = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>();
|
||||
DEBUG_LOG(m_logger) << "---onEditClicked() FrequencyPlanningId: " << fp.id() << " FrequencySetDataId: " << fp.frequencySetId();
|
||||
const FrequencyPlanning& fp = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>();
|
||||
DEBUG_LOG(m_logger) << "---onEditClicked() FrequencyPlanningId: " << fp.id()
|
||||
<< " FrequencySetDataId: " << fp.frequencySetId();
|
||||
|
||||
m_copy = false;
|
||||
showEditDialog(m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>());
|
||||
m_copy = false;
|
||||
showEditDialog(m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>());
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onRemoveClicked()
|
||||
{
|
||||
const QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
const QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
int planningId = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id();
|
||||
|
||||
if (m_editDlgMap.contains(planningId))
|
||||
{
|
||||
m_editDlgMap.value(planningId)->deleteLater();
|
||||
m_editDlgMap.remove(planningId);
|
||||
}
|
||||
int planningId = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id();
|
||||
|
||||
Core::RemoveElementRequest req;
|
||||
if (m_editDlgMap.contains(planningId))
|
||||
{
|
||||
m_editDlgMap.value(planningId)->deleteLater();
|
||||
m_editDlgMap.remove(planningId);
|
||||
}
|
||||
|
||||
req.id(planningId);
|
||||
Core::RemoveElementRequest req;
|
||||
|
||||
m_requestHelper->startSingleRequest([this, req]()
|
||||
{
|
||||
return m_avmFtc->removeFrequencyPlanningRequest(req, this);
|
||||
});
|
||||
req.id(planningId);
|
||||
|
||||
m_requestHelper->startSingleRequest([this, req]() { return m_avmFtc->removeFrequencyPlanningRequest(req, this); });
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onSelectionChanged()
|
||||
{
|
||||
const QModelIndexList selectedRows = m_ui->dataView->selectedRows();
|
||||
bool hasSelection = !selectedRows.empty();
|
||||
bool selectedIsActive = false;
|
||||
if (hasSelection)
|
||||
{
|
||||
const QModelIndex currentIndex = selectedRows.constFirst();
|
||||
selectedIsActive = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id() == m_activePlanning.frequencyPlanningId();
|
||||
}
|
||||
const QModelIndexList selectedRows = m_ui->dataView->selectedRows();
|
||||
bool hasSelection = !selectedRows.empty();
|
||||
bool selectedIsActive = false;
|
||||
if (hasSelection)
|
||||
{
|
||||
const QModelIndex currentIndex = selectedRows.constFirst();
|
||||
selectedIsActive = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id() ==
|
||||
m_activePlanning.frequencyPlanningId();
|
||||
}
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, hasSelection);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, hasSelection && !selectedIsActive);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, hasSelection && m_session->exerciseId() && m_session->exerciseState() == LtsWidgets::ExcState::eStarted);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, hasSelection);
|
||||
|
||||
if (selectedIsActive)
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Deactivate"));
|
||||
else
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Activate"));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, hasSelection && !selectedIsActive);
|
||||
|
||||
bool disableGlobalPlanning = m_session->exerciseId() == 0 && m_proxyModel->rowCount() !=0;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, !disableGlobalPlanning);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save,
|
||||
hasSelection && m_session->exerciseId() &&
|
||||
m_session->exerciseState() == LtsWidgets::ExcState::eStarted);
|
||||
|
||||
if (selectedIsActive)
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Deactivate"));
|
||||
else
|
||||
m_buttonBox->getButton(LtsWidgets::DialogButton::Save)->setText(tr("Activate"));
|
||||
|
||||
bool disableGlobalPlanning = m_session->exerciseId() == 0 && m_proxyModel->rowCount() != 0;
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, !disableGlobalPlanning);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onActivateDeactivatePlanningClicked()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Frequency Planning"), tr("Are you sure you want to switch the active frequency planning?"),
|
||||
QMessageBox::StandardButtons(QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No))
|
||||
== QMessageBox::StandardButton::No)
|
||||
return;
|
||||
{
|
||||
if (QMessageBox::question(
|
||||
this, tr("Frequency Planning"), tr("Are you sure you want to switch the active frequency planning?"),
|
||||
QMessageBox::StandardButtons(QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No)) ==
|
||||
QMessageBox::StandardButton::No)
|
||||
return;
|
||||
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
int32_t planningId = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id();
|
||||
int32_t planningId = m_model->data(currentIndex, Qt::UserRole).value<FrequencyPlanning>().id();
|
||||
|
||||
bool isActive = planningId == m_activePlanning.frequencyPlanningId();
|
||||
if (!isActive)
|
||||
{
|
||||
ModifyActiveFrequencyPlanningRequest request(m_session->exerciseId(), planningId);
|
||||
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
bool isActive = planningId == m_activePlanning.frequencyPlanningId();
|
||||
if (!isActive)
|
||||
{
|
||||
return m_avmFtc->modifyActiveFrequencyPlanningRequest(request, this);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveActiveFrequencyPlanningRequest request(m_session->exerciseId());
|
||||
ModifyActiveFrequencyPlanningRequest request(m_session->exerciseId(), planningId);
|
||||
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->modifyActiveFrequencyPlanningRequest(request, this); });
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_avmFtc->removeActiveFrequencyPlanningRequest(request, this);
|
||||
});
|
||||
}
|
||||
RemoveActiveFrequencyPlanningRequest request(m_session->exerciseId());
|
||||
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->removeActiveFrequencyPlanningRequest(request, this); });
|
||||
}
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::showEditDialog(const FrequencyPlanning &planning)
|
||||
void FrequencyPlanningDialog::showEditDialog(const FrequencyPlanning& planning)
|
||||
{
|
||||
QString widgetIdentifier(QStringLiteral("FrequencyPlanning%1").arg(QString::number(planning.id())));
|
||||
if (m_copy)
|
||||
widgetIdentifier.append(QStringLiteral("Copy"));
|
||||
QString widgetIdentifier(QStringLiteral("FrequencyPlanning%1").arg(QString::number(planning.id())));
|
||||
if (m_copy)
|
||||
widgetIdentifier.append(QStringLiteral("Copy"));
|
||||
|
||||
if (baseLayoutWidget()->focusTab(menuGroup(), widgetIdentifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
return;
|
||||
EditFrequencyPlanningDialog *dlg = new EditFrequencyPlanningDialog(m_session, m_menuGroup, widgetIdentifier, planning, m_copy, m_avmDtc, m_avmFtc, m_ppmDtc, m_ismDtc, m_exmDtc, this);
|
||||
connect(dlg, &EditFrequencyPlanningDialog::aboutToCloseMe, this , [this](int planningId)
|
||||
{
|
||||
if (planningId <= 0 || !m_editDlgMap.contains(planningId))
|
||||
return;
|
||||
m_editDlgMap.remove(planningId);
|
||||
});
|
||||
if (baseLayoutWidget()->focusTab(menuGroup(), widgetIdentifier, LtsWidgets::LayoutArea::eDialogTab))
|
||||
return;
|
||||
EditFrequencyPlanningDialog* dlg =
|
||||
new EditFrequencyPlanningDialog(m_session, m_menuGroup, widgetIdentifier, planning, m_copy, m_avmDtc, m_avmFtc,
|
||||
m_ppmDtc, m_ismDtc, m_exmDtc, this);
|
||||
connect(dlg, &EditFrequencyPlanningDialog::aboutToCloseMe, this, [this](int planningId) {
|
||||
if (planningId <= 0 || !m_editDlgMap.contains(planningId))
|
||||
return;
|
||||
m_editDlgMap.remove(planningId);
|
||||
});
|
||||
|
||||
addDialog(dlg, m_menuGroup, widgetIdentifier);
|
||||
|
||||
addDialog(dlg, m_menuGroup, widgetIdentifier);
|
||||
|
||||
if (!m_copy)
|
||||
{
|
||||
m_editDlgMap.insert(planning.id(), dlg);
|
||||
}
|
||||
if (!m_copy)
|
||||
{
|
||||
m_editDlgMap.insert(planning.id(), dlg);
|
||||
}
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onActiveFrequencyPlanningChanged(const ActiveFrequencyPlanning &data, DataModification modType)
|
||||
void FrequencyPlanningDialog::onActiveFrequencyPlanningChanged(const ActiveFrequencyPlanning& data,
|
||||
DataModification modType)
|
||||
{
|
||||
if (data.exerciseId() != m_session->exerciseId())
|
||||
return;
|
||||
if (data.exerciseId() != m_session->exerciseId())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
unsetActiveFrequencyPlanning();
|
||||
else
|
||||
setActiveFrequencyPlanning(data);
|
||||
if (modType == DataModification::eRemoved)
|
||||
unsetActiveFrequencyPlanning();
|
||||
else
|
||||
setActiveFrequencyPlanning(data);
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView() );
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
}
|
||||
|
||||
|
||||
void FrequencyPlanningDialog::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_model->modelToJson();
|
||||
QByteArray byteArray = m_model->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 ";
|
||||
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 FrequencyPlanningDialog::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
if (m_model->rowCount() > 0)
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("Only available if the list is empty."),
|
||||
windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal,
|
||||
LtsWidgets::Button::Yes,
|
||||
texts);
|
||||
return;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
if (m_model->rowCount() > 0)
|
||||
{
|
||||
QHash<LtsWidgets::Button, QString> texts({{LtsWidgets::Button::Yes, tr("Ok")}});
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Only available if the list is empty."), windowTitle(),
|
||||
LtsWidgets::Behaviour::Modal, LtsWidgets::Button::Yes, texts);
|
||||
return;
|
||||
}
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(), FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning)))
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning));
|
||||
if (fileId > 0)
|
||||
{
|
||||
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<ModifyFrequencyPlanningRequest> requests = m_model->jsonToFrequencyPlanningVector(content);
|
||||
for (const auto &request : requests)
|
||||
{
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning)))
|
||||
{
|
||||
return m_avmFtc->modifyFrequencyPlanningRequest(request, this);
|
||||
});
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
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<ModifyFrequencyPlanningRequest> requests = m_model->jsonToFrequencyPlanningVector(content);
|
||||
for (const auto& request : requests)
|
||||
{
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->modifyFrequencyPlanningRequest(request, this); });
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+67
-70
@@ -1,14 +1,12 @@
|
||||
|
||||
|
||||
|
||||
#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 <AudioVideoManagement/logger.h>
|
||||
#include <LtsUtilsCore/data_modification_enum.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
@@ -27,7 +25,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
namespace InfrastructureManagement
|
||||
{
|
||||
@@ -35,7 +33,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -43,7 +41,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace LtsSession
|
||||
{
|
||||
@@ -60,71 +58,70 @@ class FrequencyPlanningDialogModel;
|
||||
class FrequencyPlanningDialogProxyModel;
|
||||
class EditFrequencyPlanningDialog;
|
||||
|
||||
class FrequencyPlanningDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ModifyFrequencyPlanningReplyHandler
|
||||
, protected Interface::Ftc::RemoveFrequencyPlanningReplyHandler
|
||||
, protected Interface::Ftc::ModifyActiveFrequencyPlanningReplyHandler
|
||||
, protected Interface::Ftc::RemoveActiveFrequencyPlanningReplyHandler
|
||||
class FrequencyPlanningDialog : public LtsWidgets::LtsDialog,
|
||||
protected Interface::Ftc::ModifyFrequencyPlanningReplyHandler,
|
||||
protected Interface::Ftc::RemoveFrequencyPlanningReplyHandler,
|
||||
protected Interface::Ftc::ModifyActiveFrequencyPlanningReplyHandler,
|
||||
protected Interface::Ftc::RemoveActiveFrequencyPlanningReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FrequencyPlanningDialog(LtsSession::LtsSession *session, const QString &menuGroup, QWidget *parent = nullptr);
|
||||
~FrequencyPlanningDialog();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FrequencyPlanningDialog(LtsSession::LtsSession* session, const QString& menuGroup,
|
||||
QWidget* parent = nullptr);
|
||||
~FrequencyPlanningDialog();
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc> &avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
ExerciseManagement::Interface::Dtc *exmDtc);
|
||||
bool init(const std::shared_ptr<Interface::Dtc>& avmDtc, const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc);
|
||||
|
||||
void onModifyFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onRemoveActiveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onModifyActiveFrequencyPlanningReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onModifyFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
void onRemoveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
void onRemoveActiveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
void onModifyActiveFrequencyPlanningReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onActivateDeactivatePlanningClicked();
|
||||
void showEditDialog(const FrequencyPlanning &planning);
|
||||
void onActiveFrequencyPlanningChanged(const ActiveFrequencyPlanning &data, DataModification modType);
|
||||
void onFrequencyPlanningStatusChanged(const FrequencyPlanningStatus &data, DataModification modType);
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
signals:
|
||||
void aboutToCloseMe(int);
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onActivateDeactivatePlanningClicked();
|
||||
void showEditDialog(const FrequencyPlanning& planning);
|
||||
void onActiveFrequencyPlanningChanged(const ActiveFrequencyPlanning& data, DataModification modType);
|
||||
void onFrequencyPlanningStatusChanged(const FrequencyPlanningStatus& data, DataModification modType);
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
signals:
|
||||
void aboutToCloseMe(int);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void unsetActiveFrequencyPlanning();
|
||||
void setActiveFrequencyPlanning(const ActiveFrequencyPlanning& activePlanning);
|
||||
void setButtonSetActivePlanningEnabled();
|
||||
static void setBackgroundColor(QWidget* w, Qt::GlobalColor color, bool bSetColor);
|
||||
void setStatus(const QString& statusText, const QString& requester, qint64 timeStampMsecs,
|
||||
TransmissionReason reason = TransmissionReason_def::TR_Unknown, Qt::GlobalColor color = Qt::black);
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void unsetActiveFrequencyPlanning();
|
||||
void setActiveFrequencyPlanning(const ActiveFrequencyPlanning &activePlanning);
|
||||
void setButtonSetActivePlanningEnabled();
|
||||
static void setBackgroundColor(QWidget *w, Qt::GlobalColor color, bool bSetColor);
|
||||
void setStatus(const QString &statusText, const QString &requester, qint64 timeStampMsecs, TransmissionReason reason = TransmissionReason_def::TR_Unknown, Qt::GlobalColor color = Qt::black);
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
Ui::FrequencyPlanningDialog *m_ui;
|
||||
QString m_menuGroup;
|
||||
bool m_copy;
|
||||
LtsSession::LtsSession *m_session;
|
||||
FrequencyPlanningDialogModel *m_model;
|
||||
FrequencyPlanningDialogProxyModel *m_proxyModel;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
ActiveFrequencyPlanning m_activePlanning;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
ExerciseManagement::Interface::Dtc *m_exmDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
QMap<int, EditFrequencyPlanningDialog*> m_editDlgMap;
|
||||
int m_activeFrequencyPlanningStatus;
|
||||
};
|
||||
}
|
||||
private:
|
||||
Ui::FrequencyPlanningDialog* m_ui;
|
||||
QString m_menuGroup;
|
||||
bool m_copy;
|
||||
LtsSession::LtsSession* m_session;
|
||||
FrequencyPlanningDialogModel* m_model;
|
||||
FrequencyPlanningDialogProxyModel* m_proxyModel;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
ActiveFrequencyPlanning m_activePlanning;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
ExerciseManagement::Interface::Dtc* m_exmDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
QMap<int, EditFrequencyPlanningDialog*> m_editDlgMap;
|
||||
int m_activeFrequencyPlanningStatus;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+131
-145
@@ -1,197 +1,183 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_frequency_planning_dialog_model.h"
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
FrequencyPlanningDialogModel::FrequencyPlanningDialogModel(int32_t exerciseId, QObject *parent)
|
||||
: LtsAbstractTableModel<FrequencyPlanning>(
|
||||
FrequencyPlanningDialogModel::FrequencyPlanningDialogModel(int32_t exerciseId, QObject* parent)
|
||||
: LtsAbstractTableModel<FrequencyPlanning>({tr("Name"), tr("Date"), tr("Set"), tr("Active")}, parent),
|
||||
m_exerciseId(exerciseId)
|
||||
{
|
||||
tr("Name"),
|
||||
tr("Date"),
|
||||
tr("Set"),
|
||||
tr("Active")
|
||||
}, parent)
|
||||
, m_exerciseId(exerciseId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "---FrequencyPlanningDialogModel() ";
|
||||
DEBUG_LOG(m_logger) << "---FrequencyPlanningDialogModel() ";
|
||||
}
|
||||
|
||||
QVariant FrequencyPlanningDialogModel::data(const QModelIndex &index, int role) const
|
||||
QVariant FrequencyPlanningDialogModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if ((role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
if ((role != Qt::DisplayRole && role != Qt::UserRole) || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const FrequencyPlanning& planning = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case NAME:
|
||||
return QString::fromStdString(planning.name());
|
||||
case DATE:
|
||||
return QDateTime::fromMSecsSinceEpoch(planning.date());
|
||||
case SET: {
|
||||
const FrequencySet frequencySet = m_avmDtc->frequencySet(planning.frequencySetId());
|
||||
return QString::fromStdString(frequencySet.name());
|
||||
}
|
||||
case ACTIVE:
|
||||
return planning.id() == m_activePlanningId ? tr("Active") : QStringLiteral("-");
|
||||
}
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return QVariant::fromValue(planning);
|
||||
|
||||
return QVariant();
|
||||
|
||||
const FrequencyPlanning &planning = m_vecData.at(index.row());
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case NAME:
|
||||
return QString::fromStdString(planning.name());
|
||||
case DATE:
|
||||
return QDateTime::fromMSecsSinceEpoch(planning.date());
|
||||
case SET:
|
||||
{
|
||||
const FrequencySet frequencySet = m_avmDtc->frequencySet(planning.frequencySetId());
|
||||
return QString::fromStdString(frequencySet.name());
|
||||
}
|
||||
case ACTIVE:
|
||||
return planning.id() == m_activePlanningId ? tr("Active") : QStringLiteral("-");
|
||||
}
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return QVariant::fromValue(planning);
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool FrequencyPlanningDialogModel::init(const std::shared_ptr<Interface::Dtc> &avmDtc)
|
||||
bool FrequencyPlanningDialogModel::init(const std::shared_ptr<Interface::Dtc>& avmDtc)
|
||||
{
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmDtc = avmDtc;
|
||||
|
||||
m_frequencySets = m_avmDtc->frequencySets();
|
||||
m_frequencySets = m_avmDtc->frequencySets();
|
||||
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::frequencyPlanningChanged,
|
||||
this, &FrequencyPlanningDialogModel::onFrequencyPlanningChanged);
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::frequencyPlanningChanged, this,
|
||||
&FrequencyPlanningDialogModel::onFrequencyPlanningChanged);
|
||||
|
||||
m_avmDtc->frequencyPlannings([this](const FrequencyPlanning & p)
|
||||
{
|
||||
if (p.exerciseId().is_set() && p.exerciseId().get() == m_exerciseId)
|
||||
insertRow(p);
|
||||
});
|
||||
m_avmDtc->frequencyPlannings([this](const FrequencyPlanning& p) {
|
||||
if (p.exerciseId().is_set() && p.exerciseId().get() == m_exerciseId)
|
||||
insertRow(p);
|
||||
});
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
FrequencySet FrequencyPlanningDialogModel::frequencySetByIndex(const QModelIndex &index) const
|
||||
FrequencySet FrequencyPlanningDialogModel::frequencySetByIndex(const QModelIndex& index) const
|
||||
{
|
||||
if (!indexIsValid(index))
|
||||
return FrequencySet();
|
||||
if (!indexIsValid(index))
|
||||
return FrequencySet();
|
||||
|
||||
return m_frequencySets.value(m_vecData.at(index.row()).frequencySetId());
|
||||
return m_frequencySets.value(m_vecData.at(index.row()).frequencySetId());
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialogModel::onFrequencyPlanningChanged(const FrequencyPlanning &data, DataModification modType)
|
||||
void FrequencyPlanningDialogModel::onFrequencyPlanningChanged(const FrequencyPlanning& data, DataModification modType)
|
||||
{
|
||||
INFO_LOG(m_logger) << "onFrequencyPlanningChanged "
|
||||
<< " data.exerciseId()" << data.exerciseId()
|
||||
<< " m_exerciseId=" << m_exerciseId;
|
||||
if ((data.exerciseId().is_set() && data.exerciseId().get() != m_exerciseId)
|
||||
|| (!data.exerciseId().is_set() && m_exerciseId != 0))
|
||||
return;
|
||||
INFO_LOG(m_logger) << "onFrequencyPlanningChanged "
|
||||
<< " data.exerciseId()" << data.exerciseId() << " m_exerciseId=" << m_exerciseId;
|
||||
if ((data.exerciseId().is_set() && data.exerciseId().get() != m_exerciseId) ||
|
||||
(!data.exerciseId().is_set() && m_exerciseId != 0))
|
||||
return;
|
||||
|
||||
onDataChanged(data, modType);
|
||||
onDataChanged(data, modType);
|
||||
}
|
||||
|
||||
QByteArray FrequencyPlanningDialogModel::modelToJson()
|
||||
{
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
QJsonArray arrData;
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
QJsonArray arrData;
|
||||
|
||||
for (int row = 0; row < rowCount(); row++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
QJsonObject inner;
|
||||
const FrequencyPlanning &planning = m_vecData.at(row);
|
||||
|
||||
inner[QStringLiteral("id")] = planning.id();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(planning.name());
|
||||
inner[QStringLiteral("dateOfCreation")] = planning.date();
|
||||
if(planning.exerciseId().is_set())
|
||||
for (int row = 0; row < rowCount(); row++)
|
||||
{
|
||||
inner[QStringLiteral("exerciseId")] = planning.exerciseId().get();
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
QJsonObject inner;
|
||||
const FrequencyPlanning& planning = m_vecData.at(row);
|
||||
|
||||
inner[QStringLiteral("id")] = planning.id();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(planning.name());
|
||||
inner[QStringLiteral("dateOfCreation")] = planning.date();
|
||||
if (planning.exerciseId().is_set())
|
||||
{
|
||||
inner[QStringLiteral("exerciseId")] = planning.exerciseId().get();
|
||||
}
|
||||
inner[QStringLiteral("frequencySetId")] = planning.frequencySetId();
|
||||
|
||||
arrData = {};
|
||||
for (const FrequencyPlanningData& planningData : planning.data())
|
||||
{
|
||||
QJsonObject innerData;
|
||||
innerData[QStringLiteral("cnrConfigId")] = planningData.cnrConfigId();
|
||||
innerData[QStringLiteral("properties")] = QString::fromStdString(planningData.properties());
|
||||
arrData += innerData;
|
||||
}
|
||||
inner[QStringLiteral("data")] = arrData;
|
||||
arr += inner;
|
||||
}
|
||||
inner[QStringLiteral("frequencySetId")] = planning.frequencySetId();
|
||||
|
||||
arrData = {};
|
||||
for (const FrequencyPlanningData &planningData : planning.data())
|
||||
{
|
||||
QJsonObject innerData;
|
||||
innerData[QStringLiteral("cnrConfigId")] = planningData.cnrConfigId();
|
||||
innerData[QStringLiteral("properties")] = QString::fromStdString(planningData.properties());
|
||||
arrData += innerData;
|
||||
}
|
||||
inner[QStringLiteral("data")] = arrData;
|
||||
arr += inner;
|
||||
}
|
||||
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning);
|
||||
obj[QStringLiteral("FrequencyPlanning")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMFrequencyPlanning);
|
||||
obj[QStringLiteral("FrequencyPlanning")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
QVector<ModifyFrequencyPlanningRequest> FrequencyPlanningDialogModel::jsonToFrequencyPlanningVector(const QByteArray &content)
|
||||
QVector<ModifyFrequencyPlanningRequest>
|
||||
FrequencyPlanningDialogModel::jsonToFrequencyPlanningVector(const QByteArray& content)
|
||||
{
|
||||
QVector<ModifyFrequencyPlanningRequest> result;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject toplevelObj(doc.object());
|
||||
const QJsonArray arr(toplevelObj.value(QStringLiteral("FrequencyPlanning")).toArray());
|
||||
for (const auto &ele : arr)
|
||||
{
|
||||
const QJsonObject obj(ele.toObject());
|
||||
ModifyFrequencyPlanningRequest frequencyPlanning;
|
||||
frequencyPlanning.date(obj[QStringLiteral("dateOfCreation")].toDouble());
|
||||
frequencyPlanning.exerciseId(m_exerciseId);
|
||||
frequencyPlanning.frequencySetId(obj[QStringLiteral("frequencySetId")].toInt());
|
||||
frequencyPlanning.id(0);
|
||||
frequencyPlanning.name(obj[QStringLiteral("name")].toString().toStdString());
|
||||
|
||||
|
||||
const QJsonArray arrData = (obj.value(QStringLiteral("data")).toArray());
|
||||
frequencyPlanning.data().reserve(arrData.size());
|
||||
for (const auto &eleData : arrData)
|
||||
QVector<ModifyFrequencyPlanningRequest> result;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject toplevelObj(doc.object());
|
||||
const QJsonArray arr(toplevelObj.value(QStringLiteral("FrequencyPlanning")).toArray());
|
||||
for (const auto& ele : arr)
|
||||
{
|
||||
const QJsonObject objData(eleData.toObject());
|
||||
FrequencyPlanningData frequencyPlanningData;
|
||||
frequencyPlanningData.cnrConfigId(objData[QStringLiteral("cnrConfigId")].toInt());
|
||||
frequencyPlanningData.properties(objData[QStringLiteral("properties")].toString().toStdString());
|
||||
frequencyPlanning.data().push_back(frequencyPlanningData);
|
||||
const QJsonObject obj(ele.toObject());
|
||||
ModifyFrequencyPlanningRequest frequencyPlanning;
|
||||
frequencyPlanning.date(obj[QStringLiteral("dateOfCreation")].toDouble());
|
||||
frequencyPlanning.exerciseId(m_exerciseId);
|
||||
frequencyPlanning.frequencySetId(obj[QStringLiteral("frequencySetId")].toInt());
|
||||
frequencyPlanning.id(0);
|
||||
frequencyPlanning.name(obj[QStringLiteral("name")].toString().toStdString());
|
||||
|
||||
const QJsonArray arrData = (obj.value(QStringLiteral("data")).toArray());
|
||||
frequencyPlanning.data().reserve(arrData.size());
|
||||
for (const auto& eleData : arrData)
|
||||
{
|
||||
const QJsonObject objData(eleData.toObject());
|
||||
FrequencyPlanningData frequencyPlanningData;
|
||||
frequencyPlanningData.cnrConfigId(objData[QStringLiteral("cnrConfigId")].toInt());
|
||||
frequencyPlanningData.properties(objData[QStringLiteral("properties")].toString().toStdString());
|
||||
frequencyPlanning.data().push_back(frequencyPlanningData);
|
||||
}
|
||||
|
||||
result.push_back(std::move(frequencyPlanning));
|
||||
}
|
||||
|
||||
|
||||
result.push_back(std::move(frequencyPlanning));
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
void FrequencyPlanningDialogProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
void FrequencyPlanningDialogProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<FrequencyPlanningDialogModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
m_sourceModel = qobject_cast<FrequencyPlanningDialogModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool FrequencyPlanningDialogProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
bool FrequencyPlanningDialogProxyModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
!source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
if (!m_sourceModel || source_left.column() != source_right.column() || !source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto& dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case FrequencyPlanningDialogModel::DATE:
|
||||
return dataLeft.date() < dataRight.date();
|
||||
case FrequencyPlanningDialogModel::NAME:
|
||||
case FrequencyPlanningDialogModel::SET:
|
||||
case FrequencyPlanningDialogModel::ACTIVE:
|
||||
case FrequencyPlanningDialogModel::COUNT:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
const auto &dataLeft = m_sourceModel->m_vecData.at(source_left.row());
|
||||
const auto dataRight = m_sourceModel->m_vecData.at(source_right.row());
|
||||
switch (source_left.column())
|
||||
{
|
||||
case FrequencyPlanningDialogModel::DATE:
|
||||
return dataLeft.date() < dataRight.date();
|
||||
case FrequencyPlanningDialogModel::NAME:
|
||||
case FrequencyPlanningDialogModel::SET:
|
||||
case FrequencyPlanningDialogModel::ACTIVE:
|
||||
case FrequencyPlanningDialogModel::COUNT:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+41
-43
@@ -1,73 +1,71 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <boost/optional.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class FrequencyPlanningDialogModel final
|
||||
: public LtsWidgets::LtsAbstractTableModel<FrequencyPlanning>
|
||||
class FrequencyPlanningDialogModel final : public LtsWidgets::LtsAbstractTableModel<FrequencyPlanning>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
NAME,
|
||||
DATE,
|
||||
SET,
|
||||
ACTIVE,
|
||||
COUNT
|
||||
};
|
||||
public:
|
||||
enum Columns { NAME, DATE, SET, ACTIVE, COUNT };
|
||||
|
||||
explicit FrequencyPlanningDialogModel(int32_t exerciseId, QObject *parent = nullptr);
|
||||
explicit FrequencyPlanningDialogModel(int32_t exerciseId, QObject* parent = nullptr);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
QVariant data(const QModelIndex& index, int role) const override final;
|
||||
|
||||
bool init(const std::shared_ptr<Interface::Dtc> &avmDtc);
|
||||
bool init(const std::shared_ptr<Interface::Dtc>& avmDtc);
|
||||
|
||||
void setActivePlanning(int activePlanningId) { m_activePlanningId = activePlanningId; }
|
||||
void unsetActivePlanning() { m_activePlanningId.reset(); }
|
||||
void setActivePlanning(int activePlanningId)
|
||||
{
|
||||
m_activePlanningId = activePlanningId;
|
||||
}
|
||||
|
||||
FrequencySet frequencySetByIndex(const QModelIndex &index) const;
|
||||
QByteArray modelToJson();
|
||||
QVector<ModifyFrequencyPlanningRequest> jsonToFrequencyPlanningVector(const QByteArray &content);
|
||||
void unsetActivePlanning()
|
||||
{
|
||||
m_activePlanningId.reset();
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
void onFrequencyPlanningChanged(const FrequencyPlanning &data, DataModification modType);
|
||||
FrequencySet frequencySetByIndex(const QModelIndex& index) const;
|
||||
QByteArray modelToJson();
|
||||
QVector<ModifyFrequencyPlanningRequest> jsonToFrequencyPlanningVector(const QByteArray& content);
|
||||
|
||||
private:
|
||||
private Q_SLOTS:
|
||||
void onFrequencyPlanningChanged(const FrequencyPlanning& data, DataModification modType);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
int32_t m_exerciseId;
|
||||
boost::optional<int> m_activePlanningId;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
int32_t m_exerciseId;
|
||||
boost::optional<int> m_activePlanningId;
|
||||
std::shared_ptr<Interface::Dtc> m_avmDtc;
|
||||
|
||||
QMap<int32_t, FrequencySet> m_frequencySets;
|
||||
QMap<int32_t, FrequencySet> m_frequencySets;
|
||||
|
||||
friend class FrequencyPlanningDialogProxyModel;
|
||||
};
|
||||
friend class FrequencyPlanningDialogProxyModel;
|
||||
};
|
||||
|
||||
class FrequencyPlanningDialogProxyModel final : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel *sourceModel) override;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override;
|
||||
private:
|
||||
FrequencyPlanningDialogModel *m_sourceModel = nullptr;
|
||||
Q_OBJECT
|
||||
public:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::LtsColumnFilterProxyModel;
|
||||
void setSourceModel(QAbstractItemModel* sourceModel) override;
|
||||
|
||||
protected:
|
||||
bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override;
|
||||
|
||||
private:
|
||||
FrequencyPlanningDialogModel* m_sourceModel = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::FrequencyPlanning)
|
||||
Executable → Regular
+158
-165
@@ -1,238 +1,231 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_frequency_planning_widget.h"
|
||||
#include <LtsWidgets/lts_spinbox.h>
|
||||
#include "ui_avm_frequency_planning_widget.h"
|
||||
|
||||
#include "avm_edit_frequency_planning_set_resource_dialog.h"
|
||||
#include "avm_radio_specifica_hf_widget.h"
|
||||
#include "avm_radio_specifica_vhf_widget.h"
|
||||
#include "avm_radio_specifica_uhf_widget.h"
|
||||
#include "avm_radio_specifica_vhf_widget.h"
|
||||
#include "ui_avm_frequency_planning_widget.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_translation.h>
|
||||
#include <InfrastructureManagement/Gui/IsmComboBox/ism_combobox_gui_plugin.h>
|
||||
|
||||
#include <LtsWidgets/lts_spinbox.h>
|
||||
#include <QJsonArray>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
FrequencyPlanningWidget::FrequencyPlanningWidget(const std::shared_ptr<Interface::Dtc> &avmDtc, QSet<int> &allocatedDataSets, QWidget *parent) : QWidget(parent)
|
||||
, m_ui(new Ui::FrequencyPlanningWidget)
|
||||
, m_assignedFrequencySetDataIds(allocatedDataSets)
|
||||
, m_avmDtc(avmDtc),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
m_ui->setupUi(this);
|
||||
FrequencyPlanningWidget::FrequencyPlanningWidget(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
QSet<int>& allocatedDataSets, QWidget* parent)
|
||||
: QWidget(parent), m_ui(new Ui::FrequencyPlanningWidget), m_assignedFrequencySetDataIds(allocatedDataSets),
|
||||
m_avmDtc(avmDtc), m_logger(NGL::NGLLoggerBootstrap::getLogger())
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::VHF), FrequencyBand_def::VHF);
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::HF), FrequencyBand_def::HF);
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::UHF), FrequencyBand_def::UHF);
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::VHF), FrequencyBand_def::VHF);
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::HF), FrequencyBand_def::HF);
|
||||
m_ui->cbFrequencyBand->addItem(toString(FrequencyBand_def::UHF), FrequencyBand_def::UHF);
|
||||
|
||||
connect(m_ui->leName, &QLineEdit::textChanged,
|
||||
this, &FrequencyPlanningWidget::onNameChanged);
|
||||
connect(m_ui->cbFrequencyBand, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
this, &FrequencyPlanningWidget::onFrequencyBandChanged);
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::cnrConfigChanged,
|
||||
this, &FrequencyPlanningWidget::onCnrConfigChanged);
|
||||
connect(m_ui->leName, &QLineEdit::textChanged, this, &FrequencyPlanningWidget::onNameChanged);
|
||||
connect(m_ui->cbFrequencyBand, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
||||
&FrequencyPlanningWidget::onFrequencyBandChanged);
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::cnrConfigChanged, this,
|
||||
&FrequencyPlanningWidget::onCnrConfigChanged);
|
||||
}
|
||||
|
||||
bool FrequencyPlanningWidget::init(LtsSession::LtsSession *session, RadioCircuit *data, const CnrConfig &cnrConfigId, int frequencySetId, FrequencyBand ft)
|
||||
bool FrequencyPlanningWidget::init(LtsSession::LtsSession* session, RadioCircuit* data, const CnrConfig& cnrConfigId,
|
||||
int frequencySetId, FrequencyBand ft)
|
||||
{
|
||||
m_frequencySetId = frequencySetId;
|
||||
m_cnrConfigId = cnrConfigId.id();
|
||||
m_hasParty = cnrConfigId.partyId() != 0;
|
||||
m_frequencySetId = frequencySetId;
|
||||
m_cnrConfigId = cnrConfigId.id();
|
||||
m_hasParty = cnrConfigId.partyId() != 0;
|
||||
|
||||
if (!session->getForeignGuiInterface<InfrastructureManagement::ForeignGuiComboboxInterface>(m_ismCbxIfc))
|
||||
return false;
|
||||
|
||||
m_ui->cbFrequencyBand->setCurrentIndex(m_ui->cbFrequencyBand->findData(ft.underlying()));
|
||||
m_ui->cbFrequencyBand->setVisible(false);
|
||||
m_ui->lbxFrequencyBand->setVisible(false);
|
||||
|
||||
switch (ft.underlying())
|
||||
{
|
||||
|
||||
case FrequencyBand_def::HF:
|
||||
{
|
||||
createHFWidget(data);
|
||||
break;
|
||||
}
|
||||
case FrequencyBand_def::UHF:
|
||||
{
|
||||
createUHFWidget(data);
|
||||
break;
|
||||
}
|
||||
case FrequencyBand_def::VHF:
|
||||
{
|
||||
createVHFWidget(data);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
ft = data ? data->freqBand : FrequencyBand::VHF;
|
||||
m_isRelay = true;
|
||||
if (!session->getForeignGuiInterface<InfrastructureManagement::ForeignGuiComboboxInterface>(m_ismCbxIfc))
|
||||
return false;
|
||||
|
||||
m_ui->cbFrequencyBand->setCurrentIndex(m_ui->cbFrequencyBand->findData(ft.underlying()));
|
||||
m_ui->cbFrequencyBand->setVisible(true);
|
||||
m_ui->lbxFrequencyBand->setVisible(true);
|
||||
m_ui->cbFrequencyBand->setVisible(false);
|
||||
m_ui->lbxFrequencyBand->setVisible(false);
|
||||
|
||||
switch (ft.underlying())
|
||||
{
|
||||
case FrequencyBand_def::HF:
|
||||
createHFWidget(data);
|
||||
break;
|
||||
case FrequencyBand_def::UHF:
|
||||
createUHFWidget(data);
|
||||
break;
|
||||
case FrequencyBand_def::VHF:
|
||||
createVHFWidget(data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
|
||||
case FrequencyBand_def::HF: {
|
||||
createHFWidget(data);
|
||||
break;
|
||||
}
|
||||
case FrequencyBand_def::UHF: {
|
||||
createUHFWidget(data);
|
||||
break;
|
||||
}
|
||||
case FrequencyBand_def::VHF: {
|
||||
createVHFWidget(data);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ft = data ? data->freqBand : FrequencyBand::VHF;
|
||||
m_isRelay = true;
|
||||
|
||||
m_ui->cbFrequencyBand->setCurrentIndex(m_ui->cbFrequencyBand->findData(ft.underlying()));
|
||||
m_ui->cbFrequencyBand->setVisible(true);
|
||||
m_ui->lbxFrequencyBand->setVisible(true);
|
||||
switch (ft.underlying())
|
||||
{
|
||||
case FrequencyBand_def::HF:
|
||||
createHFWidget(data);
|
||||
break;
|
||||
case FrequencyBand_def::UHF:
|
||||
createUHFWidget(data);
|
||||
break;
|
||||
case FrequencyBand_def::VHF:
|
||||
createVHFWidget(data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_ismCbxIfc->fillRadioStationsComboBox(m_ui->cbRadioStation, ft.underlying());
|
||||
if (m_hasParty && !m_isRelay)
|
||||
m_ui->cbRadioStation->addItem(tr("Automatic"), 0);
|
||||
if (!data)
|
||||
m_ui->leName->clear();
|
||||
else
|
||||
{
|
||||
m_ui->leName->setText(data->name);
|
||||
m_ui->cbRadioStation->setCurrentIndex(m_ui->cbRadioStation->findData(data->radioStationId));
|
||||
}
|
||||
m_ismCbxIfc->fillRadioStationsComboBox(m_ui->cbRadioStation, ft.underlying());
|
||||
if (m_hasParty && !m_isRelay)
|
||||
m_ui->cbRadioStation->addItem(tr("Automatic"), 0);
|
||||
if (!data)
|
||||
m_ui->leName->clear();
|
||||
else
|
||||
{
|
||||
m_ui->leName->setText(data->name);
|
||||
m_ui->cbRadioStation->setCurrentIndex(m_ui->cbRadioStation->findData(data->radioStationId));
|
||||
}
|
||||
|
||||
adjustSize();
|
||||
return true;
|
||||
adjustSize();
|
||||
return true;
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::setNameDisabled(bool disable)
|
||||
{
|
||||
m_ui->leName->setDisabled(disable);
|
||||
m_ui->leName->setDisabled(disable);
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::setName(const QString &name)
|
||||
void FrequencyPlanningWidget::setName(const QString& name)
|
||||
{
|
||||
m_ui->leName->setText(name);
|
||||
m_ui->leName->setText(name);
|
||||
}
|
||||
|
||||
|
||||
void FrequencyPlanningWidget::setRelaisRestrictions(bool restrict)
|
||||
{
|
||||
if (restrict)
|
||||
{
|
||||
m_ui->cbFrequencyBand->setCurrentIndex(m_ui->cbFrequencyBand->findData(FrequencyBand_def::VHF));
|
||||
m_ui->cbFrequencyBand->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->cbFrequencyBand->setEnabled(true);
|
||||
}
|
||||
|
||||
if (restrict)
|
||||
{
|
||||
m_ui->cbFrequencyBand->setCurrentIndex(m_ui->cbFrequencyBand->findData(FrequencyBand_def::VHF));
|
||||
m_ui->cbFrequencyBand->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ui->cbFrequencyBand->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject FrequencyPlanningWidget::toJson() const
|
||||
{
|
||||
return frequencyPlanningJson(m_radioSpecificaWidget->toJson(),
|
||||
m_ui->leName->text(),
|
||||
static_cast<FrequencyBand::inner_enum>(m_ui->cbFrequencyBand->currentData().toInt()),
|
||||
m_ui->cbRadioStation->currentData().toInt());
|
||||
return frequencyPlanningJson(m_radioSpecificaWidget->toJson(), m_ui->leName->text(),
|
||||
static_cast<FrequencyBand::inner_enum>(m_ui->cbFrequencyBand->currentData().toInt()),
|
||||
m_ui->cbRadioStation->currentData().toInt());
|
||||
}
|
||||
|
||||
QVector<QPair<QLabel *, const std::function<bool ()> > > FrequencyPlanningWidget::requirements() const
|
||||
QVector<QPair<QLabel*, const std::function<bool()>>> FrequencyPlanningWidget::requirements() const
|
||||
{
|
||||
return m_radioSpecificaWidget->requirements();
|
||||
return m_radioSpecificaWidget->requirements();
|
||||
}
|
||||
|
||||
FrequencyPlanningWidget::~FrequencyPlanningWidget()
|
||||
{
|
||||
if(m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
delete m_ui;
|
||||
if (m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::onFrequencyBandChanged()
|
||||
{
|
||||
switch (m_ui->cbFrequencyBand->currentData().toInt())
|
||||
{
|
||||
case FrequencyBand_def::HF:
|
||||
createHFWidget();
|
||||
break;
|
||||
case FrequencyBand_def::UHF:
|
||||
createUHFWidget();
|
||||
break;
|
||||
case FrequencyBand_def::VHF:
|
||||
createVHFWidget();
|
||||
break;
|
||||
}
|
||||
switch (m_ui->cbFrequencyBand->currentData().toInt())
|
||||
{
|
||||
case FrequencyBand_def::HF:
|
||||
createHFWidget();
|
||||
break;
|
||||
case FrequencyBand_def::UHF:
|
||||
createUHFWidget();
|
||||
break;
|
||||
case FrequencyBand_def::VHF:
|
||||
createVHFWidget();
|
||||
break;
|
||||
}
|
||||
|
||||
m_ui->cbRadioStation->clear();
|
||||
m_ismCbxIfc->fillRadioStationsComboBox(m_ui->cbRadioStation, m_ui->cbFrequencyBand->currentData().toInt());
|
||||
if(m_hasParty && !m_isRelay)
|
||||
m_ui->cbRadioStation->addItem(tr("Automatic"), 0);
|
||||
m_ui->cbRadioStation->clear();
|
||||
m_ismCbxIfc->fillRadioStationsComboBox(m_ui->cbRadioStation, m_ui->cbFrequencyBand->currentData().toInt());
|
||||
if (m_hasParty && !m_isRelay)
|
||||
m_ui->cbRadioStation->addItem(tr("Automatic"), 0);
|
||||
|
||||
if(m_radioSpecificaWidget)
|
||||
m_ui->gridLayout->addWidget(m_radioSpecificaWidget,5,0,1,2);
|
||||
adjustSize();
|
||||
if (m_radioSpecificaWidget)
|
||||
m_ui->gridLayout->addWidget(m_radioSpecificaWidget, 5, 0, 1, 2);
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::createHFWidget(RadioCircuit* circuit)
|
||||
{
|
||||
if(m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
m_radioSpecificaWidget = new RadioSpecificaHfWidget(m_ui->radioSpecificaWidget);
|
||||
if(!circuit)
|
||||
return;
|
||||
RadioCircuitHF *dataHf = dynamic_cast<RadioCircuitHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataHf);
|
||||
if (m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
m_radioSpecificaWidget = new RadioSpecificaHfWidget(m_ui->radioSpecificaWidget);
|
||||
if (!circuit)
|
||||
return;
|
||||
RadioCircuitHF* dataHf = dynamic_cast<RadioCircuitHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataHf);
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::createUHFWidget(RadioCircuit* circuit)
|
||||
{
|
||||
if(m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
m_radioSpecificaWidget = new RadioSpecificaUhfWidget(m_ui->radioSpecificaWidget);
|
||||
if(!circuit)
|
||||
return;
|
||||
RadioCircuitUHF* dataUhf = dynamic_cast<RadioCircuitUHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataUhf);
|
||||
if (m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
m_radioSpecificaWidget = new RadioSpecificaUhfWidget(m_ui->radioSpecificaWidget);
|
||||
if (!circuit)
|
||||
return;
|
||||
RadioCircuitUHF* dataUhf = dynamic_cast<RadioCircuitUHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataUhf);
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::createVHFWidget(RadioCircuit* circuit)
|
||||
{
|
||||
if(m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
auto *widget = new RadioSpecificaVhfWidget(m_assignedFrequencySetDataIds, m_ui->radioSpecificaWidget);
|
||||
widget->init(m_frequencySetId, m_avmDtc, m_cnrConfigId);
|
||||
m_radioSpecificaWidget = widget;
|
||||
if (m_radioSpecificaWidget)
|
||||
{
|
||||
delete m_radioSpecificaWidget;
|
||||
m_radioSpecificaWidget = nullptr;
|
||||
}
|
||||
auto* widget = new RadioSpecificaVhfWidget(m_assignedFrequencySetDataIds, m_ui->radioSpecificaWidget);
|
||||
widget->init(m_frequencySetId, m_avmDtc, m_cnrConfigId);
|
||||
m_radioSpecificaWidget = widget;
|
||||
|
||||
if(!circuit)
|
||||
return;
|
||||
RadioCircuitVHF* dataVhf = dynamic_cast<RadioCircuitVHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataVhf);
|
||||
if (!circuit)
|
||||
return;
|
||||
RadioCircuitVHF* dataVhf = dynamic_cast<RadioCircuitVHF*>(circuit);
|
||||
m_radioSpecificaWidget->setValues(dataVhf);
|
||||
}
|
||||
|
||||
void FrequencyPlanningWidget::onCnrConfigChanged(const AudioVideoManagement::CnrConfig &config, DataModification modType)
|
||||
void FrequencyPlanningWidget::onCnrConfigChanged(const AudioVideoManagement::CnrConfig& config,
|
||||
DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
if (m_cnrConfigId == config.id())
|
||||
{
|
||||
m_ui->leName->setText(QString::fromStdString(config.radioCircuit()));
|
||||
}
|
||||
Q_UNUSED(modType);
|
||||
if (m_cnrConfigId == config.id())
|
||||
{
|
||||
m_ui->leName->setText(QString::fromStdString(config.radioCircuit()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+32
-36
@@ -1,70 +1,66 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_init_frequency_planning_dialog.h"
|
||||
|
||||
#include "ui_avm_init_frequency_planning_dialog.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
InitFrequencyPlanningDialog::InitFrequencyPlanningDialog(LtsSession::LtsSession *session, const std::shared_ptr<Interface::Dtc> &avmDtc, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkCancel)
|
||||
, m_ui(new Ui::InitFrequencyPlanningDialog)
|
||||
, m_dateOfCreation(session->partitionTime())
|
||||
, m_session(session)
|
||||
InitFrequencyPlanningDialog::InitFrequencyPlanningDialog(LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<Interface::Dtc>& avmDtc, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkCancel), m_ui(new Ui::InitFrequencyPlanningDialog),
|
||||
m_dateOfCreation(session->partitionTime()), m_session(session)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "---InitFrequencyPlanningDialog() ";
|
||||
m_ui->setupUi(this);
|
||||
DEBUG_LOG(m_logger) << "---InitFrequencyPlanningDialog() ";
|
||||
m_ui->setupUi(this);
|
||||
|
||||
QMap<int32_t, FrequencySet> frequencySets = avmDtc->frequencySets();
|
||||
QMap<int32_t, FrequencySet> frequencySets = avmDtc->frequencySets();
|
||||
|
||||
for (auto it = frequencySets.constBegin(); it != frequencySets.constEnd(); ++it)
|
||||
m_ui->cbFrequencySets->addItem(QString::fromStdString(it.value().name()), QVariant::fromValue(it.key()));
|
||||
for (auto it = frequencySets.constBegin(); it != frequencySets.constEnd(); ++it)
|
||||
m_ui->cbFrequencySets->addItem(QString::fromStdString(it.value().name()), QVariant::fromValue(it.key()));
|
||||
|
||||
m_ui->tbTime->setText(DTG::toStringMSec(m_dateOfCreation));
|
||||
|
||||
connect(m_ui->tbTime, &QToolButton::clicked, this, [this]()
|
||||
{
|
||||
m_dateOfCreation = m_session->partitionTime();
|
||||
m_ui->tbTime->setText(DTG::toStringMSec(m_dateOfCreation));
|
||||
});
|
||||
|
||||
m_uiRequirements->addRequirement( { m_ui->lblName, [this]() { return !m_ui->leName->text().isEmpty(); } });
|
||||
m_uiRequirements->addRequirement( { m_ui->lblFrequencySets, [this]() { return !m_ui->cbFrequencySets->currentText().isEmpty(); } });
|
||||
connect(m_ui->tbTime, &QToolButton::clicked, this, [this]() {
|
||||
m_dateOfCreation = m_session->partitionTime();
|
||||
m_ui->tbTime->setText(DTG::toStringMSec(m_dateOfCreation));
|
||||
});
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
m_uiRequirements->addRequirement({m_ui->lblName, [this]() { return !m_ui->leName->text().isEmpty(); }});
|
||||
m_uiRequirements->addRequirement(
|
||||
{m_ui->lblFrequencySets, [this]() { return !m_ui->cbFrequencySets->currentText().isEmpty(); }});
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Frequency_Planning"));
|
||||
}
|
||||
|
||||
|
||||
InitFrequencyPlanningDialog::~InitFrequencyPlanningDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void InitFrequencyPlanningDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("New Frequency Planning"));
|
||||
translate(m_ui, tr("New Frequency Planning"));
|
||||
}
|
||||
|
||||
|
||||
bool InitFrequencyPlanningDialog::apply()
|
||||
{
|
||||
FrequencyPlanning planning;
|
||||
FrequencyPlanning planning;
|
||||
|
||||
planning.id(0);
|
||||
if(m_session->exerciseId() != 0)
|
||||
planning.exerciseId(m_session->exerciseId());
|
||||
planning.frequencySetId(m_ui->cbFrequencySets->currentData().toInt());
|
||||
planning.name(m_ui->leName->text().toStdString());
|
||||
planning.date(m_dateOfCreation);
|
||||
planning.id(0);
|
||||
if (m_session->exerciseId() != 0)
|
||||
planning.exerciseId(m_session->exerciseId());
|
||||
planning.frequencySetId(m_ui->cbFrequencySets->currentData().toInt());
|
||||
planning.name(m_ui->leName->text().toStdString());
|
||||
planning.date(m_dateOfCreation);
|
||||
|
||||
emit newInitFrequencyPlanning(planning);
|
||||
emit newInitFrequencyPlanning(planning);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+18
-20
@@ -1,12 +1,10 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
class QCheckBox;
|
||||
|
||||
@@ -24,23 +22,23 @@ namespace AudioVideoManagement
|
||||
{
|
||||
class InitFrequencyPlanningDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InitFrequencyPlanningDialog(LtsSession::LtsSession *session, const std::shared_ptr<Interface::Dtc> &avmDtc, QWidget *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InitFrequencyPlanningDialog(LtsSession::LtsSession* session, const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
QWidget* parent);
|
||||
|
||||
~InitFrequencyPlanningDialog();
|
||||
~InitFrequencyPlanningDialog();
|
||||
|
||||
signals:
|
||||
void newInitFrequencyPlanning(const FrequencyPlanning &);
|
||||
signals:
|
||||
void newInitFrequencyPlanning(const FrequencyPlanning&);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
bool apply() override;
|
||||
|
||||
Ui::InitFrequencyPlanningDialog *m_ui;
|
||||
qint64 m_dateOfCreation;
|
||||
LtsSession::LtsSession *m_session;
|
||||
};
|
||||
}
|
||||
Ui::InitFrequencyPlanningDialog* m_ui;
|
||||
qint64 m_dateOfCreation;
|
||||
LtsSession::LtsSession* m_session;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+23
-27
@@ -1,11 +1,10 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_frameless_dialog.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -23,7 +22,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace InfrastructureManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -31,38 +30,35 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class LoadFrequencyPlanningDialogModel;
|
||||
|
||||
class LoadFrequencyPlanningDialog
|
||||
: public LtsWidgets::LtsFramelessDialog
|
||||
class LoadFrequencyPlanningDialog : public LtsWidgets::LtsFramelessDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoadFrequencyPlanningDialog(const QByteArray &data,
|
||||
const FrequencyPlanning &initPlan,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc> &ismDtc,
|
||||
QWidget *parent = nullptr);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoadFrequencyPlanningDialog(const QByteArray& data, const FrequencyPlanning& initPlan,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<InfrastructureManagement::Interface::Dtc>& ismDtc,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
~LoadFrequencyPlanningDialog();
|
||||
~LoadFrequencyPlanningDialog();
|
||||
|
||||
QVector<int32_t> unassignments() const;
|
||||
QVector<FrequencyPlanningData> newPlanningData() const;
|
||||
QVector<int32_t> unassignments() const;
|
||||
QVector<FrequencyPlanningData> newPlanningData() const;
|
||||
|
||||
bool isApplied() const;
|
||||
bool isApplied() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOk();
|
||||
private Q_SLOTS:
|
||||
void onOk();
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::unique_ptr<Ui::LoadFrequencyPlanningDialog> m_ui;
|
||||
LoadFrequencyPlanningDialogModel *m_model;
|
||||
bool m_isApplied = false;
|
||||
};
|
||||
}
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::unique_ptr<Ui::LoadFrequencyPlanningDialog> m_ui;
|
||||
LoadFrequencyPlanningDialogModel* m_model;
|
||||
bool m_isApplied = false;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+695
-756
File diff suppressed because it is too large.
Load diff
Executable → Regular
+175
-206
@@ -1,329 +1,298 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_eloka_dialog.h"
|
||||
#include <utility>
|
||||
|
||||
#include "ui_avm_eloka_dialog.h"
|
||||
|
||||
#include <avm_eloka_edit_dialog.h>
|
||||
#include <AudioVideoManagement/ava_session.h>
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/av_helper.h>
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/ava_session.h>
|
||||
#include <AudioVideoManagement/stream_name_mapping.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <QTreeView>
|
||||
#include <avm_eloka_edit_dialog.h>
|
||||
#include <utility>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
ElokaDialog::ElokaDialog(LtsSession::LtsSession *session, AvaSession *avaSession, Interface::Dtc *avmDtc, StreamNameMapping *streamNameMapping,
|
||||
const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ui(new Ui::ElokaDialog)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_elokaModel(new ElokaModel(session, this))
|
||||
, m_session(session)
|
||||
, m_avaSession(avaSession)
|
||||
, m_elokaListCollector(m_avaSession->control()->comm(), [this] (QVector<AvaEloka> &&eloka) { onQueryElokaResponse(std::move(eloka)); })
|
||||
, m_streamNameMapping(streamNameMapping)
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_avaSessionEstablished(false)
|
||||
, m_usedCnr()
|
||||
, m_usedTvc()
|
||||
, m_usedAnnouncement()
|
||||
ElokaDialog::ElokaDialog(LtsSession::LtsSession* session, AvaSession* avaSession, Interface::Dtc* avmDtc,
|
||||
StreamNameMapping* streamNameMapping, const QString& menuGroup, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_ui(new Ui::ElokaDialog),
|
||||
m_menuGroup(menuGroup), m_elokaModel(new ElokaModel(session, this)), m_session(session), m_avaSession(avaSession),
|
||||
m_elokaListCollector(m_avaSession->control()->comm(),
|
||||
[this](QVector<AvaEloka>&& eloka) { onQueryElokaResponse(std::move(eloka)); }),
|
||||
m_streamNameMapping(streamNameMapping), m_avmDtc(avmDtc), m_avaSessionEstablished(false), m_usedCnr(),
|
||||
m_usedTvc(), m_usedAnnouncement()
|
||||
{
|
||||
Q_ASSERT(session);
|
||||
Q_ASSERT(avaSession);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
Q_ASSERT(avmDtc);
|
||||
Q_ASSERT(session);
|
||||
Q_ASSERT(avaSession);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
Q_ASSERT(avmDtc);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_avaSession, &AvaSession::sessionEstablished,
|
||||
this, &ElokaDialog::onAvaSessionEstablished);
|
||||
connect(m_avaSession, &AvaSession::disconnected,
|
||||
this, &ElokaDialog::onAvaSessionDisconnected);
|
||||
connect(m_avaSession, &AvaSession::sessionEstablished, this, &ElokaDialog::onAvaSessionEstablished);
|
||||
connect(m_avaSession, &AvaSession::disconnected, this, &ElokaDialog::onAvaSessionDisconnected);
|
||||
|
||||
m_elokaListCollector.start();
|
||||
m_elokaListCollector.start();
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add,
|
||||
this, &ElokaDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit,
|
||||
this, &ElokaDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove,
|
||||
this, &ElokaDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print,
|
||||
this, &ElokaDialog::onPrint);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &ElokaDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ElokaDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &ElokaDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &ElokaDialog::onPrint);
|
||||
|
||||
m_ui->tvEloka->setModel(m_elokaModel);
|
||||
m_ui->tvEloka->setModel(m_elokaModel);
|
||||
|
||||
connect(m_ui->tvEloka, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &ElokaDialog::onSelectionChanged);
|
||||
onSelectionChanged();
|
||||
connect(m_ui->tvEloka, &LtsDataView::LtsDataView::signalSelectionChanged, this, &ElokaDialog::onSelectionChanged);
|
||||
onSelectionChanged();
|
||||
|
||||
connect(m_ui->tvEloka, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &ElokaDialog::onEditClicked);
|
||||
connect(m_ui->tvEloka, &LtsDataView::LtsDataView::signalDoubleClicked, this, &ElokaDialog::onEditClicked);
|
||||
|
||||
setAvaSessionStatus(m_avaSession->isEstablished());
|
||||
setAvaSessionStatus(m_avaSession->isEstablished());
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Electronic_Warfare_Measures"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Electronic_Warfare_Measures"));
|
||||
}
|
||||
|
||||
ElokaDialog::~ElokaDialog()
|
||||
{
|
||||
delete m_elokaModel;
|
||||
delete m_ui;
|
||||
m_avaSession->control()->queryEloka(AvaQueryElokaMode::Stop);
|
||||
delete m_elokaModel;
|
||||
delete m_ui;
|
||||
m_avaSession->control()->queryEloka(AvaQueryElokaMode::Stop);
|
||||
}
|
||||
|
||||
void ElokaDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Eloka"));
|
||||
translate(m_ui, tr("Eloka"));
|
||||
}
|
||||
|
||||
void ElokaDialog::onAvaSessionEstablished()
|
||||
{
|
||||
setAvaSessionStatus(true);
|
||||
setAvaSessionStatus(true);
|
||||
}
|
||||
|
||||
void ElokaDialog::onAvaSessionDisconnected()
|
||||
{
|
||||
m_elokaListCollector.reset();
|
||||
m_elokaListCollector.start();
|
||||
setAvaSessionStatus(false);
|
||||
m_elokaListCollector.reset();
|
||||
m_elokaListCollector.start();
|
||||
setAvaSessionStatus(false);
|
||||
}
|
||||
|
||||
void ElokaDialog::setAvaSessionStatus(bool established)
|
||||
{
|
||||
m_avaSessionEstablished = established;
|
||||
m_avaSessionEstablished = established;
|
||||
|
||||
|
||||
if (established)
|
||||
m_avaSession->control()->queryEloka(AvaQueryElokaMode::Push);
|
||||
if (established)
|
||||
m_avaSession->control()->queryEloka(AvaQueryElokaMode::Push);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, established);
|
||||
m_ui->lblAvaSessionStatus->setVisible(!established);
|
||||
onSelectionChanged();
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, established);
|
||||
m_ui->lblAvaSessionStatus->setVisible(!established);
|
||||
onSelectionChanged();
|
||||
}
|
||||
|
||||
void ElokaDialog::onAddClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "**** onAddClicked() ";
|
||||
DEBUG_LOG(m_logger) << "**** onAddClicked() ";
|
||||
|
||||
ElokaEditDialog *dialog = new ElokaEditDialog(m_session, m_avaSession, m_avmDtc, m_streamNameMapping,
|
||||
ElokaData(), this);
|
||||
ElokaEditDialog* dialog =
|
||||
new ElokaEditDialog(m_session, m_avaSession, m_avmDtc, m_streamNameMapping, ElokaData(), this);
|
||||
|
||||
connect(dialog, &ElokaEditDialog::signalNewEloka, this,
|
||||
[this](const ElokaData & data)
|
||||
{
|
||||
m_elokaModel->insertRow(data);
|
||||
});
|
||||
connect(dialog, &ElokaEditDialog::signalNewEloka, this,
|
||||
[this](const ElokaData& data) { m_elokaModel->insertRow(data); });
|
||||
|
||||
getUsedRadioCircuits();
|
||||
dialog->init(m_usedCnr, m_usedTvc, m_usedAnnouncement);
|
||||
getUsedRadioCircuits();
|
||||
dialog->init(m_usedCnr, m_usedTvc, m_usedAnnouncement);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("AddEloka"));
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("AddEloka"));
|
||||
}
|
||||
|
||||
void ElokaDialog::onEditClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "**** onEditClicked() ";
|
||||
DEBUG_LOG(m_logger) << "**** onEditClicked() ";
|
||||
|
||||
const QModelIndex idx = m_ui->tvEloka->currentIndex();
|
||||
const QModelIndex idx = m_ui->tvEloka->currentIndex();
|
||||
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
|
||||
const ElokaData data = m_elokaModel->getRowData(idx.row());
|
||||
const ElokaData data = m_elokaModel->getRowData(idx.row());
|
||||
|
||||
ElokaEditDialog *dialog = new ElokaEditDialog(m_session, m_avaSession, m_avmDtc, m_streamNameMapping,
|
||||
data, this);
|
||||
ElokaEditDialog* dialog = new ElokaEditDialog(m_session, m_avaSession, m_avmDtc, m_streamNameMapping, data, this);
|
||||
|
||||
connect(dialog, &ElokaEditDialog::signalNewEloka, this,
|
||||
[ = ](const ElokaData & data)
|
||||
{
|
||||
m_elokaModel->setRowData(idx.row(), data);
|
||||
});
|
||||
connect(dialog, &ElokaEditDialog::signalNewEloka, this,
|
||||
[=](const ElokaData& data) { m_elokaModel->setRowData(idx.row(), data); });
|
||||
|
||||
getUsedRadioCircuits();
|
||||
dialog->init(m_usedCnr, m_usedTvc, m_usedAnnouncement);
|
||||
getUsedRadioCircuits();
|
||||
dialog->init(m_usedCnr, m_usedTvc, m_usedAnnouncement);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditEloka"));
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditEloka"));
|
||||
}
|
||||
|
||||
void ElokaDialog::onRemoveClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "**** onRemoveClicked() ";
|
||||
DEBUG_LOG(m_logger) << "**** onRemoveClicked() ";
|
||||
|
||||
const QModelIndex idx = m_ui->tvEloka->currentIndex();
|
||||
const QModelIndex idx = m_ui->tvEloka->currentIndex();
|
||||
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
m_avaSession->control()->releaseEloka(m_elokaModel->getRowData(idx.row()).internalName);
|
||||
m_elokaModel->removeRow(idx.row());
|
||||
if (!idx.isValid())
|
||||
return;
|
||||
m_avaSession->control()->releaseEloka(m_elokaModel->getRowData(idx.row()).internalName);
|
||||
m_elokaModel->removeRow(idx.row());
|
||||
}
|
||||
|
||||
void ElokaDialog::onSelectionChanged()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->tvEloka->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
QModelIndexList selectedRows = m_ui->tvEloka->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit,
|
||||
cntSelectedRows == 1 && m_avaSessionEstablished);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove,
|
||||
cntSelectedRows > 0 && m_avaSessionEstablished);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add,
|
||||
!(m_elokaModel->rowCount() >= 20));
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1 && m_avaSessionEstablished);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, cntSelectedRows > 0 && m_avaSessionEstablished);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, !(m_elokaModel->rowCount() >= 20));
|
||||
}
|
||||
|
||||
void ElokaDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->tvEloka->treeView() );
|
||||
LtsPrinting::printView(m_session, this, m_ui->tvEloka->treeView());
|
||||
}
|
||||
|
||||
void ElokaDialog::onQueryElokaResponse(const QVector<AvaEloka> &&eloka)
|
||||
void ElokaDialog::onQueryElokaResponse(const QVector<AvaEloka>&& eloka)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onQueryElokaResponse";
|
||||
DEBUG_LOG(m_logger) << "onQueryElokaResponse";
|
||||
|
||||
m_elokaListCollector.start();
|
||||
m_elokaModel->clear();
|
||||
m_elokaListCollector.start();
|
||||
m_elokaModel->clear();
|
||||
|
||||
if (eloka.isEmpty())
|
||||
return;
|
||||
if (eloka.isEmpty())
|
||||
return;
|
||||
|
||||
const auto cnrTvcProfiles = m_avmDtc->cnrTvcProfiles();
|
||||
QMultiMap<qint32, ElokaCircuitType> userProfile;
|
||||
int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
int exerciseId = m_session->exerciseId();
|
||||
const auto cnrTvcProfiles = m_avmDtc->cnrTvcProfiles();
|
||||
QMultiMap<qint32, ElokaCircuitType> userProfile;
|
||||
int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
int exerciseId = m_session->exerciseId();
|
||||
|
||||
for (const auto &cnrTvcProfile : cnrTvcProfiles)
|
||||
{
|
||||
if (cnrTvcProfile.exerciseId() == exerciseId &&
|
||||
cnrTvcProfile.operatorId() == operatorId)
|
||||
for (const auto& cnrTvcProfile : cnrTvcProfiles)
|
||||
{
|
||||
for (const auto &cnrTvcProfileData : cnrTvcProfile.data())
|
||||
{
|
||||
if (cnrTvcProfileData.radioSystemId() == RadioSystem::inner_enum::Cnr)
|
||||
userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Cnr);
|
||||
else
|
||||
userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Tvc);
|
||||
}
|
||||
if (cnrTvcProfile.exerciseId() == exerciseId && cnrTvcProfile.operatorId() == operatorId)
|
||||
{
|
||||
for (const auto& cnrTvcProfileData : cnrTvcProfile.data())
|
||||
{
|
||||
if (cnrTvcProfileData.radioSystemId() == RadioSystem::inner_enum::Cnr)
|
||||
userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Cnr);
|
||||
else
|
||||
userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Tvc);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ElokaData data;
|
||||
for (const auto &elokaData : eloka)
|
||||
{
|
||||
data.internalName = elokaData.stream;
|
||||
data.displayName = elokaData.stream;
|
||||
data.action = elokaData.signal;
|
||||
data.mode = AvaElokaMode::EndlessLoop;
|
||||
data.startTime = toMSecSinceEpoch(elokaData.time);
|
||||
ElokaData data;
|
||||
for (const auto& elokaData : eloka)
|
||||
{
|
||||
data.internalName = elokaData.stream;
|
||||
data.displayName = elokaData.stream;
|
||||
data.action = elokaData.signal;
|
||||
data.mode = AvaElokaMode::EndlessLoop;
|
||||
data.startTime = toMSecSinceEpoch(elokaData.time);
|
||||
|
||||
if (isCnr(data, userProfile) ||
|
||||
isTvc(data, userProfile) ||
|
||||
isAnnouncement(data))
|
||||
m_elokaModel->insertRow(data);
|
||||
}
|
||||
if (isCnr(data, userProfile) || isTvc(data, userProfile) || isAnnouncement(data))
|
||||
m_elokaModel->insertRow(data);
|
||||
}
|
||||
}
|
||||
|
||||
void ElokaDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->tvEloka->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->tvEloka->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool ElokaDialog::isCnr(ElokaData& data, const QMultiMap<qint32, ElokaCircuitType>& userProfile)
|
||||
{
|
||||
const QMap<qint32, CnrConfig> cnrs = m_avmDtc->cnrConfigs();
|
||||
const QMap<qint32, CnrConfig> cnrs = m_avmDtc->cnrConfigs();
|
||||
|
||||
for (const auto &cnr : cnrs)
|
||||
{
|
||||
if ((QString::fromStdString(cnr.radioCircuit()) == data.internalName) &&
|
||||
(userProfile.contains(cnr.id(), ElokaCircuitType::Cnr)))
|
||||
for (const auto& cnr : cnrs)
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Cnr;
|
||||
data.party = cnr.partyId();
|
||||
data.id = cnr.id();
|
||||
return true;
|
||||
if ((QString::fromStdString(cnr.radioCircuit()) == data.internalName) &&
|
||||
(userProfile.contains(cnr.id(), ElokaCircuitType::Cnr)))
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Cnr;
|
||||
data.party = cnr.partyId();
|
||||
data.id = cnr.id();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ElokaDialog::isTvc(ElokaData& data, const QMultiMap<qint32, ElokaCircuitType>& userProfile)
|
||||
{
|
||||
const QMap<qint32, TvcConfig> tvcs = m_avmDtc->tvcConfigs();
|
||||
const QMap<qint32, TvcConfig> tvcs = m_avmDtc->tvcConfigs();
|
||||
|
||||
for (const auto &tvc : tvcs)
|
||||
{
|
||||
if (tvc.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
if ((QString::fromStdString(tvc.radioCircuit()) == data.internalName) &&
|
||||
(userProfile.contains(tvc.id(), ElokaCircuitType::Tvc)))
|
||||
for (const auto& tvc : tvcs)
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Tvc;
|
||||
data.party = 0;
|
||||
data.id = tvc.id();
|
||||
return true;
|
||||
if (tvc.exerciseId() != m_session->exerciseId())
|
||||
continue;
|
||||
if ((QString::fromStdString(tvc.radioCircuit()) == data.internalName) &&
|
||||
(userProfile.contains(tvc.id(), ElokaCircuitType::Tvc)))
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Tvc;
|
||||
data.party = 0;
|
||||
data.id = tvc.id();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ElokaDialog::isAnnouncement(ElokaData& data)
|
||||
{
|
||||
QMap<qint32, Stream> announcements;
|
||||
QMap<qint32, Stream> streams = m_avmDtc->streams();
|
||||
for (const Stream &stream : std::as_const(streams))
|
||||
{
|
||||
if ((stream.type() == StreamType_def::AudioOut) ||
|
||||
(stream.type() == StreamType_def::AudioInOut))
|
||||
announcements.insert(stream.id(), stream);
|
||||
}
|
||||
|
||||
for (const auto &announcement : announcements)
|
||||
{
|
||||
if (QString::fromStdString(announcement.name()) == data.internalName)
|
||||
QMap<qint32, Stream> announcements;
|
||||
QMap<qint32, Stream> streams = m_avmDtc->streams();
|
||||
for (const Stream& stream : std::as_const(streams))
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Announcement;
|
||||
data.party = -1;
|
||||
data.id = announcement.id();
|
||||
data.exerciseId = m_session->exerciseId();
|
||||
data.displayName = m_streamNameMapping->displayName(data.internalName);
|
||||
return true;
|
||||
if ((stream.type() == StreamType_def::AudioOut) || (stream.type() == StreamType_def::AudioInOut))
|
||||
announcements.insert(stream.id(), stream);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
for (const auto& announcement : announcements)
|
||||
{
|
||||
if (QString::fromStdString(announcement.name()) == data.internalName)
|
||||
{
|
||||
data.circuitType = ElokaCircuitType::Announcement;
|
||||
data.party = -1;
|
||||
data.id = announcement.id();
|
||||
data.exerciseId = m_session->exerciseId();
|
||||
data.displayName = m_streamNameMapping->displayName(data.internalName);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ElokaDialog::getUsedRadioCircuits()
|
||||
{
|
||||
m_usedAnnouncement.clear();
|
||||
m_usedCnr.clear();
|
||||
m_usedTvc.clear();
|
||||
m_usedAnnouncement.clear();
|
||||
m_usedCnr.clear();
|
||||
m_usedTvc.clear();
|
||||
|
||||
for (int i=0; i < m_elokaModel->rowCount(); ++i)
|
||||
{
|
||||
ElokaData elokaData = m_elokaModel->getRowData(i);
|
||||
switch (elokaData.circuitType)
|
||||
for (int i = 0; i < m_elokaModel->rowCount(); ++i)
|
||||
{
|
||||
case ElokaCircuitType::Cnr:
|
||||
m_usedCnr.push_back(elokaData.id);
|
||||
break;
|
||||
case ElokaCircuitType::Tvc:
|
||||
m_usedTvc.push_back(elokaData.id);
|
||||
break;
|
||||
case ElokaCircuitType::Announcement:
|
||||
m_usedAnnouncement.push_back(elokaData.id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
ElokaData elokaData = m_elokaModel->getRowData(i);
|
||||
switch (elokaData.circuitType)
|
||||
{
|
||||
case ElokaCircuitType::Cnr:
|
||||
m_usedCnr.push_back(elokaData.id);
|
||||
break;
|
||||
case ElokaCircuitType::Tvc:
|
||||
m_usedTvc.push_back(elokaData.id);
|
||||
break;
|
||||
case ElokaCircuitType::Announcement:
|
||||
m_usedAnnouncement.push_back(elokaData.id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+348
-393
@@ -1,264 +1,233 @@
|
||||
|
||||
|
||||
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <utility>
|
||||
|
||||
#include "avm_eloka_edit_dialog.h"
|
||||
#include "ui_avm_eloka_edit_dialog.h"
|
||||
#include <AudioVideoManagement/ava_session.h>
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/stream_name_mapping.h>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include "ui_avm_eloka_edit_dialog.h"
|
||||
|
||||
#include <AudioVideoManagement/ava_control.h>
|
||||
#include <AudioVideoManagement/ava_session.h>
|
||||
#include <AudioVideoManagement/stream_name_mapping.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <boost/optional.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
||||
|
||||
struct ComboBoxUserData
|
||||
{
|
||||
QString internalName;
|
||||
AudioVideoManagement::ElokaCircuitType circuitType;
|
||||
int id;
|
||||
QString internalName;
|
||||
AudioVideoManagement::ElokaCircuitType circuitType;
|
||||
int id;
|
||||
};
|
||||
|
||||
|
||||
ComboBoxUserData userDataAt(QComboBox *cb, int index)
|
||||
ComboBoxUserData userDataAt(QComboBox* cb, int index)
|
||||
{
|
||||
Q_ASSERT(cb);
|
||||
Q_ASSERT(index >= 0 && index < cb->count());
|
||||
QVariant userData = cb->itemData(index);
|
||||
Q_ASSERT(userData.canConvert<ComboBoxUserData>());
|
||||
return userData.value<ComboBoxUserData>();
|
||||
Q_ASSERT(cb);
|
||||
Q_ASSERT(index >= 0 && index < cb->count());
|
||||
QVariant userData = cb->itemData(index);
|
||||
Q_ASSERT(userData.canConvert<ComboBoxUserData>());
|
||||
return userData.value<ComboBoxUserData>();
|
||||
}
|
||||
|
||||
ComboBoxUserData currentUserData(QComboBox* cb)
|
||||
{
|
||||
Q_ASSERT(cb);
|
||||
return userDataAt(cb, cb->currentIndex());
|
||||
Q_ASSERT(cb);
|
||||
return userDataAt(cb, cb->currentIndex());
|
||||
}
|
||||
|
||||
|
||||
|
||||
boost::optional<int> currentId(QComboBox *comboBox, AudioVideoManagement::ElokaCircuitType circuitType)
|
||||
boost::optional<int> currentId(QComboBox* comboBox, AudioVideoManagement::ElokaCircuitType circuitType)
|
||||
{
|
||||
Q_ASSERT(comboBox);
|
||||
Q_ASSERT(comboBox);
|
||||
|
||||
int selectedIndex = comboBox->currentIndex();
|
||||
if (selectedIndex == -1)
|
||||
return boost::none;
|
||||
int selectedIndex = comboBox->currentIndex();
|
||||
if (selectedIndex == -1)
|
||||
return boost::none;
|
||||
|
||||
QVariant userData_ = comboBox->itemData(selectedIndex);
|
||||
Q_ASSERT(userData_.canConvert<ComboBoxUserData>());
|
||||
ComboBoxUserData userData = userData_.value<ComboBoxUserData>();
|
||||
if (userData.circuitType != circuitType)
|
||||
return boost::none;
|
||||
|
||||
return userData.id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void selectItemWithId(QComboBox *comboBox, boost::optional<int> id)
|
||||
{
|
||||
Q_ASSERT(comboBox);
|
||||
|
||||
if (comboBox->count() == 0)
|
||||
return;
|
||||
|
||||
if (!id.is_initialized())
|
||||
{
|
||||
comboBox->setCurrentIndex(0);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < comboBox->count(); ++i)
|
||||
{
|
||||
QVariant userData_ = comboBox->itemData(i);
|
||||
QVariant userData_ = comboBox->itemData(selectedIndex);
|
||||
Q_ASSERT(userData_.canConvert<ComboBoxUserData>());
|
||||
ComboBoxUserData userData = userData_.value<ComboBoxUserData>();
|
||||
if (userData.id == *id)
|
||||
{
|
||||
comboBox->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ComboBoxUserData userData = userData_.value<ComboBoxUserData>();
|
||||
if (userData.circuitType != circuitType)
|
||||
return boost::none;
|
||||
|
||||
comboBox->setCurrentIndex(0);
|
||||
return userData.id;
|
||||
}
|
||||
|
||||
}
|
||||
void selectItemWithId(QComboBox* comboBox, boost::optional<int> id)
|
||||
{
|
||||
Q_ASSERT(comboBox);
|
||||
|
||||
if (comboBox->count() == 0)
|
||||
return;
|
||||
|
||||
if (!id.is_initialized())
|
||||
{
|
||||
comboBox->setCurrentIndex(0);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < comboBox->count(); ++i)
|
||||
{
|
||||
QVariant userData_ = comboBox->itemData(i);
|
||||
Q_ASSERT(userData_.canConvert<ComboBoxUserData>());
|
||||
ComboBoxUserData userData = userData_.value<ComboBoxUserData>();
|
||||
if (userData.id == *id)
|
||||
{
|
||||
comboBox->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
comboBox->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(ComboBoxUserData)
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
ElokaEditDialog::ElokaEditDialog(LtsSession::LtsSession *session, AvaSession *avaSession, Interface::Dtc *avmDtc, StreamNameMapping *streamNameMapping,
|
||||
const ElokaData &data, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::ElokaEditDialog)
|
||||
, m_session(session)
|
||||
, m_streamNameMapping(streamNameMapping)
|
||||
, m_avaCtrl(avaSession->control())
|
||||
, m_avmDtc(avmDtc)
|
||||
, m_elokaData(data)
|
||||
, m_cnrConfigMap()
|
||||
, m_tvcConfigMap()
|
||||
, m_announcementMap()
|
||||
, m_userProfile()
|
||||
ElokaEditDialog::ElokaEditDialog(LtsSession::LtsSession* session, AvaSession* avaSession, Interface::Dtc* avmDtc,
|
||||
StreamNameMapping* streamNameMapping, const ElokaData& data, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ui(new Ui::ElokaEditDialog),
|
||||
m_session(session), m_streamNameMapping(streamNameMapping), m_avaCtrl(avaSession->control()), m_avmDtc(avmDtc),
|
||||
m_elokaData(data), m_cnrConfigMap(), m_tvcConfigMap(), m_announcementMap(), m_userProfile()
|
||||
{
|
||||
Q_ASSERT(session);
|
||||
Q_ASSERT(avaSession);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
Q_ASSERT(avmDtc);
|
||||
Q_ASSERT(session);
|
||||
Q_ASSERT(avaSession);
|
||||
Q_ASSERT(streamNameMapping);
|
||||
Q_ASSERT(avmDtc);
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_uiRequirements->addRequirement( { m_ui->lbAction, [this]() { return !m_ui->cmbAction->currentText().isEmpty(); } });
|
||||
m_uiRequirements->addRequirement( { m_ui->lbCircuit, [this]() { return !m_ui->cmbCircuit->currentText().isEmpty(); } });
|
||||
m_uiRequirements->addRequirement({m_ui->lbAction, [this]() { return !m_ui->cmbAction->currentText().isEmpty(); }});
|
||||
m_uiRequirements->addRequirement(
|
||||
{m_ui->lbCircuit, [this]() { return !m_ui->cmbCircuit->currentText().isEmpty(); }});
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Electronic_Warfare_Measures"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Electronic_Warfare_Measures"));
|
||||
}
|
||||
|
||||
ElokaEditDialog::~ElokaEditDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ElokaEditDialog::retranslate()
|
||||
{
|
||||
bool isNew = true;
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
isNew = false;
|
||||
bool isNew = true;
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
isNew = false;
|
||||
|
||||
translate(m_ui, QString(), isNew, tr("Eloka"));
|
||||
translate(m_ui, QString(), isNew, tr("Eloka"));
|
||||
}
|
||||
|
||||
bool ElokaEditDialog::init(const std::vector<qint32> &usedCnr,
|
||||
const std::vector<qint32> &usedTvc,
|
||||
const std::vector<qint32> &usedAnnouncement)
|
||||
bool ElokaEditDialog::init(const std::vector<qint32>& usedCnr, const std::vector<qint32>& usedTvc,
|
||||
const std::vector<qint32>& usedAnnouncement)
|
||||
{
|
||||
setUnchangeable(true);
|
||||
setUnchangeable(true);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->rbTvc->hide();
|
||||
m_ui->rbTvc->hide();
|
||||
#endif
|
||||
|
||||
getUserProfile();
|
||||
|
||||
|
||||
getActiveCnrs();
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
for (int used : usedCnr)
|
||||
m_cnrConfigMap.remove(used);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_cnrConfigMap.remove(m_elokaData.id);
|
||||
}
|
||||
getUserProfile();
|
||||
|
||||
|
||||
m_tvcConfigMap = m_avmDtc->tvcConfigs();
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
for (int used : usedTvc)
|
||||
m_tvcConfigMap.remove(used);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tvcConfigMap.remove(m_elokaData.id);
|
||||
}
|
||||
getActiveCnrs();
|
||||
|
||||
|
||||
const QMap<qint32, Stream> streams = m_avmDtc->streams();
|
||||
for (const Stream &stream : streams)
|
||||
{
|
||||
if ((stream.type() == StreamType_def::AudioOut) ||
|
||||
(stream.type() == StreamType_def::AudioInOut))
|
||||
m_announcementMap.insert(stream.id(), stream);
|
||||
}
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
for (int used : usedAnnouncement)
|
||||
m_announcementMap.remove(used);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_announcementMap.remove(m_elokaData.id);
|
||||
}
|
||||
|
||||
connect(m_avmDtc,
|
||||
&AudioVideoManagement::Interface::Dtc::cnrConfigChanged,
|
||||
this, &ElokaEditDialog::onCnrConfigChanged);
|
||||
connect(m_avmDtc,
|
||||
&AudioVideoManagement::Interface::Dtc::tvcConfigChanged,
|
||||
this, &ElokaEditDialog::onTvcConfigChanged);
|
||||
connect(m_avmDtc,
|
||||
&AudioVideoManagement::Interface::Dtc::cnrTvcProfileChanged,
|
||||
this, &ElokaEditDialog::onCnrTvcProfileChanged);
|
||||
connect(m_avmDtc,
|
||||
&AudioVideoManagement::Interface::Dtc::streamChanged,
|
||||
this, &ElokaEditDialog::onStreamChanged);
|
||||
|
||||
connect(m_ui->cmbCircuit,
|
||||
QOverload<int>::of(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &ElokaEditDialog::onCmbCircuitChanged);
|
||||
connect(m_ui->rbCnr, &QRadioButton::toggled,
|
||||
this, &ElokaEditDialog::onCbCnrToggled);
|
||||
connect(m_ui->rbAnnouncement, &QRadioButton::toggled,
|
||||
this, &ElokaEditDialog::onCbAnnouncementToggled);
|
||||
connect(m_ui->rbTvc, &QRadioButton::toggled,
|
||||
this, &ElokaEditDialog::onCbTvcToggled);
|
||||
connect(m_avaCtrl, &AvaControl::getElokaListResponse,
|
||||
this, &ElokaEditDialog::onGetElokaListResponse);
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
|
||||
checkedRadioButtons(true, false, false);
|
||||
enabledRadioButtons(true, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Cnr)
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
checkedRadioButtons(true, false, false);
|
||||
enabledRadioButtons(true, false, false);
|
||||
for (int used : usedCnr)
|
||||
m_cnrConfigMap.remove(used);
|
||||
}
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Tvc)
|
||||
else
|
||||
{
|
||||
checkedRadioButtons(false, true, false);
|
||||
enabledRadioButtons(false, true, false);
|
||||
m_cnrConfigMap.remove(m_elokaData.id);
|
||||
}
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Announcement)
|
||||
|
||||
m_tvcConfigMap = m_avmDtc->tvcConfigs();
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
checkedRadioButtons(false, false, true);
|
||||
enabledRadioButtons(false, false, true);
|
||||
for (int used : usedTvc)
|
||||
m_tvcConfigMap.remove(used);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tvcConfigMap.remove(m_elokaData.id);
|
||||
}
|
||||
if (m_elokaData.mode == AvaElokaMode::EndlessLoop)
|
||||
m_ui->chbEndlessPlayback->setChecked(true);
|
||||
|
||||
setCurrentCircuit(m_elokaData);
|
||||
m_ui->cmbAction->setCurrentText(m_elokaData.action);
|
||||
}
|
||||
const QMap<qint32, Stream> streams = m_avmDtc->streams();
|
||||
for (const Stream& stream : streams)
|
||||
{
|
||||
if ((stream.type() == StreamType_def::AudioOut) || (stream.type() == StreamType_def::AudioInOut))
|
||||
m_announcementMap.insert(stream.id(), stream);
|
||||
}
|
||||
|
||||
setUnchangeable(false);
|
||||
return true;
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
for (int used : usedAnnouncement)
|
||||
m_announcementMap.remove(used);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_announcementMap.remove(m_elokaData.id);
|
||||
}
|
||||
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::cnrConfigChanged, this,
|
||||
&ElokaEditDialog::onCnrConfigChanged);
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::tvcConfigChanged, this,
|
||||
&ElokaEditDialog::onTvcConfigChanged);
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::cnrTvcProfileChanged, this,
|
||||
&ElokaEditDialog::onCnrTvcProfileChanged);
|
||||
connect(m_avmDtc, &AudioVideoManagement::Interface::Dtc::streamChanged, this, &ElokaEditDialog::onStreamChanged);
|
||||
|
||||
connect(m_ui->cmbCircuit, QOverload<int>::of(&LtsWidgets::LtsComboBox::currentIndexChanged), this,
|
||||
&ElokaEditDialog::onCmbCircuitChanged);
|
||||
connect(m_ui->rbCnr, &QRadioButton::toggled, this, &ElokaEditDialog::onCbCnrToggled);
|
||||
connect(m_ui->rbAnnouncement, &QRadioButton::toggled, this, &ElokaEditDialog::onCbAnnouncementToggled);
|
||||
connect(m_ui->rbTvc, &QRadioButton::toggled, this, &ElokaEditDialog::onCbTvcToggled);
|
||||
connect(m_avaCtrl, &AvaControl::getElokaListResponse, this, &ElokaEditDialog::onGetElokaListResponse);
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
{
|
||||
|
||||
checkedRadioButtons(true, false, false);
|
||||
enabledRadioButtons(true, true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Cnr)
|
||||
{
|
||||
checkedRadioButtons(true, false, false);
|
||||
enabledRadioButtons(true, false, false);
|
||||
}
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Tvc)
|
||||
{
|
||||
checkedRadioButtons(false, true, false);
|
||||
enabledRadioButtons(false, true, false);
|
||||
}
|
||||
if (m_elokaData.circuitType == ElokaCircuitType::Announcement)
|
||||
{
|
||||
checkedRadioButtons(false, false, true);
|
||||
enabledRadioButtons(false, false, true);
|
||||
}
|
||||
if (m_elokaData.mode == AvaElokaMode::EndlessLoop)
|
||||
m_ui->chbEndlessPlayback->setChecked(true);
|
||||
|
||||
setCurrentCircuit(m_elokaData);
|
||||
m_ui->cmbAction->setCurrentText(m_elokaData.action);
|
||||
}
|
||||
|
||||
setUnchangeable(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ElokaEditDialog::checkedRadioButtons(bool cnr, bool tvc, bool announcement)
|
||||
{
|
||||
m_ui->rbCnr->setChecked(cnr);
|
||||
m_ui->rbTvc->setChecked(tvc);
|
||||
m_ui->rbAnnouncement->setChecked(announcement);
|
||||
m_ui->rbCnr->setChecked(cnr);
|
||||
m_ui->rbTvc->setChecked(tvc);
|
||||
m_ui->rbAnnouncement->setChecked(announcement);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::enabledRadioButtons(bool cnr, bool tvc, bool announcement)
|
||||
@@ -270,288 +239,274 @@ void ElokaEditDialog::enabledRadioButtons(bool cnr, bool tvc, bool announcement)
|
||||
|
||||
void ElokaEditDialog::onCmbCircuitChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
Q_UNUSED(index);
|
||||
|
||||
m_ui->cmbAction->clear();
|
||||
m_ui->cmbAction->clear();
|
||||
|
||||
if (m_ui->cmbCircuit->currentText().isEmpty())
|
||||
return;
|
||||
if (m_ui->cmbCircuit->currentText().isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
ComboBoxUserData userData = currentUserData(m_ui->cmbCircuit);
|
||||
m_avaCtrl->getElokaList(userData.internalName);
|
||||
ComboBoxUserData userData = currentUserData(m_ui->cmbCircuit);
|
||||
m_avaCtrl->getElokaList(userData.internalName);
|
||||
}
|
||||
|
||||
bool ElokaEditDialog::apply()
|
||||
{
|
||||
ComboBoxUserData userData = currentUserData(m_ui->cmbCircuit);
|
||||
ComboBoxUserData userData = currentUserData(m_ui->cmbCircuit);
|
||||
|
||||
ElokaData data;
|
||||
data.id = userData.id;
|
||||
data.internalName = userData.internalName;
|
||||
data.displayName = m_ui->cmbCircuit->currentText();
|
||||
data.party = -1;
|
||||
data.exerciseId = m_session->exerciseId();
|
||||
data.circuitType = userData.circuitType;
|
||||
data.action = m_ui->cmbAction->currentText();
|
||||
data.mode = m_ui->chbEndlessPlayback->isChecked() ? AvaElokaMode::EndlessLoop : AvaElokaMode::Once;
|
||||
data.startTime = m_session->partitionTime();
|
||||
ElokaData data;
|
||||
data.id = userData.id;
|
||||
data.internalName = userData.internalName;
|
||||
data.displayName = m_ui->cmbCircuit->currentText();
|
||||
data.party = -1;
|
||||
data.exerciseId = m_session->exerciseId();
|
||||
data.circuitType = userData.circuitType;
|
||||
data.action = m_ui->cmbAction->currentText();
|
||||
data.mode = m_ui->chbEndlessPlayback->isChecked() ? AvaElokaMode::EndlessLoop : AvaElokaMode::Once;
|
||||
data.startTime = m_session->partitionTime();
|
||||
|
||||
if (userData.circuitType == ElokaCircuitType::Cnr)
|
||||
data.party = m_cnrConfigMap.value(userData.id).partyId();
|
||||
if (userData.circuitType == ElokaCircuitType::Cnr)
|
||||
data.party = m_cnrConfigMap.value(userData.id).partyId();
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
m_avaCtrl->chooseEloka(data.internalName, data.action, data.mode);
|
||||
else if (m_elokaData.action != data.action)
|
||||
{
|
||||
m_avaCtrl->releaseEloka(m_elokaData.internalName);
|
||||
m_avaCtrl->chooseEloka(data.internalName, data.action, data.mode);
|
||||
}
|
||||
|
||||
if (m_elokaData.internalName.isEmpty())
|
||||
m_avaCtrl->chooseEloka(data.internalName, data.action, data.mode);
|
||||
else if (m_elokaData.action != data.action)
|
||||
{
|
||||
m_avaCtrl->releaseEloka(m_elokaData.internalName);
|
||||
m_avaCtrl->chooseEloka(data.internalName, data.action, data.mode);
|
||||
}
|
||||
|
||||
m_elokaData = data;
|
||||
emit signalNewEloka(data);
|
||||
return true;
|
||||
m_elokaData = data;
|
||||
emit signalNewEloka(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onCbCnrToggled(bool checked)
|
||||
{
|
||||
if (!checked)
|
||||
return;
|
||||
if (!checked)
|
||||
return;
|
||||
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onCbAnnouncementToggled(bool checked)
|
||||
{
|
||||
if (!checked)
|
||||
return;
|
||||
if (!checked)
|
||||
return;
|
||||
|
||||
fillComboBoxCircuit(ElokaCircuitType::Announcement);
|
||||
fillComboBoxCircuit(ElokaCircuitType::Announcement);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onCbTvcToggled(bool checked)
|
||||
{
|
||||
if (!checked)
|
||||
return;
|
||||
if (!checked)
|
||||
return;
|
||||
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::getActiveCnrs()
|
||||
{
|
||||
const QMap<qint32, CnrConfig> cnrs = m_avmDtc->cnrConfigs();
|
||||
for (const CnrConfig &cnr : cnrs)
|
||||
{
|
||||
if (cnr.isActive() == true)
|
||||
m_cnrConfigMap.insert(cnr.id(), cnr);
|
||||
}
|
||||
const QMap<qint32, CnrConfig> cnrs = m_avmDtc->cnrConfigs();
|
||||
for (const CnrConfig& cnr : cnrs)
|
||||
{
|
||||
if (cnr.isActive() == true)
|
||||
m_cnrConfigMap.insert(cnr.id(), cnr);
|
||||
}
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onCnrConfigChanged(const CnrConfig &data,
|
||||
DataModification modType)
|
||||
void ElokaEditDialog::onCnrConfigChanged(const CnrConfig& data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onCnrConfigChanged";
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
m_cnrConfigMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
m_cnrConfigMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "onCnrConfigChanged";
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified: {
|
||||
m_cnrConfigMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved: {
|
||||
m_cnrConfigMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ui->rbCnr->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
if (m_ui->rbCnr->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onTvcConfigChanged(const TvcConfig &data,
|
||||
DataModification modType)
|
||||
void ElokaEditDialog::onTvcConfigChanged(const TvcConfig& data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onTvcConfigChanged";
|
||||
DEBUG_LOG(m_logger) << "onTvcConfigChanged";
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
m_tvcConfigMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
m_tvcConfigMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified: {
|
||||
m_tvcConfigMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved: {
|
||||
m_tvcConfigMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ui->rbTvc->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
if (m_ui->rbTvc->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onStreamChanged(const Stream &data,
|
||||
DataModification modType)
|
||||
void ElokaEditDialog::onStreamChanged(const Stream& data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onStreamChanged";
|
||||
DEBUG_LOG(m_logger) << "onStreamChanged";
|
||||
|
||||
if ((data.type() != StreamType_def::AudioOut) &&
|
||||
(data.type() != StreamType_def::AudioInOut))
|
||||
return;
|
||||
if ((data.type() != StreamType_def::AudioOut) && (data.type() != StreamType_def::AudioInOut))
|
||||
return;
|
||||
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified:
|
||||
{
|
||||
m_announcementMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved:
|
||||
{
|
||||
m_announcementMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (modType)
|
||||
{
|
||||
case DataModification::eAdded:
|
||||
case DataModification::eModified: {
|
||||
m_announcementMap.insert(data.id(), data);
|
||||
break;
|
||||
}
|
||||
case DataModification::eRemoved: {
|
||||
m_announcementMap.remove(data.id());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ui->rbAnnouncement->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Announcement);
|
||||
if (m_ui->rbAnnouncement->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Announcement);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onCnrTvcProfileChanged(const CnrTvcProfile &data,
|
||||
DataModification modType)
|
||||
void ElokaEditDialog::onCnrTvcProfileChanged(const CnrTvcProfile& data, DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
DEBUG_LOG(m_logger) << "onCnrTvcProfileChanged";
|
||||
Q_UNUSED(modType);
|
||||
DEBUG_LOG(m_logger) << "onCnrTvcProfileChanged";
|
||||
|
||||
if (data.exerciseId() != m_session->exerciseId() ||
|
||||
data.operatorId() != LtsSessionData::LtsSessionData::getInstance()->getOperatorId())
|
||||
return;
|
||||
if (data.exerciseId() != m_session->exerciseId() ||
|
||||
data.operatorId() != LtsSessionData::LtsSessionData::getInstance()->getOperatorId())
|
||||
return;
|
||||
|
||||
getUserProfile();
|
||||
getUserProfile();
|
||||
|
||||
if (m_ui->rbCnr->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
else if (m_ui->rbTvc->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
if (m_ui->rbCnr->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Cnr);
|
||||
else if (m_ui->rbTvc->isChecked())
|
||||
fillComboBoxCircuit(ElokaCircuitType::Tvc);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::getUserProfile()
|
||||
{
|
||||
m_userProfile.clear();
|
||||
m_userProfile.clear();
|
||||
|
||||
const QMap<qint32, AudioVideoManagement::CnrTvcProfile> cnrTvcProfiles = m_avmDtc->cnrTvcProfiles();
|
||||
int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
int exerciseId = m_session->exerciseId();
|
||||
const QMap<qint32, AudioVideoManagement::CnrTvcProfile> cnrTvcProfiles = m_avmDtc->cnrTvcProfiles();
|
||||
int operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
int exerciseId = m_session->exerciseId();
|
||||
|
||||
for (const auto &cnrTvcProfile : cnrTvcProfiles)
|
||||
{
|
||||
if (cnrTvcProfile.exerciseId() == exerciseId &&
|
||||
cnrTvcProfile.operatorId() == operatorId)
|
||||
for (const auto& cnrTvcProfile : cnrTvcProfiles)
|
||||
{
|
||||
for (const auto &cnrTvcProfileData : cnrTvcProfile.data())
|
||||
if (cnrTvcProfileData.radioSystemId() == RadioSystem::inner_enum::Cnr)
|
||||
m_userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Cnr);
|
||||
else
|
||||
m_userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Tvc);
|
||||
if (cnrTvcProfile.exerciseId() == exerciseId && cnrTvcProfile.operatorId() == operatorId)
|
||||
{
|
||||
for (const auto& cnrTvcProfileData : cnrTvcProfile.data())
|
||||
if (cnrTvcProfileData.radioSystemId() == RadioSystem::inner_enum::Cnr)
|
||||
m_userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Cnr);
|
||||
else
|
||||
m_userProfile.insert(cnrTvcProfileData.radioCircuitId(), ElokaCircuitType::Tvc);
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ElokaEditDialog::fillComboBoxCircuit(ElokaCircuitType type)
|
||||
{
|
||||
boost::optional<int> selectedId = currentId(m_ui->cmbCircuit, type);
|
||||
m_ui->cmbCircuit->clear();
|
||||
boost::optional<int> selectedId = currentId(m_ui->cmbCircuit, type);
|
||||
m_ui->cmbCircuit->clear();
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case ElokaCircuitType::Cnr:
|
||||
{
|
||||
for (const CnrConfig &cnr : std::as_const(m_cnrConfigMap))
|
||||
switch (type)
|
||||
{
|
||||
if (!m_userProfile.contains(cnr.id(), ElokaCircuitType::Cnr))
|
||||
continue;
|
||||
case ElokaCircuitType::Cnr: {
|
||||
for (const CnrConfig& cnr : std::as_const(m_cnrConfigMap))
|
||||
{
|
||||
if (!m_userProfile.contains(cnr.id(), ElokaCircuitType::Cnr))
|
||||
continue;
|
||||
|
||||
QString internalName = QString::fromStdString(cnr.radioCircuit());
|
||||
QVariant userData = QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Cnr, cnr.id()});
|
||||
m_ui->cmbCircuit->addItem(internalName, userData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElokaCircuitType::Tvc:
|
||||
{
|
||||
for (const TvcConfig &tvc : std::as_const(m_tvcConfigMap))
|
||||
{
|
||||
if (!m_userProfile.contains(tvc.id(), ElokaCircuitType::Tvc))
|
||||
continue;
|
||||
QString internalName = QString::fromStdString(cnr.radioCircuit());
|
||||
QVariant userData =
|
||||
QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Cnr, cnr.id()});
|
||||
m_ui->cmbCircuit->addItem(internalName, userData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElokaCircuitType::Tvc: {
|
||||
for (const TvcConfig& tvc : std::as_const(m_tvcConfigMap))
|
||||
{
|
||||
if (!m_userProfile.contains(tvc.id(), ElokaCircuitType::Tvc))
|
||||
continue;
|
||||
|
||||
QString internalName = QString::fromStdString(tvc.radioCircuit());
|
||||
QVariant userData = QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Tvc, tvc.id()});
|
||||
m_ui->cmbCircuit->addItem(internalName, userData);
|
||||
QString internalName = QString::fromStdString(tvc.radioCircuit());
|
||||
QVariant userData =
|
||||
QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Tvc, tvc.id()});
|
||||
m_ui->cmbCircuit->addItem(internalName, userData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElokaCircuitType::Announcement: {
|
||||
for (const Stream& stream : std::as_const(m_announcementMap))
|
||||
{
|
||||
QString internalName = QString::fromStdString(stream.name());
|
||||
QString displayName = m_streamNameMapping->displayName(internalName);
|
||||
QVariant userData =
|
||||
QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Announcement, stream.id()});
|
||||
m_ui->cmbCircuit->addItem(displayName, userData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ElokaCircuitType::Announcement:
|
||||
{
|
||||
for (const Stream &stream : std::as_const(m_announcementMap))
|
||||
{
|
||||
QString internalName = QString::fromStdString(stream.name());
|
||||
QString displayName = m_streamNameMapping->displayName(internalName);
|
||||
QVariant userData = QVariant::fromValue(ComboBoxUserData{internalName, ElokaCircuitType::Announcement, stream.id()});
|
||||
m_ui->cmbCircuit->addItem(displayName, userData);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_ui->cmbCircuit->model()->sort(0);
|
||||
selectItemWithId(m_ui->cmbCircuit, selectedId);
|
||||
m_ui->cmbCircuit->model()->sort(0);
|
||||
selectItemWithId(m_ui->cmbCircuit, selectedId);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::setCurrentCircuit(const ElokaData &data)
|
||||
void ElokaEditDialog::setCurrentCircuit(const ElokaData& data)
|
||||
{
|
||||
for (int i = 0; i < m_ui->cmbCircuit->count(); ++i)
|
||||
{
|
||||
ComboBoxUserData userData = userDataAt(m_ui->cmbCircuit, i);
|
||||
if (userData.circuitType != data.circuitType)
|
||||
continue;
|
||||
for (int i = 0; i < m_ui->cmbCircuit->count(); ++i)
|
||||
{
|
||||
ComboBoxUserData userData = userDataAt(m_ui->cmbCircuit, i);
|
||||
if (userData.circuitType != data.circuitType)
|
||||
continue;
|
||||
|
||||
if (userData.id != data.id)
|
||||
continue;
|
||||
if (userData.id != data.id)
|
||||
continue;
|
||||
|
||||
m_ui->cmbCircuit->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
m_ui->cmbCircuit->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
|
||||
Q_ASSERT(false);
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
void ElokaEditDialog::onGetElokaListResponse(const QVector<QString> &actions)
|
||||
void ElokaEditDialog::onGetElokaListResponse(const QVector<QString>& actions)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onGetElokaListResponse";
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
setUnchangeable(true);
|
||||
DEBUG_LOG(m_logger) << "onGetElokaListResponse";
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
setUnchangeable(true);
|
||||
|
||||
m_ui->cmbAction->clear();
|
||||
m_ui->cmbAction->clear();
|
||||
|
||||
if (actions.isEmpty())
|
||||
return;
|
||||
if (actions.isEmpty())
|
||||
return;
|
||||
|
||||
for (const QString &action : actions)
|
||||
m_ui->cmbAction->addItem(action);
|
||||
for (const QString& action : actions)
|
||||
m_ui->cmbAction->addItem(action);
|
||||
|
||||
if(m_elokaData.action.isEmpty() == false)
|
||||
m_ui->cmbAction->setCurrentText(m_elokaData.action);
|
||||
if (m_elokaData.action.isEmpty() == false)
|
||||
m_ui->cmbAction->setCurrentText(m_elokaData.action);
|
||||
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
setUnchangeable(false);
|
||||
if (!m_elokaData.internalName.isEmpty())
|
||||
setUnchangeable(false);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+108
-135
@@ -1,218 +1,191 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_mvs_dialog.h"
|
||||
#include "ui_avm_mvs_dialog.h"
|
||||
#include "avm_mvs_edit_dialog.h"
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include "avm_mvs_edit_dialog.h"
|
||||
#include "ui_avm_mvs_dialog.h"
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QTreeView>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
MvsDialog::MvsDialog(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::MvsDialog)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_model(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_avmDtc(nullptr)
|
||||
, m_avmFtc(nullptr)
|
||||
MvsDialog::MvsDialog(const QString& menuGroup, LtsSession::LtsSession* session, QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_session(session),
|
||||
m_ui(new Ui::MvsDialog), m_menuGroup(menuGroup), m_model(nullptr),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_avmDtc(nullptr), m_avmFtc(nullptr)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Configuration_Video_Teams"));
|
||||
m_ui->setupUi(this);
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Configuration_Video_Teams"));
|
||||
}
|
||||
|
||||
MvsDialog::~MvsDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void MvsDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Configure Mobile Video Teams"));
|
||||
translate(m_ui, tr("Configure Mobile Video Teams"));
|
||||
}
|
||||
|
||||
void MvsDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool MvsDialog::init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc, const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &avmFtc)
|
||||
bool MvsDialog::init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& avmFtc)
|
||||
{
|
||||
|
||||
delete m_model;
|
||||
m_model = new MvsModel(this);
|
||||
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
|
||||
if (!m_model->init(m_session->exerciseId(), avmDtc))
|
||||
{
|
||||
delete m_model;
|
||||
m_model = nullptr;
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
m_model = new MvsModel(this);
|
||||
|
||||
m_ui->dataView->setModel(m_model);
|
||||
m_avmDtc = avmDtc;
|
||||
m_avmFtc = avmFtc;
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &MvsDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MvsDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &MvsDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &MvsDialog::onPrint);
|
||||
if (!m_model->init(m_session->exerciseId(), avmDtc))
|
||||
{
|
||||
delete m_model;
|
||||
m_model = nullptr;
|
||||
ERROR_LOG(m_logger) << "Could not init model";
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &MvsDialog::onSelectionChanged);
|
||||
m_ui->dataView->setModel(m_model);
|
||||
|
||||
onSelectionChanged();
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &MvsDialog::onAddClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &MvsDialog::onEditClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &MvsDialog::onRemoveClicked);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &MvsDialog::onPrint);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &MvsDialog::onEditClicked);
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged, this, &MvsDialog::onSelectionChanged);
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&MvsDialog::onImportButtonClicked,
|
||||
&MvsDialog::onExportButtonClicked);
|
||||
onSelectionChanged();
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked, this, &MvsDialog::onEditClicked);
|
||||
|
||||
return true;
|
||||
m_buttonBox->connectLibraryButton(this, &MvsDialog::onImportButtonClicked, &MvsDialog::onExportButtonClicked);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MvsDialog::onVideoTeamModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
void MvsDialog::onVideoTeamModifyReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
|
||||
void MvsDialog::onAddClicked()
|
||||
{
|
||||
EditVideoTeamDialog *dialog = new EditVideoTeamDialog(m_avmDtc, m_session->exerciseId(), this);
|
||||
EditVideoTeamDialog* dialog = new EditVideoTeamDialog(m_avmDtc, m_session->exerciseId(), this);
|
||||
|
||||
connect(dialog, &EditVideoTeamDialog::modifyRequest, this, [this](const AudioVideoManagement::VideoTeamModifyRequest & request)
|
||||
{
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->videoTeamModifyRequest(request, this);
|
||||
});
|
||||
});
|
||||
connect(dialog, &EditVideoTeamDialog::modifyRequest, this,
|
||||
[this](const AudioVideoManagement::VideoTeamModifyRequest& request) {
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->videoTeamModifyRequest(request, this); });
|
||||
});
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("NewVideoTeam"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("NewVideoTeam"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void MvsDialog::onEditClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
AudioVideoManagement::VideoTeam config = m_model->getRowData(currentIndex.row());
|
||||
EditVideoTeamDialog *dialog = new EditVideoTeamDialog(config.id(),
|
||||
m_avmDtc,
|
||||
m_session->exerciseId(),
|
||||
config,
|
||||
this);
|
||||
AudioVideoManagement::VideoTeam config = m_model->getRowData(currentIndex.row());
|
||||
EditVideoTeamDialog* dialog = new EditVideoTeamDialog(config.id(), m_avmDtc, m_session->exerciseId(), config, this);
|
||||
|
||||
connect(dialog, &EditVideoTeamDialog::modifyRequest, this, [this](const AudioVideoManagement::VideoTeamModifyRequest & request)
|
||||
{
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->videoTeamModifyRequest(request, this);
|
||||
});
|
||||
});
|
||||
connect(dialog, &EditVideoTeamDialog::modifyRequest, this,
|
||||
[this](const AudioVideoManagement::VideoTeamModifyRequest& request) {
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->videoTeamModifyRequest(request, this); });
|
||||
});
|
||||
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditVideoTeam%1").arg(config.id()), LtsWidgets::LayoutArea::eDialogTab);
|
||||
addDialog(dialog, m_menuGroup, QStringLiteral("EditVideoTeam%1").arg(config.id()),
|
||||
LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void MvsDialog::onRemoveClicked()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
AudioVideoManagement::VideoTeamModifyRequest request;
|
||||
const VideoTeam team = m_model->getRowData(currentIndex.row());
|
||||
request.id(team.id());
|
||||
request.name(team.name());
|
||||
request.ssrc(team.ssrc());
|
||||
request.streamName(team.streamName());
|
||||
request.vtPort(team.vtPort());
|
||||
request.exerciseId(0);
|
||||
AudioVideoManagement::VideoTeamModifyRequest request;
|
||||
const VideoTeam team = m_model->getRowData(currentIndex.row());
|
||||
request.id(team.id());
|
||||
request.name(team.name());
|
||||
request.ssrc(team.ssrc());
|
||||
request.streamName(team.streamName());
|
||||
request.vtPort(team.vtPort());
|
||||
request.exerciseId(0);
|
||||
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->videoTeamModifyRequest(request, this);
|
||||
});
|
||||
m_model->removeRow(currentIndex.row());
|
||||
m_requestHelper->startSingleRequest([this, request]() { return m_avmFtc->videoTeamModifyRequest(request, this); });
|
||||
m_model->removeRow(currentIndex.row());
|
||||
}
|
||||
|
||||
void MvsDialog::onSelectionChanged()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, currentIndex.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, currentIndex.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, currentIndex.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, currentIndex.isValid());
|
||||
}
|
||||
|
||||
void MvsDialog::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void MvsDialog::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_model->modelToJson();
|
||||
QByteArray byteArray = m_model->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 ";
|
||||
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 MvsDialog::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " 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::AVMMvsDialog));
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMMvsDialog)))
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMMvsDialog));
|
||||
if (fileId > 0)
|
||||
{
|
||||
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<VideoTeamModifyRequest> requests = m_model->jsonToVideoTeamVector(content);
|
||||
for (const auto &request : requests)
|
||||
{
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
if (!m_flmGui->isXmlType(content, FileManagement::toString(FileManagement::XmlType::AVMMvsDialog)))
|
||||
{
|
||||
return m_avmFtc->videoTeamModifyRequest(request, this);
|
||||
});
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
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<VideoTeamModifyRequest> requests = m_model->jsonToVideoTeamVector(content);
|
||||
for (const auto& request : requests)
|
||||
{
|
||||
m_requestHelper->startSingleRequest(
|
||||
[this, request]() { return m_avmFtc->videoTeamModifyRequest(request, this); });
|
||||
}
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+38
-42
@@ -1,16 +1,13 @@
|
||||
|
||||
|
||||
|
||||
#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 "avm_mvs_model.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
@@ -34,7 +31,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
@@ -42,48 +39,47 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ParticipantManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class MvsDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected AudioVideoManagement::Interface::Ftc::VideoTeamModifyReplyHandler
|
||||
class MvsDialog : public LtsWidgets::LtsDialog,
|
||||
protected AudioVideoManagement::Interface::Ftc::VideoTeamModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MvsDialog(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~MvsDialog();
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MvsDialog(const QString& menuGroup, LtsSession::LtsSession* session, QWidget* parent = nullptr);
|
||||
~MvsDialog();
|
||||
|
||||
bool init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc, const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &avmFtc);
|
||||
bool init(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& avmFtc);
|
||||
|
||||
void onVideoTeamModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onVideoTeamModifyReply(const Core::FunctionReplyObject& replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
private Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
private:
|
||||
LtsSession::LtsSession* m_session;
|
||||
Ui::MvsDialog* m_ui;
|
||||
QString m_menuGroup;
|
||||
MvsModel* m_model;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::MvsDialog *m_ui;
|
||||
QString m_menuGroup;
|
||||
MvsModel *m_model;
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
}
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_avmFtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+33
-44
@@ -1,13 +1,11 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
class QCheckBox;
|
||||
|
||||
@@ -16,55 +14,46 @@ namespace Ui
|
||||
class EditVideoTeamDialog;
|
||||
}
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class EditVideoTeamDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
class EditVideoTeamDialog : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EditVideoTeamDialog(const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc,
|
||||
int32_t exerciseId,
|
||||
QWidget *parent = nullptr);
|
||||
explicit EditVideoTeamDialog(int32_t id,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc,
|
||||
int32_t exerciseId,
|
||||
const VideoTeam &team,
|
||||
QWidget *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit EditVideoTeamDialog(const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
int32_t exerciseId, QWidget* parent = nullptr);
|
||||
explicit EditVideoTeamDialog(int32_t id, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
int32_t exerciseId, const VideoTeam& team, QWidget* parent);
|
||||
|
||||
~EditVideoTeamDialog();
|
||||
~EditVideoTeamDialog();
|
||||
|
||||
void retranslate() override;
|
||||
void retranslate() override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void modifyRequest(const AudioVideoManagement::VideoTeamModifyRequest &request);
|
||||
Q_SIGNALS:
|
||||
void modifyRequest(const AudioVideoManagement::VideoTeamModifyRequest& request);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool apply() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool apply() override;
|
||||
private:
|
||||
EditVideoTeamDialog(int32_t id, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc,
|
||||
int32_t exerciseId, QWidget* parent);
|
||||
|
||||
private:
|
||||
EditVideoTeamDialog(int32_t id,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc,
|
||||
int32_t exerciseId,
|
||||
QWidget *parent);
|
||||
void init();
|
||||
|
||||
void init();
|
||||
private Q_SLOTS:
|
||||
void onCheckTakenTeams();
|
||||
void onCurrentTeamChanged();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCheckTakenTeams();
|
||||
void onCurrentTeamChanged();
|
||||
private:
|
||||
Ui::EditVideoTeamDialog* m_ui;
|
||||
|
||||
private:
|
||||
Ui::EditVideoTeamDialog *m_ui;
|
||||
|
||||
int32_t m_exerciseId;
|
||||
int32_t m_id;
|
||||
VideoTeam m_videoTeam;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
QMap<QString, int32_t> m_takenTeams;
|
||||
QMap<QString, int32_t> m_teamsToIndex;
|
||||
};
|
||||
}
|
||||
int32_t m_exerciseId;
|
||||
int32_t m_id;
|
||||
VideoTeam m_videoTeam;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
QMap<QString, int32_t> m_takenTeams;
|
||||
QMap<QString, int32_t> m_teamsToIndex;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+98
-106
@@ -1,138 +1,130 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_mvs_dialog.h"
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
MvsModel::MvsModel(QObject *parent)
|
||||
: LtsAbstractTableModel<AudioVideoManagement::VideoTeam>(
|
||||
MvsModel::MvsModel(QObject* parent)
|
||||
: LtsAbstractTableModel<AudioVideoManagement::VideoTeam>({tr("Video Team Name"), tr("Stream Name")}, parent),
|
||||
m_exerciseId(-1)
|
||||
{
|
||||
tr("Video Team Name"),
|
||||
tr("Stream Name")
|
||||
}, parent)
|
||||
, m_exerciseId(-1)
|
||||
{}
|
||||
|
||||
QVariant MvsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const AudioVideoManagement::VideoTeam &config = m_vecData.at(index.row());
|
||||
|
||||
switch (index.column())
|
||||
{
|
||||
case CHANNEL:
|
||||
return QString::fromStdString(m_videoTeams.value(config.id()).name());
|
||||
case STREAM_NAME:
|
||||
return QString::fromStdString(config.streamName());
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool MvsModel::init(int32_t exerciseId, const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc)
|
||||
QVariant MvsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
m_avmDtc = avmDtc;
|
||||
m_exerciseId = exerciseId;
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
m_videoTeams = avmDtc->videoTeams();
|
||||
const AudioVideoManagement::VideoTeam& config = m_vecData.at(index.row());
|
||||
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::videoTeamChanged,
|
||||
this, [this](const AudioVideoManagement::VideoTeam & data, DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
switch (index.column())
|
||||
{
|
||||
case CHANNEL:
|
||||
return QString::fromStdString(m_videoTeams.value(config.id()).name());
|
||||
case STREAM_NAME:
|
||||
return QString::fromStdString(config.streamName());
|
||||
}
|
||||
|
||||
if (data.exerciseId() == m_exerciseId)
|
||||
onDataChanged(data, DataModification::eAdded);
|
||||
else
|
||||
onDataChanged(data, DataModification::eRemoved);
|
||||
}
|
||||
);
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVector<AudioVideoManagement::VideoTeam> configs;
|
||||
const QMap<int, AudioVideoManagement::VideoTeam> configMap = m_avmDtc->videoTeams();
|
||||
for (auto it = configMap.begin(); it != configMap.end(); ++it)
|
||||
{
|
||||
if (it.value().exerciseId() == m_exerciseId)
|
||||
configs.append(it.value());
|
||||
}
|
||||
setData(configs);
|
||||
bool MvsModel::init(int32_t exerciseId, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc)
|
||||
{
|
||||
m_avmDtc = avmDtc;
|
||||
m_exerciseId = exerciseId;
|
||||
|
||||
return true;
|
||||
m_videoTeams = avmDtc->videoTeams();
|
||||
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::videoTeamChanged, this,
|
||||
[this](const AudioVideoManagement::VideoTeam& data, DataModification modType) {
|
||||
Q_UNUSED(modType);
|
||||
|
||||
if (data.exerciseId() == m_exerciseId)
|
||||
onDataChanged(data, DataModification::eAdded);
|
||||
else
|
||||
onDataChanged(data, DataModification::eRemoved);
|
||||
});
|
||||
|
||||
QVector<AudioVideoManagement::VideoTeam> configs;
|
||||
const QMap<int, AudioVideoManagement::VideoTeam> configMap = m_avmDtc->videoTeams();
|
||||
for (auto it = configMap.begin(); it != configMap.end(); ++it)
|
||||
{
|
||||
if (it.value().exerciseId() == m_exerciseId)
|
||||
configs.append(it.value());
|
||||
}
|
||||
setData(configs);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray MvsModel::modelToJson()
|
||||
{
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMMvsDialog);
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMMvsDialog);
|
||||
|
||||
for (int row = 0; row < rowCount(); row++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
QJsonObject inner;
|
||||
const VideoTeam &config = m_vecData.at(row);
|
||||
inner[QStringLiteral("id")] = config.id();
|
||||
inner[QStringLiteral("exerciseId")] = config.exerciseId();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(config.name());
|
||||
inner[QStringLiteral("streamName")] = QString::fromStdString(config.streamName());
|
||||
arr += inner;
|
||||
}
|
||||
for (int row = 0; row < rowCount(); row++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "row =" << ": " << row;
|
||||
QJsonObject inner;
|
||||
const VideoTeam& config = m_vecData.at(row);
|
||||
inner[QStringLiteral("id")] = config.id();
|
||||
inner[QStringLiteral("exerciseId")] = config.exerciseId();
|
||||
inner[QStringLiteral("name")] = QString::fromStdString(config.name());
|
||||
inner[QStringLiteral("streamName")] = QString::fromStdString(config.streamName());
|
||||
arr += inner;
|
||||
}
|
||||
|
||||
obj[QStringLiteral("videoTeams")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
obj[QStringLiteral("videoTeams")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
QVector<VideoTeamModifyRequest> MvsModel::jsonToVideoTeamVector(const QByteArray &content)
|
||||
{
|
||||
|
||||
QVector<VideoTeamModifyRequest> result;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
const QJsonArray arr(obj.value(QStringLiteral("videoTeams")).toArray());
|
||||
for (const auto &ele : arr)
|
||||
{
|
||||
const QJsonObject obj(ele.toObject());
|
||||
int id = obj[QStringLiteral("id")].toInt();
|
||||
if (id <= 0)
|
||||
return QVector<VideoTeamModifyRequest>();
|
||||
|
||||
const VideoTeam team = m_avmDtc->videoTeam(id);
|
||||
if (!m_avmDtc->isFreeVideoTeam(m_exerciseId, id))
|
||||
continue;
|
||||
|
||||
VideoTeamModifyRequest config;
|
||||
config.id(id);
|
||||
config.name(team.name());
|
||||
config.ssrc(team.ssrc());
|
||||
config.vtPort(team.vtPort());
|
||||
config.exerciseId(m_exerciseId);
|
||||
config.streamName(obj[QStringLiteral("streamName")].toString().toStdString());
|
||||
|
||||
INFO_LOG(m_logger) << "insertRow: " << config.name()
|
||||
<< " VideoTeamId=" << config.id();
|
||||
result.append(std::move(config));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool MvsModel::isFiltered(const VideoTeam &data, DataModification modType) const
|
||||
QVector<VideoTeamModifyRequest> MvsModel::jsonToVideoTeamVector(const QByteArray& content)
|
||||
{
|
||||
|
||||
Q_UNUSED(modType)
|
||||
if (data.exerciseId() != m_exerciseId)
|
||||
return true;
|
||||
return false;
|
||||
QVector<VideoTeamModifyRequest> result;
|
||||
const QJsonDocument doc(QJsonDocument::fromJson(content));
|
||||
const QJsonObject obj(doc.object());
|
||||
const QJsonArray arr(obj.value(QStringLiteral("videoTeams")).toArray());
|
||||
for (const auto& ele : arr)
|
||||
{
|
||||
const QJsonObject obj(ele.toObject());
|
||||
int id = obj[QStringLiteral("id")].toInt();
|
||||
if (id <= 0)
|
||||
return QVector<VideoTeamModifyRequest>();
|
||||
|
||||
const VideoTeam team = m_avmDtc->videoTeam(id);
|
||||
if (!m_avmDtc->isFreeVideoTeam(m_exerciseId, id))
|
||||
continue;
|
||||
|
||||
VideoTeamModifyRequest config;
|
||||
config.id(id);
|
||||
config.name(team.name());
|
||||
config.ssrc(team.ssrc());
|
||||
config.vtPort(team.vtPort());
|
||||
config.exerciseId(m_exerciseId);
|
||||
config.streamName(obj[QStringLiteral("streamName")].toString().toStdString());
|
||||
|
||||
INFO_LOG(m_logger) << "insertRow: " << config.name() << " VideoTeamId=" << config.id();
|
||||
result.append(std::move(config));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
bool MvsModel::isFiltered(const VideoTeam& data, DataModification modType) const
|
||||
{
|
||||
|
||||
Q_UNUSED(modType)
|
||||
if (data.exerciseId() != m_exerciseId)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+20
-28
@@ -1,46 +1,38 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <memory>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class MvsModel final
|
||||
: public LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::VideoTeam>
|
||||
class MvsModel final : public LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::VideoTeam>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
CHANNEL,
|
||||
STREAM_NAME,
|
||||
COUNT
|
||||
};
|
||||
public:
|
||||
enum Columns { CHANNEL, STREAM_NAME, COUNT };
|
||||
|
||||
explicit MvsModel(QObject *parent = nullptr);
|
||||
explicit MvsModel(QObject* parent = nullptr);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
QVariant data(const QModelIndex& index, int role) const override final;
|
||||
|
||||
bool init(int32_t exerciseId, const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &avmDtc);
|
||||
QByteArray modelToJson();
|
||||
QVector<VideoTeamModifyRequest> jsonToVideoTeamVector(const QByteArray &content);
|
||||
bool isFiltered(const VideoTeam &data, DataModification modType) const override;
|
||||
private:
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
int32_t m_exerciseId;
|
||||
bool init(int32_t exerciseId, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc);
|
||||
QByteArray modelToJson();
|
||||
QVector<VideoTeamModifyRequest> jsonToVideoTeamVector(const QByteArray& content);
|
||||
bool isFiltered(const VideoTeam& data, DataModification modType) const override;
|
||||
|
||||
QMap<int32_t, AudioVideoManagement::VideoTeam> m_videoTeams;
|
||||
};
|
||||
}
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
int32_t m_exerciseId;
|
||||
|
||||
QMap<int32_t, AudioVideoManagement::VideoTeam> m_videoTeams;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::VideoTeam)
|
||||
Executable → Regular
+173
-201
@@ -1,265 +1,237 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_mvs_video_team_dialog.h"
|
||||
#include "ui_avm_mvs_video_team_dialog.h"
|
||||
|
||||
#include "receiverelement.h"
|
||||
#include "ui_avm_mvs_video_team_dialog.h"
|
||||
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <Plugins/AudioVideoManagement/avm_mvs_video_team_gui_plugin_interface.h>
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <QButtonGroup>
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
MvsVideoTeamDialog::MvsVideoTeamDialog(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::MvsVideoTeamDialog)
|
||||
, m_session(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_flmGui(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
MvsVideoTeamDialog::MvsVideoTeamDialog(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_ui(new Ui::MvsVideoTeamDialog),
|
||||
m_session(nullptr), m_dtc(nullptr), m_ftc(nullptr), m_flmGui(nullptr),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Mobile_Video_System"));
|
||||
|
||||
}
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Mobile_Video_System"));
|
||||
}
|
||||
|
||||
MvsVideoTeamDialog::~MvsVideoTeamDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void MvsVideoTeamDialog::retranslate()
|
||||
{
|
||||
QString text = tr("Mobile Video System");
|
||||
translate(m_ui, text);
|
||||
QString text = tr("Mobile Video System");
|
||||
translate(m_ui, text);
|
||||
}
|
||||
|
||||
void MvsVideoTeamDialog::enaDisa(bool enable)
|
||||
{
|
||||
Q_UNUSED(enable);
|
||||
|
||||
if (!m_flmGui)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Export, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Import, false);
|
||||
}
|
||||
Q_UNUSED(enable);
|
||||
|
||||
if (!m_flmGui)
|
||||
{
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Export, false);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Import, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool MvsVideoTeamDialog::init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc)
|
||||
bool MvsVideoTeamDialog::init(LtsSession::LtsSession* session,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc)
|
||||
{
|
||||
m_session = session;
|
||||
m_session = session;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
|
||||
session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui);
|
||||
session->getDtc<InfrastructureManagement::DataInterface>(m_ismDtc);
|
||||
session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui);
|
||||
session->getDtc<InfrastructureManagement::DataInterface>(m_ismDtc);
|
||||
|
||||
m_receiverMap = m_dtc->videoReceivers();
|
||||
m_receiverMap = m_dtc->videoReceivers();
|
||||
|
||||
int row = 1;
|
||||
int column = 2;
|
||||
|
||||
|
||||
int row = 1;
|
||||
int column = 2;
|
||||
QMap<std::string, VideoTeam> teamMap;
|
||||
auto cbVt = [this, &row, &teamMap](const AudioVideoManagement::VideoTeam& vt) {
|
||||
if (vt.exerciseId() != m_session->exerciseId())
|
||||
return;
|
||||
|
||||
QMap<std::string , VideoTeam> teamMap;
|
||||
auto cbVt = [this, &row, &teamMap](const AudioVideoManagement::VideoTeam & vt)
|
||||
{
|
||||
if (vt.exerciseId() != m_session->exerciseId())
|
||||
return;
|
||||
|
||||
|
||||
m_teamToRow.insert(vt.programId() == 3 ? 2 : 1, vt.programId() == 3 ? 2 : 1);
|
||||
teamMap.insert(vt.name(), vt);
|
||||
};
|
||||
m_dtc->videoTeams(cbVt);
|
||||
m_teamToRow.insert(vt.programId() == 3 ? 2 : 1, vt.programId() == 3 ? 2 : 1);
|
||||
teamMap.insert(vt.name(), vt);
|
||||
};
|
||||
m_dtc->videoTeams(cbVt);
|
||||
|
||||
const QMap<int, AudioVideoManagement::VideoReceiver> vts = m_dtc->videoReceivers();
|
||||
QSet<int> teamId;
|
||||
for (auto rec : vts)
|
||||
{
|
||||
if (teamMap.value(rec.streamName()).id() > 0)
|
||||
teamId.insert(rec.teamId());
|
||||
}
|
||||
for (auto team: teamId)
|
||||
{
|
||||
QLabel *lbl = new QLabel(QStringLiteral("MLVS")+QString::number(team), this);
|
||||
m_ui->glMvs->addWidget(lbl, team == 1 ? 1 : 2, 0);
|
||||
}
|
||||
|
||||
auto cbMs = [this, &column](const InfrastructureManagement::MainStructureElement & mse)
|
||||
{
|
||||
if (mse.structureElementTypeId() == InfrastructureManagement::StructureElementType::RadioStation && !mse.isDeleted() && mse.id() > 0)
|
||||
const QMap<int, AudioVideoManagement::VideoReceiver> vts = m_dtc->videoReceivers();
|
||||
QSet<int> teamId;
|
||||
for (auto rec : vts)
|
||||
{
|
||||
m_stationToColumn.insert(mse.id(), column);
|
||||
QLabel *lblStation = new QLabel(QString::fromStdString(mse.name()), this);
|
||||
lblStation->setProperty("RadioStation", true);
|
||||
lblStation->setProperty("column", column);
|
||||
lblStation->setProperty("name", QString::fromStdString(mse.name()));
|
||||
m_ui->glMvs->addWidget(lblStation, 0, column++);
|
||||
lblStation->hide();
|
||||
if (teamMap.value(rec.streamName()).id() > 0)
|
||||
teamId.insert(rec.teamId());
|
||||
}
|
||||
};
|
||||
m_ismDtc->mainStructureElements(cbMs);
|
||||
|
||||
auto cbRec = [this, teamMap](const AudioVideoManagement::VideoReceiver & rec)
|
||||
{
|
||||
if (m_teamToRow.value(rec.teamId()) <= 0)
|
||||
return;
|
||||
if (!teamMap.contains(rec.streamName()))
|
||||
return;
|
||||
m_receiverMap.insert(rec.id(), rec);
|
||||
if (m_stationToColumn.value(rec.mainStructureElementId()) > 0 && m_teamToRow.value(rec.teamId()) > 0)
|
||||
for (auto team : teamId)
|
||||
{
|
||||
ReceiverElement *btn = createReceiverElement(rec);
|
||||
|
||||
int row = m_teamToRow.value(rec.teamId());
|
||||
int column = m_stationToColumn.value(rec.mainStructureElementId());
|
||||
if (!m_videoTeamButtonGroup.contains(row))
|
||||
{
|
||||
QRadioButton *none = new QRadioButton(tr("None"), this);
|
||||
none->setChecked(true);
|
||||
QLabel* lbl = new QLabel(QStringLiteral("MLVS") + QString::number(team), this);
|
||||
m_ui->glMvs->addWidget(lbl, team == 1 ? 1 : 2, 0);
|
||||
}
|
||||
|
||||
m_ui->glMvs->addWidget(none, row, 1);
|
||||
m_videoTeamButtonGroup.insert(row, new QButtonGroup(this));
|
||||
m_videoTeamButtonGroup[row]->addButton(none, 0);
|
||||
}
|
||||
m_videoTeamButtonGroup[row]->addButton(btn->radioButton(), rec.mainStructureElementId());
|
||||
m_videoTeamButtonGroup[row]->setProperty("teamId", rec.teamId());
|
||||
m_receiverIds.insert(QPair<int, int>(rec.mainStructureElementId(), rec.teamId()), rec.id());
|
||||
bool isActive = rec.isActive();
|
||||
btn->setButtonChecked(isActive);
|
||||
btn->radioButton()->setChecked(isActive);
|
||||
m_ui->glMvs->addWidget(btn, row, column);
|
||||
|
||||
for (int i = 0; i < m_ui->glMvs->count(); i++)
|
||||
{
|
||||
QWidget* widget = m_ui->glMvs->itemAt(i)->widget();
|
||||
if ( widget->property("RadioStation").toBool() && widget->property("column").toInt() == column)
|
||||
auto cbMs = [this, &column](const InfrastructureManagement::MainStructureElement& mse) {
|
||||
if (mse.structureElementTypeId() == InfrastructureManagement::StructureElementType::RadioStation &&
|
||||
!mse.isDeleted() && mse.id() > 0)
|
||||
{
|
||||
widget->show();
|
||||
m_stationToColumn.insert(mse.id(), column);
|
||||
QLabel* lblStation = new QLabel(QString::fromStdString(mse.name()), this);
|
||||
lblStation->setProperty("RadioStation", true);
|
||||
lblStation->setProperty("column", column);
|
||||
lblStation->setProperty("name", QString::fromStdString(mse.name()));
|
||||
m_ui->glMvs->addWidget(lblStation, 0, column++);
|
||||
lblStation->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
m_dtc->videoReceivers(cbRec);
|
||||
enaDisa(true);
|
||||
};
|
||||
m_ismDtc->mainStructureElements(cbMs);
|
||||
|
||||
auto cbRec = [this, teamMap](const AudioVideoManagement::VideoReceiver& rec) {
|
||||
if (m_teamToRow.value(rec.teamId()) <= 0)
|
||||
return;
|
||||
if (!teamMap.contains(rec.streamName()))
|
||||
return;
|
||||
m_receiverMap.insert(rec.id(), rec);
|
||||
if (m_stationToColumn.value(rec.mainStructureElementId()) > 0 && m_teamToRow.value(rec.teamId()) > 0)
|
||||
{
|
||||
ReceiverElement* btn = createReceiverElement(rec);
|
||||
|
||||
connect(m_dtc.get(), &AudioVideoManagement::Interface::Dtc::videoReceiverChanged, this, &MvsVideoTeamDialog::updateReceiverButton);
|
||||
int row = m_teamToRow.value(rec.teamId());
|
||||
int column = m_stationToColumn.value(rec.mainStructureElementId());
|
||||
if (!m_videoTeamButtonGroup.contains(row))
|
||||
{
|
||||
QRadioButton* none = new QRadioButton(tr("None"), this);
|
||||
none->setChecked(true);
|
||||
|
||||
return true;
|
||||
m_ui->glMvs->addWidget(none, row, 1);
|
||||
m_videoTeamButtonGroup.insert(row, new QButtonGroup(this));
|
||||
m_videoTeamButtonGroup[row]->addButton(none, 0);
|
||||
}
|
||||
m_videoTeamButtonGroup[row]->addButton(btn->radioButton(), rec.mainStructureElementId());
|
||||
m_videoTeamButtonGroup[row]->setProperty("teamId", rec.teamId());
|
||||
m_receiverIds.insert(QPair<int, int>(rec.mainStructureElementId(), rec.teamId()), rec.id());
|
||||
bool isActive = rec.isActive();
|
||||
btn->setButtonChecked(isActive);
|
||||
btn->radioButton()->setChecked(isActive);
|
||||
m_ui->glMvs->addWidget(btn, row, column);
|
||||
|
||||
for (int i = 0; i < m_ui->glMvs->count(); i++)
|
||||
{
|
||||
QWidget* widget = m_ui->glMvs->itemAt(i)->widget();
|
||||
if (widget->property("RadioStation").toBool() && widget->property("column").toInt() == column)
|
||||
{
|
||||
widget->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
m_dtc->videoReceivers(cbRec);
|
||||
enaDisa(true);
|
||||
|
||||
connect(m_dtc.get(), &AudioVideoManagement::Interface::Dtc::videoReceiverChanged, this,
|
||||
&MvsVideoTeamDialog::updateReceiverButton);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MvsVideoTeamDialog::setData()
|
||||
{
|
||||
|
||||
}
|
||||
void MvsVideoTeamDialog::setData() {}
|
||||
|
||||
bool MvsVideoTeamDialog::apply()
|
||||
{
|
||||
VideoReceiverModifyActiveRequest req;
|
||||
DEBUG_LOG(m_logger) << "apply m_videoTeamButtonGroup.size=" << m_videoTeamButtonGroup.size();
|
||||
QMap<int, QButtonGroup *> ::const_iterator itBg;
|
||||
for (itBg = m_videoTeamButtonGroup.constBegin(); itBg != m_videoTeamButtonGroup.constEnd(); ++itBg)
|
||||
{
|
||||
int teamId = itBg.value()->property("teamId").toInt();
|
||||
int mainStructureElementId = itBg.value()->checkedId();
|
||||
int oldActiveId = m_dtc->getActiveVideoReceiver(teamId);
|
||||
|
||||
DEBUG_LOG(m_logger) << "Team id = " << teamId;
|
||||
DEBUG_LOG(m_logger) << "Main structure element id = " << mainStructureElementId;
|
||||
DEBUG_LOG(m_logger) << "Old active video receiver = " << oldActiveId;
|
||||
|
||||
if (itBg.value()->checkedId() == 0)
|
||||
VideoReceiverModifyActiveRequest req;
|
||||
DEBUG_LOG(m_logger) << "apply m_videoTeamButtonGroup.size=" << m_videoTeamButtonGroup.size();
|
||||
QMap<int, QButtonGroup*>::const_iterator itBg;
|
||||
for (itBg = m_videoTeamButtonGroup.constBegin(); itBg != m_videoTeamButtonGroup.constEnd(); ++itBg)
|
||||
{
|
||||
req.isActive(false);
|
||||
req.id(0);
|
||||
QMapIterator<qint32, AudioVideoManagement::VideoReceiver> i(m_receiverMap);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if ((i.value().isActive())
|
||||
&& i.value().teamId() == teamId)
|
||||
req.id(i.value().id());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
req.isActive(true);
|
||||
req.id(m_receiverIds.value(QPair<int, int>(mainStructureElementId, teamId)));
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "itBg.key=" << itBg.key()
|
||||
<< " mainStructureElementId=" << mainStructureElementId
|
||||
<< " teamId=" << teamId
|
||||
<< " id=" << req.id()
|
||||
<< " isActive=" << req.isActive();
|
||||
int teamId = itBg.value()->property("teamId").toInt();
|
||||
int mainStructureElementId = itBg.value()->checkedId();
|
||||
int oldActiveId = m_dtc->getActiveVideoReceiver(teamId);
|
||||
|
||||
|
||||
if ((m_receiverMap.value(req.id()).isActive() != req.isActive())
|
||||
&& req.id() > 0)
|
||||
{
|
||||
|
||||
if (oldActiveId > 0)
|
||||
{
|
||||
VideoReceiverModifyActiveRequest reqInactive;
|
||||
reqInactive.id(oldActiveId);
|
||||
reqInactive.isActive(false);
|
||||
m_requestHelper->addRequest([this, reqInactive]()
|
||||
DEBUG_LOG(m_logger) << "Team id = " << teamId;
|
||||
DEBUG_LOG(m_logger) << "Main structure element id = " << mainStructureElementId;
|
||||
DEBUG_LOG(m_logger) << "Old active video receiver = " << oldActiveId;
|
||||
|
||||
if (itBg.value()->checkedId() == 0)
|
||||
{
|
||||
return m_ftc->videoReceiverModifyActiveRequest(reqInactive, this);
|
||||
});
|
||||
}
|
||||
m_requestHelper->addRequest([this, req]()
|
||||
{
|
||||
return m_ftc->videoReceiverModifyActiveRequest(req, this);
|
||||
});
|
||||
req.isActive(false);
|
||||
req.id(0);
|
||||
QMapIterator<qint32, AudioVideoManagement::VideoReceiver> i(m_receiverMap);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if ((i.value().isActive()) && i.value().teamId() == teamId)
|
||||
req.id(i.value().id());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
req.isActive(true);
|
||||
req.id(m_receiverIds.value(QPair<int, int>(mainStructureElementId, teamId)));
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "itBg.key=" << itBg.key() << " mainStructureElementId=" << mainStructureElementId
|
||||
<< " teamId=" << teamId << " id=" << req.id() << " isActive=" << req.isActive();
|
||||
|
||||
if ((m_receiverMap.value(req.id()).isActive() != req.isActive()) && req.id() > 0)
|
||||
{
|
||||
|
||||
if (oldActiveId > 0)
|
||||
{
|
||||
VideoReceiverModifyActiveRequest reqInactive;
|
||||
reqInactive.id(oldActiveId);
|
||||
reqInactive.isActive(false);
|
||||
m_requestHelper->addRequest(
|
||||
[this, reqInactive]() { return m_ftc->videoReceiverModifyActiveRequest(reqInactive, this); });
|
||||
}
|
||||
m_requestHelper->addRequest([this, req]() { return m_ftc->videoReceiverModifyActiveRequest(req, this); });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
ReceiverElement *MvsVideoTeamDialog::createReceiverElement(const VideoReceiver &rec)
|
||||
ReceiverElement* MvsVideoTeamDialog::createReceiverElement(const VideoReceiver& rec)
|
||||
{
|
||||
ReceiverElement *re = new ReceiverElement(this);
|
||||
re->init(rec);
|
||||
if (rec.isActive())
|
||||
m_oldActiveTeamToRec.insert(rec.teamId(), rec.id());
|
||||
m_elementList.insert(rec.teamId(), re);
|
||||
return re;
|
||||
ReceiverElement* re = new ReceiverElement(this);
|
||||
re->init(rec);
|
||||
if (rec.isActive())
|
||||
m_oldActiveTeamToRec.insert(rec.teamId(), rec.id());
|
||||
m_elementList.insert(rec.teamId(), re);
|
||||
return re;
|
||||
}
|
||||
|
||||
void MvsVideoTeamDialog::updateReceiverButton(const AudioVideoManagement::VideoReceiver &rec, DataModification modType)
|
||||
void MvsVideoTeamDialog::updateReceiverButton(const AudioVideoManagement::VideoReceiver& rec, DataModification modType)
|
||||
{
|
||||
Q_UNUSED(modType);
|
||||
m_receiverMap.insert(rec.id(), rec);
|
||||
for (auto it = m_elementList.lowerBound(rec.teamId()) ; it != m_elementList.end(); ++it)
|
||||
{
|
||||
if (it.key() != rec.teamId())
|
||||
break;
|
||||
auto *receiverElement = it.value();
|
||||
if (receiverElement->property("recId").toInt() != rec.id())
|
||||
continue;
|
||||
Q_UNUSED(modType);
|
||||
m_receiverMap.insert(rec.id(), rec);
|
||||
for (auto it = m_elementList.lowerBound(rec.teamId()); it != m_elementList.end(); ++it)
|
||||
{
|
||||
if (it.key() != rec.teamId())
|
||||
break;
|
||||
auto* receiverElement = it.value();
|
||||
if (receiverElement->property("recId").toInt() != rec.id())
|
||||
continue;
|
||||
|
||||
receiverElement->setButtonChecked(rec.isActive());
|
||||
receiverElement->setSnr(rec.snr());
|
||||
receiverElement->setDbm(rec.dbm());
|
||||
receiverElement->setStreamName(QString::fromStdString(rec.streamName()));
|
||||
receiverElement->setFrequency(rec.frequency());
|
||||
receiverElement->setIsLocked(rec.isLocked());
|
||||
}
|
||||
receiverElement->setButtonChecked(rec.isActive());
|
||||
receiverElement->setSnr(rec.snr());
|
||||
receiverElement->setDbm(rec.dbm());
|
||||
receiverElement->setStreamName(QString::fromStdString(rec.streamName()));
|
||||
receiverElement->setFrequency(rec.frequency());
|
||||
receiverElement->setIsLocked(rec.isLocked());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+45
-53
@@ -1,21 +1,15 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
#include <Services/AudioVideoManagement/logger.h>
|
||||
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
#include <Services/AudioVideoManagement/avm_dtc.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
#include <Plugins/InfrastructureManagement/ism_data_plugin_interface.h>
|
||||
|
||||
#include <Services/AudioVideoManagement/avm_dtc.h>
|
||||
#include <Services/AudioVideoManagement/avm_ftc.h>
|
||||
#include <Services/AudioVideoManagement/logger.h>
|
||||
|
||||
namespace LtsWidgets
|
||||
{
|
||||
@@ -28,66 +22,64 @@ class MvsVideoTeamDialog;
|
||||
}
|
||||
|
||||
class ReceiverElement;
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
class MvsVideoTeamDialog : public LtsWidgets::LtsDialog,
|
||||
private AudioVideoManagement::Interface::Ftc::VideoReceiverModifyActiveReplyHandler
|
||||
private AudioVideoManagement::Interface::Ftc::VideoReceiverModifyActiveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MvsVideoTeamDialog(QWidget *parent = nullptr);
|
||||
~MvsVideoTeamDialog();
|
||||
public:
|
||||
explicit MvsVideoTeamDialog(QWidget* parent = nullptr);
|
||||
~MvsVideoTeamDialog();
|
||||
|
||||
bool init(LtsSession::LtsSession *session,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc> &ftc);
|
||||
bool init(LtsSession::LtsSession* session, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Ftc>& ftc);
|
||||
|
||||
void onVideoReceiverModifyActiveReply(const Core::FunctionReplyObject &reply) override final { m_requestHelper->requestReply(reply); }
|
||||
void onVideoReceiverModifyActiveReply(const Core::FunctionReplyObject& reply) override final
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
ReceiverElement* createReceiverElement(const VideoReceiver& rec);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
ReceiverElement *createReceiverElement(const VideoReceiver &rec);
|
||||
private slots:
|
||||
bool apply() override;
|
||||
void updateReceiverButton(const AudioVideoManagement::VideoReceiver& rec, DataModification modType);
|
||||
|
||||
private slots:
|
||||
bool apply() override;
|
||||
void updateReceiverButton(const AudioVideoManagement::VideoReceiver &rec, DataModification modType);
|
||||
private:
|
||||
void retranslate() override;
|
||||
void enaDisa(bool enable);
|
||||
void setData();
|
||||
|
||||
private:
|
||||
Ui::MvsVideoTeamDialog* m_ui;
|
||||
LtsSession::LtsSession* m_session;
|
||||
QString m_menuGroup;
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void enaDisa(bool enable);
|
||||
void setData();
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
|
||||
private:
|
||||
Ui::MvsVideoTeamDialog *m_ui;
|
||||
LtsSession::LtsSession *m_session;
|
||||
QString m_menuGroup;
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Ftc> m_ftc;
|
||||
AudioVideoManagement::VideoReceiver m_data;
|
||||
|
||||
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_ismDtc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
|
||||
AudioVideoManagement::VideoReceiver m_data;
|
||||
QMap<qint32, AudioVideoManagement::VideoReceiver> m_receiverMap;
|
||||
QMap<int, QButtonGroup*> m_videoTeamButtonGroup;
|
||||
QMap<int, int> m_stationToColumn;
|
||||
QMap<int, int> m_teamToRow;
|
||||
QMultiMap<int, ReceiverElement*> m_elementList;
|
||||
QMap<int, int> m_oldActiveTeamToRec;
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
QHash<QPair<int, int>, int> m_receiverIds;
|
||||
|
||||
QMap<qint32, AudioVideoManagement::VideoReceiver> m_receiverMap;
|
||||
QMap<int, QButtonGroup *> m_videoTeamButtonGroup;
|
||||
QMap<int, int> m_stationToColumn;
|
||||
QMap<int, int> m_teamToRow;
|
||||
QMultiMap<int, ReceiverElement *> m_elementList;
|
||||
QMap<int, int> m_oldActiveTeamToRec;
|
||||
|
||||
|
||||
|
||||
|
||||
QHash<QPair<int, int>, int> m_receiverIds;
|
||||
|
||||
QVector <int> mainStructureElementIds;
|
||||
QVector<int> mainStructureElementIds;
|
||||
};
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+52
-65
@@ -1,16 +1,13 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/avm.hpp>
|
||||
|
||||
#include <QVector>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
|
||||
class QCheckBox;
|
||||
|
||||
@@ -25,7 +22,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -33,80 +30,70 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace LtsUtils
|
||||
{
|
||||
class RequestHelper;
|
||||
}
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class EditTrainingVoiceCommunicationDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ModifyTvcConfigReplyHandler
|
||||
class EditTrainingVoiceCommunicationDialog : public LtsWidgets::LtsDialog,
|
||||
protected Interface::Ftc::ModifyTvcConfigReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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();
|
||||
|
||||
~EditTrainingVoiceCommunicationDialog();
|
||||
void retranslate() override;
|
||||
|
||||
void retranslate() override;
|
||||
protected:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool apply() override;
|
||||
void onModifyTvcConfigReply(const Core::FunctionReplyObject& reply) override;
|
||||
|
||||
protected:
|
||||
private:
|
||||
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);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool apply() override;
|
||||
void onModifyTvcConfigReply(const Core::FunctionReplyObject &reply) override;
|
||||
void init();
|
||||
void checkToDisableChkRecording();
|
||||
|
||||
private:
|
||||
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);
|
||||
private slots:
|
||||
void updateFreeChannelsAndTakenNames();
|
||||
|
||||
void init();
|
||||
void checkToDisableChkRecording();
|
||||
private:
|
||||
void updateCbChannels(QVector<int>&& freeChannels);
|
||||
QVector<int> exercisesToConsider() const;
|
||||
QVector<int> exercisesToIgnore() const;
|
||||
|
||||
private slots:
|
||||
void updateFreeChannelsAndTakenNames();
|
||||
void initCbChannelsForCreate();
|
||||
void initCbChannelsForEdit(int channelId);
|
||||
|
||||
private:
|
||||
void updateCbChannels(QVector<int> &&freeChannels);
|
||||
QVector<int> exercisesToConsider() const;
|
||||
QVector<int> exercisesToIgnore() const;
|
||||
bool isNameValid(const QString& name) const;
|
||||
|
||||
void initCbChannelsForCreate();
|
||||
void initCbChannelsForEdit(int channelId);
|
||||
|
||||
bool isNameValid(const QString &name) const;
|
||||
|
||||
private:
|
||||
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;
|
||||
};
|
||||
}
|
||||
private:
|
||||
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;
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+111
-122
@@ -1,209 +1,198 @@
|
||||
|
||||
|
||||
|
||||
#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 <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include "avm_edit_training_voice_communication_dialog.h"
|
||||
#include "avm_training_voice_communication_dialog_model.h"
|
||||
#include "ui_avm_training_voice_communication_dialog.h"
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.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)
|
||||
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_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Training_Voice_Communication"));
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Training_Voice_Communication"));
|
||||
}
|
||||
|
||||
TrainingVoiceCommunicationDialog::~TrainingVoiceCommunicationDialog() = default;
|
||||
|
||||
void TrainingVoiceCommunicationDialog::retranslate()
|
||||
{
|
||||
translate(m_ui.get(), tr("Training Voice Communication"));
|
||||
translate(m_ui.get(), tr("Training Voice Communication"));
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->dataView->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
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)
|
||||
bool TrainingVoiceCommunicationDialog::init(const std::shared_ptr<Interface::Dtc>& avmDtc,
|
||||
const std::shared_ptr<Interface::Ftc>& avmFtc,
|
||||
ExerciseManagement::Interface::Dtc* exmDtc)
|
||||
{
|
||||
Q_ASSERT(exmDtc);
|
||||
Q_ASSERT(exmDtc);
|
||||
|
||||
if (!(avmDtc->enableTvcChannel() &&
|
||||
avmDtc->enableTvcConfig() &&
|
||||
avmFtc->enableModifyTvcConfig() &&
|
||||
avmFtc->enableRemoveTvcConfig()))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable topics";
|
||||
return false;
|
||||
}
|
||||
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_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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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_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);
|
||||
|
||||
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);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &TrainingVoiceCommunicationDialog::onSelectionChanged);
|
||||
onSelectionChanged();
|
||||
|
||||
onSelectionChanged();
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&TrainingVoiceCommunicationDialog::onEditClicked);
|
||||
|
||||
connect(m_ui->dataView, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &TrainingVoiceCommunicationDialog::onEditClicked);
|
||||
m_buttonBox->connectLibraryButton(this, &TrainingVoiceCommunicationDialog::onImportButtonClicked,
|
||||
&TrainingVoiceCommunicationDialog::onExportButtonClicked);
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&TrainingVoiceCommunicationDialog::onImportButtonClicked,
|
||||
&TrainingVoiceCommunicationDialog::onExportButtonClicked);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->dataView->hideColumn(TrainingVoiceCommunicationDialogModel::RECORDING);
|
||||
m_ui->dataView->hideColumn(TrainingVoiceCommunicationDialogModel::RECORDING);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onModifyTvcConfigReply(const Core::FunctionReplyObject &replyObject)
|
||||
void TrainingVoiceCommunicationDialog::onModifyTvcConfigReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onRemoveTvcConfigReply(const Core::FunctionReplyObject &replyObject)
|
||||
void TrainingVoiceCommunicationDialog::onRemoveTvcConfigReply(const Core::FunctionReplyObject& replyObject)
|
||||
{
|
||||
m_requestHelper->requestReply(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);
|
||||
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();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
TvcConfig config = m_model->getRowData(currentIndex.row());
|
||||
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);
|
||||
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();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
if (!currentIndex.isValid())
|
||||
return;
|
||||
|
||||
Core::RemoveElementRequest request(m_model->getRowData(currentIndex.row()).id());
|
||||
Core::RemoveElementRequest request(m_model->getRowData(currentIndex.row()).id());
|
||||
|
||||
m_requestHelper->startSingleRequest([this, request]()
|
||||
{
|
||||
return m_avmFtc->removeTvcConfigRequest(request, this);
|
||||
});
|
||||
m_requestHelper->startSingleRequest([this, request]() { return m_avmFtc->removeTvcConfigRequest(request, this); });
|
||||
}
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onSelectionChanged()
|
||||
{
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
QModelIndex currentIndex = m_ui->dataView->currentIndex();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, currentIndex.isValid());
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, currentIndex.isValid());
|
||||
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());
|
||||
LtsPrinting::printView(m_session, this, m_ui->dataView->treeView());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TrainingVoiceCommunicationDialog::onExportButtonClicked()
|
||||
{
|
||||
QByteArray byteArray = m_filter->modelToJson();
|
||||
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 ";
|
||||
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() ";
|
||||
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)))
|
||||
QByteArray content;
|
||||
int fileId =
|
||||
m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Xml}, m_session->exerciseId(),
|
||||
FileManagement::toString(FileManagement::XmlType::AVMTrainingVoiceCommunication));
|
||||
if (fileId > 0)
|
||||
{
|
||||
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]()
|
||||
if (!m_flmGui->isXmlType(content,
|
||||
FileManagement::toString(FileManagement::XmlType::AVMTrainingVoiceCommunication)))
|
||||
{
|
||||
return m_avmFtc->modifyTvcConfigRequest(request, this);
|
||||
});
|
||||
}
|
||||
(void) m_requestHelper->startRequests();
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
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
|
||||
Executable → Regular
+41
-44
@@ -1,14 +1,11 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <AudioVideoManagement/avm_ftc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace Ui
|
||||
@@ -32,7 +29,7 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
namespace ExerciseManagement
|
||||
{
|
||||
@@ -40,53 +37,53 @@ namespace Interface
|
||||
{
|
||||
class Dtc;
|
||||
}
|
||||
}
|
||||
} // namespace ExerciseManagement
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
class TrainingVoiceCommunicationDialogModel;
|
||||
class TrainingVoiceCommunicationDialogFilter;
|
||||
|
||||
class TrainingVoiceCommunicationDialog
|
||||
: public LtsWidgets::LtsDialog
|
||||
, protected Interface::Ftc::ModifyTvcConfigReplyHandler
|
||||
, protected Interface::Ftc::RemoveTvcConfigReplyHandler
|
||||
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();
|
||||
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);
|
||||
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;
|
||||
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 Q_SLOTS:
|
||||
void onAddClicked();
|
||||
void onEditClicked();
|
||||
void onRemoveClicked();
|
||||
void onSelectionChanged();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
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};
|
||||
};
|
||||
}
|
||||
private:
|
||||
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};
|
||||
};
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+88
-98
@@ -1,142 +1,132 @@
|
||||
|
||||
|
||||
|
||||
#include "avm_training_voice_communication_dialog_model.h"
|
||||
#include <FileManagement/flm_translation.h>
|
||||
|
||||
#include <FileManagement/flm_translation.h>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
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)
|
||||
TrainingVoiceCommunicationDialogModel::TrainingVoiceCommunicationDialogModel(QObject* parent)
|
||||
: LtsAbstractTableModel<AudioVideoManagement::TvcConfig>(
|
||||
{tr("Channel Number"), tr("Radio Circuit"), tr("Recording"), tr("Info"), tr("Global")}, parent),
|
||||
m_exerciseId(-1)
|
||||
{
|
||||
}
|
||||
|
||||
QVariant TrainingVoiceCommunicationDialogModel::data(const QModelIndex &index, int role) const
|
||||
QVariant TrainingVoiceCommunicationDialogModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole || !indexIsValid(index))
|
||||
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();
|
||||
|
||||
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)
|
||||
bool TrainingVoiceCommunicationDialogModel::init(int32_t exerciseId,
|
||||
const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc)
|
||||
{
|
||||
m_avmDtc = avmDtc;
|
||||
m_exerciseId = exerciseId;
|
||||
m_avmDtc = avmDtc;
|
||||
m_exerciseId = exerciseId;
|
||||
|
||||
|
||||
avmDtc->waitForHistoricalDataTvcChannel(5000);
|
||||
m_tetraChannels = avmDtc->tvcChannels();
|
||||
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); });
|
||||
connect(m_avmDtc.get(), &AudioVideoManagement::Interface::Dtc::tvcConfigChanged, this,
|
||||
&TrainingVoiceCommunicationDialogModel::onDataChanged);
|
||||
m_avmDtc->tvcConfigs([this](const TvcConfig& config) { insertRow(config); });
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
QByteArray TrainingVoiceCommunicationDialogFilter::modelToJson() const
|
||||
{
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
obj[QStringLiteral("XmlType")] = FileManagement::toString(FileManagement::XmlType::AVMTrainingVoiceCommunication);
|
||||
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();
|
||||
for (int row = 0; row < rowCount(); row++)
|
||||
{
|
||||
int sourceRow = mapToSource(index(row, 0)).row();
|
||||
|
||||
QJsonObject inner;
|
||||
const TvcConfig &config = m_sourceModel->getRowData(sourceRow);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
obj[QLatin1String("tvcConfiguration")] = arr;
|
||||
QJsonDocument doc(obj);
|
||||
return doc.toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
QVector<ModifyTvcConfigRequest> TrainingVoiceCommunicationDialogModel::jsonToTvcConfigVector(const QByteArray &content) const
|
||||
QVector<ModifyTvcConfigRequest>
|
||||
TrainingVoiceCommunicationDialogModel::jsonToTvcConfigVector(const QByteArray& content) const
|
||||
{
|
||||
|
||||
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());
|
||||
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;
|
||||
|
||||
INFO_LOG(m_logger) << "insertRow: " << config.radioCircuit()
|
||||
<< " tvcChannelId=" << config.tetraChannelId();
|
||||
result.push_back(std::move(config));
|
||||
}
|
||||
return result;
|
||||
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)
|
||||
TrainingVoiceCommunicationDialogFilter::TrainingVoiceCommunicationDialogFilter(
|
||||
int32_t exerciseId, TrainingVoiceCommunicationDialogModel* sourceModel)
|
||||
: m_exerciseId(exerciseId), m_sourceModel(sourceModel)
|
||||
{
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(sourceModel);
|
||||
Q_ASSERT(sourceModel);
|
||||
setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool TrainingVoiceCommunicationDialogFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
bool TrainingVoiceCommunicationDialogFilter::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
|
||||
{
|
||||
TvcConfig tvcConfig = m_sourceModel->getRowData(sourceRow);
|
||||
TvcConfig tvcConfig = m_sourceModel->getRowData(sourceRow);
|
||||
|
||||
if (tvcConfig.exerciseId().is_set() && tvcConfig.exerciseId().get() != m_exerciseId)
|
||||
return false;
|
||||
if (tvcConfig.exerciseId().is_set() && tvcConfig.exerciseId().get() != m_exerciseId)
|
||||
return false;
|
||||
|
||||
return LtsColumnFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
return LtsColumnFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
Executable → Regular
+26
-37
@@ -1,67 +1,56 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AudioVideoManagement/avm_dtc.h>
|
||||
#include <AudioVideoManagement/logger.h>
|
||||
#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>
|
||||
: public LtsWidgets::LtsAbstractTableModel<AudioVideoManagement::TvcConfig>
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
CHANNEL,
|
||||
RADIO_CIRCUIT,
|
||||
RECORDING,
|
||||
INFO,
|
||||
GLOBAL
|
||||
};
|
||||
public:
|
||||
enum Columns { CHANNEL, RADIO_CIRCUIT, RECORDING, INFO, GLOBAL };
|
||||
|
||||
explicit TrainingVoiceCommunicationDialogModel(QObject *parent = nullptr);
|
||||
explicit TrainingVoiceCommunicationDialogModel(QObject* parent = nullptr);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override final;
|
||||
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;
|
||||
bool init(int32_t exerciseId, const std::shared_ptr<AudioVideoManagement::Interface::Dtc>& avmDtc);
|
||||
QVector<ModifyTvcConfigRequest> jsonToTvcConfigVector(const QByteArray& content) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
int32_t m_exerciseId;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<AudioVideoManagement::Interface::Dtc> m_avmDtc;
|
||||
int32_t m_exerciseId;
|
||||
|
||||
QMap<int32_t, AudioVideoManagement::TvcChannel> m_tetraChannels;
|
||||
QMap<int32_t, AudioVideoManagement::TvcChannel> m_tetraChannels;
|
||||
};
|
||||
|
||||
|
||||
class TrainingVoiceCommunicationDialogFilter : public LtsWidgets::LtsColumnFilterProxyModel
|
||||
{
|
||||
public:
|
||||
explicit TrainingVoiceCommunicationDialogFilter(int32_t exerciseId, TrainingVoiceCommunicationDialogModel *sourceModel);
|
||||
public:
|
||||
explicit TrainingVoiceCommunicationDialogFilter(int32_t exerciseId,
|
||||
TrainingVoiceCommunicationDialogModel* sourceModel);
|
||||
|
||||
QByteArray modelToJson() const;
|
||||
QByteArray modelToJson() const;
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
protected:
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override;
|
||||
|
||||
private:
|
||||
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::setSourceModel;
|
||||
private:
|
||||
using LtsWidgets::LtsColumnFilterProxyModel::setSourceModel;
|
||||
|
||||
int32_t m_exerciseId;
|
||||
TrainingVoiceCommunicationDialogModel *m_sourceModel;
|
||||
int32_t m_exerciseId;
|
||||
TrainingVoiceCommunicationDialogModel* m_sourceModel;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace AudioVideoManagement
|
||||
|
||||
Q_DECLARE_METATYPE(AudioVideoManagement::TvcConfig)
|
||||
Reference in new issue
Block a user