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
+171
-178
@@ -1,225 +1,218 @@
|
||||
|
||||
|
||||
|
||||
#include "evl_topic_editor_model.h"
|
||||
|
||||
#include <Evaluations/evl_translation.h>
|
||||
#include <QDateTime>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
#include <Evaluations/evl_translation.h>
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
|
||||
|
||||
TopicEditorEvaluationModel::TopicEditorEvaluationModel(QObject *parent) : NGLTreeModel(parent, new NGLTreeItem(QVariant()),,
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) { tr("Id"), tr("Name"), tr("Weight"), tr("Start Time"), tr("Situation"), tr("Video"), tr("Audio") })
|
||||
{}
|
||||
|
||||
TopicEditorEvaluationModel::TopicEditorEvaluationModel(QObject* parent)
|
||||
: NGLTreeModel(parent, new NGLTreeItem(QVariant()), ,
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()){tr("Id"), tr("Name"), tr("Weight"), tr("Start Time"),
|
||||
tr("Situation"), tr("Video"), tr("Audio")})
|
||||
{
|
||||
}
|
||||
|
||||
QVariant TopicEditorEvaluationModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal)
|
||||
{
|
||||
switch (section)
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal)
|
||||
{
|
||||
case ID:
|
||||
return tr("Id");
|
||||
case WEIGHT:
|
||||
return tr("Weight");
|
||||
case NAME:
|
||||
return tr("Name");
|
||||
case START_TIME:
|
||||
return tr("Start time");
|
||||
case SITUATION:
|
||||
return tr("Situation");
|
||||
case VIDEO:
|
||||
return tr("Video");
|
||||
case AUDIO:
|
||||
return tr("Audio");
|
||||
switch (section)
|
||||
{
|
||||
case ID:
|
||||
return tr("Id");
|
||||
case WEIGHT:
|
||||
return tr("Weight");
|
||||
case NAME:
|
||||
return tr("Name");
|
||||
case START_TIME:
|
||||
return tr("Start time");
|
||||
case SITUATION:
|
||||
return tr("Situation");
|
||||
case VIDEO:
|
||||
return tr("Video");
|
||||
case AUDIO:
|
||||
return tr("Audio");
|
||||
}
|
||||
}
|
||||
}
|
||||
return NGLTreeModel::headerData(section, orientation, role);
|
||||
return NGLTreeModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
|
||||
QVariant TopicEditorEvaluationModel::data(const QModelIndex &index, int role) const
|
||||
QVariant TopicEditorEvaluationModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (!(index.isValid() && (role == Qt::DisplayRole || role == Qt::UserRole)))
|
||||
if (!(index.isValid() && (role == Qt::DisplayRole || role == Qt::UserRole)))
|
||||
return QVariant();
|
||||
|
||||
NGLTreeItem* item = privateData(index);
|
||||
if (item->data().canConvert<Evaluations::EvaluationCriterium>())
|
||||
{
|
||||
EvaluationCriterium crt = item->data().value<Evaluations::EvaluationCriterium>();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case NAME:
|
||||
return QString::fromStdString(crt.name());
|
||||
case ID:
|
||||
return crt.id();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return crt.id();
|
||||
}
|
||||
else if (item->data().canConvert<Evaluations::EvaluationElement>())
|
||||
{
|
||||
|
||||
EvaluationElement elem = item->data().value<Evaluations::EvaluationElement>();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case ID:
|
||||
return elem.id();
|
||||
case NAME:
|
||||
return QString::fromStdString(elem.note());
|
||||
case WEIGHT:
|
||||
return elem.rating();
|
||||
case SITUATION:
|
||||
return elem.situation() ? tr("Yes") : tr("No");
|
||||
case AUDIO:
|
||||
return elem.audio() ? tr("Yes") : tr("No");
|
||||
case VIDEO:
|
||||
return elem.video() ? tr("Yes") : tr("No");
|
||||
case START_TIME:
|
||||
return QDateTime::fromMSecsSinceEpoch(elem.timestamp());
|
||||
}
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return elem.id();
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
NGLTreeItem *item = privateData(index);
|
||||
if (item->data().canConvert<Evaluations::EvaluationCriterium>())
|
||||
{
|
||||
EvaluationCriterium crt = item->data().value<Evaluations::EvaluationCriterium>();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case NAME:
|
||||
return QString::fromStdString(crt.name());
|
||||
case ID:
|
||||
return crt.id();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return crt.id();
|
||||
}
|
||||
else if (item->data().canConvert<Evaluations::EvaluationElement>())
|
||||
{
|
||||
|
||||
EvaluationElement elem = item->data().value<Evaluations::EvaluationElement>();
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case ID:
|
||||
return elem.id();
|
||||
case NAME:
|
||||
return QString::fromStdString(elem.note());
|
||||
case WEIGHT:
|
||||
return elem.rating();
|
||||
case SITUATION:
|
||||
return elem.situation() ? tr("Yes") : tr("No");
|
||||
case AUDIO:
|
||||
return elem.audio() ? tr("Yes") : tr("No");
|
||||
case VIDEO:
|
||||
return elem.video() ? tr("Yes") : tr("No");
|
||||
case START_TIME:
|
||||
return QDateTime::fromMSecsSinceEpoch(elem.timestamp());
|
||||
}
|
||||
}
|
||||
else if (role == Qt::UserRole)
|
||||
return elem.id();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
Qt::ItemFlags TopicEditorEvaluationModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags TopicEditorEvaluationModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
auto ret = NGLTreeModel::flags(index);
|
||||
auto ret = NGLTreeModel::flags(index);
|
||||
|
||||
|
||||
NGLTreeItem *item = privateData(index);
|
||||
if (item->data().canConvert<Evaluations::EvaluationCriterium>())
|
||||
ret &= ~Qt::ItemIsSelectable;
|
||||
NGLTreeItem* item = privateData(index);
|
||||
if (item->data().canConvert<Evaluations::EvaluationCriterium>())
|
||||
ret &= ~Qt::ItemIsSelectable;
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool TopicEditorEvaluationModel::initModel(const std::shared_ptr<Interface::Dtc> &dtc, int operatorId)
|
||||
bool TopicEditorEvaluationModel::initModel(const std::shared_ptr<Interface::Dtc>& dtc, int operatorId)
|
||||
{
|
||||
if (!dtc)
|
||||
return false;
|
||||
DEBUG_LOG(m_logger) << "initModel Folder";
|
||||
|
||||
NGLTreeModel::resetModel();
|
||||
|
||||
QHash<int, QModelIndex> parentItemIndexCache;
|
||||
const QMap<qint32, Evaluations::EvaluationCriterium> critMap = dtc->evaluationCriteriums();
|
||||
|
||||
const QMap<qint32, Evaluations::EvaluationElement> elemMap = dtc->evaluationElements();
|
||||
|
||||
parentItemIndexCache.insert(0, QModelIndex());
|
||||
|
||||
for (QMap<qint32, Evaluations::EvaluationCriterium>::const_iterator iter = critMap.constBegin();
|
||||
iter != critMap.constEnd(); ++iter)
|
||||
{
|
||||
int criteriumId = iter.key();
|
||||
|
||||
int parentId = 0;
|
||||
EvaluationCriterium crit = iter.value();
|
||||
|
||||
if (crit.operatorId() != operatorId)
|
||||
continue;
|
||||
|
||||
if (!parentItemIndexCache.contains(parentId))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid folder structure";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
QModelIndex pIndex = parentItemIndexCache.value(parentId);
|
||||
int rowPos = -1;
|
||||
|
||||
QVariant data;
|
||||
data.setValue(crit);
|
||||
onInsertRow(rowPos, pIndex, data);
|
||||
parentItemIndexCache.insert(criteriumId+10000, index(rowPos, 0, pIndex));
|
||||
DEBUG_LOG(m_logger) << "Added to tree (criterium id, parent id) : (" << criteriumId << ", " << parentId << ")";
|
||||
}
|
||||
|
||||
for (QMap<qint32, Evaluations::EvaluationElement>::const_iterator iter2 = elemMap.constBegin();
|
||||
iter2 != elemMap.constEnd(); ++iter2)
|
||||
{
|
||||
Evaluations::EvaluationElement elem = iter2.value();
|
||||
if (elem.criteriumId() != criteriumId)
|
||||
continue;
|
||||
|
||||
parentId = criteriumId + 10000;
|
||||
|
||||
if (!parentItemIndexCache.contains(parentId))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid folder structure";
|
||||
if (!dtc)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
QModelIndex pIndex = parentItemIndexCache.value(parentId);
|
||||
int rowPos = -1;
|
||||
DEBUG_LOG(m_logger) << "initModel Folder";
|
||||
|
||||
QVariant data;
|
||||
data.setValue(elem);
|
||||
onInsertRow(rowPos, pIndex, data);
|
||||
int elementId = elem.id();
|
||||
parentItemIndexCache.insert(elementId,index(rowPos, 0, pIndex));
|
||||
DEBUG_LOG(m_logger) << "Added to tree (element id, parent id) : (" << elementId << ", " << parentId << ")";
|
||||
}
|
||||
NGLTreeModel::resetModel();
|
||||
|
||||
QHash<int, QModelIndex> parentItemIndexCache;
|
||||
const QMap<qint32, Evaluations::EvaluationCriterium> critMap = dtc->evaluationCriteriums();
|
||||
|
||||
const QMap<qint32, Evaluations::EvaluationElement> elemMap = dtc->evaluationElements();
|
||||
|
||||
parentItemIndexCache.insert(0, QModelIndex());
|
||||
|
||||
for (QMap<qint32, Evaluations::EvaluationCriterium>::const_iterator iter = critMap.constBegin();
|
||||
iter != critMap.constEnd(); ++iter)
|
||||
{
|
||||
int criteriumId = iter.key();
|
||||
|
||||
int parentId = 0;
|
||||
EvaluationCriterium crit = iter.value();
|
||||
|
||||
if (crit.operatorId() != operatorId)
|
||||
continue;
|
||||
|
||||
if (!parentItemIndexCache.contains(parentId))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid folder structure";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
QModelIndex pIndex = parentItemIndexCache.value(parentId);
|
||||
int rowPos = -1;
|
||||
|
||||
QVariant data;
|
||||
data.setValue(crit);
|
||||
onInsertRow(rowPos, pIndex, data);
|
||||
parentItemIndexCache.insert(criteriumId + 10000, index(rowPos, 0, pIndex));
|
||||
DEBUG_LOG(m_logger) << "Added to tree (criterium id, parent id) : (" << criteriumId << ", " << parentId
|
||||
<< ")";
|
||||
}
|
||||
|
||||
for (QMap<qint32, Evaluations::EvaluationElement>::const_iterator iter2 = elemMap.constBegin();
|
||||
iter2 != elemMap.constEnd(); ++iter2)
|
||||
{
|
||||
Evaluations::EvaluationElement elem = iter2.value();
|
||||
if (elem.criteriumId() != criteriumId)
|
||||
continue;
|
||||
|
||||
parentId = criteriumId + 10000;
|
||||
|
||||
if (!parentItemIndexCache.contains(parentId))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid folder structure";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
QModelIndex pIndex = parentItemIndexCache.value(parentId);
|
||||
int rowPos = -1;
|
||||
|
||||
QVariant data;
|
||||
data.setValue(elem);
|
||||
onInsertRow(rowPos, pIndex, data);
|
||||
int elementId = elem.id();
|
||||
parentItemIndexCache.insert(elementId, index(rowPos, 0, pIndex));
|
||||
DEBUG_LOG(m_logger) << "Added to tree (element id, parent id) : (" << elementId << ", " << parentId
|
||||
<< ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TopicEditorEvaluationModel::onInsertRow(int &row, const QModelIndex &parent, const QVariant &data)
|
||||
bool TopicEditorEvaluationModel::onInsertRow(int& row, const QModelIndex& parent, const QVariant& data)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onInsertRow";
|
||||
DEBUG_LOG(m_logger) << "onInsertRow";
|
||||
|
||||
row = rowCount(parent);
|
||||
NGLTreeItem *item = new NGLTreeItem(data, QIcon());
|
||||
row = rowCount(parent);
|
||||
NGLTreeItem* item = new NGLTreeItem(data, QIcon());
|
||||
|
||||
return NGLTreeModel::insertRow(row, parent, item);
|
||||
return NGLTreeModel::insertRow(row, parent, item);
|
||||
}
|
||||
|
||||
EvaluationElement TopicEditorEvaluationModel::getEvaluationElement(const QModelIndex &index) const
|
||||
EvaluationElement TopicEditorEvaluationModel::getEvaluationElement(const QModelIndex& index) const
|
||||
{
|
||||
NGLTreeItem *item = privateData(index);
|
||||
if (item->data().canConvert<EvaluationElement>())
|
||||
return item->data().value<EvaluationElement>();
|
||||
NGLTreeItem* item = privateData(index);
|
||||
if (item->data().canConvert<EvaluationElement>())
|
||||
return item->data().value<EvaluationElement>();
|
||||
|
||||
return EvaluationElement();
|
||||
return EvaluationElement();
|
||||
}
|
||||
|
||||
|
||||
QModelIndex TopicEditorEvaluationModel::getIndex(const int &elementId) const
|
||||
QModelIndex TopicEditorEvaluationModel::getIndex(const int& elementId) const
|
||||
{
|
||||
QModelIndexList list = match(index(0, 0), Qt::UserRole, QVariant::fromValue(elementId), 1, Qt::MatchRecursive);
|
||||
QModelIndexList list = match(index(0, 0), Qt::UserRole, QVariant::fromValue(elementId), 1, Qt::MatchRecursive);
|
||||
|
||||
if (!list.isEmpty())
|
||||
return list.first();
|
||||
if (!list.isEmpty())
|
||||
return list.first();
|
||||
|
||||
return {};
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace Evaluations
|
||||
Executable → Regular
+17
-35
@@ -1,60 +1,42 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Evaluations/logger.h>
|
||||
#include <Evaluations/evl_dtc.h>
|
||||
|
||||
#include <Evaluations/logger.h>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <nglwidgets/ngltreemodel.h>
|
||||
|
||||
class QTableWidget;
|
||||
|
||||
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
class TopicEditorEvaluationModel : public NGLTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
NAME = 0,
|
||||
ID,
|
||||
WEIGHT,
|
||||
START_TIME,
|
||||
SITUATION,
|
||||
VIDEO,
|
||||
AUDIO
|
||||
};
|
||||
public:
|
||||
enum Columns { NAME = 0, ID, WEIGHT, START_TIME, SITUATION, VIDEO, AUDIO };
|
||||
|
||||
explicit TopicEditorEvaluationModel(QObject *parent);
|
||||
~TopicEditorEvaluationModel() = default;
|
||||
explicit TopicEditorEvaluationModel(QObject* parent);
|
||||
~TopicEditorEvaluationModel() = default;
|
||||
|
||||
bool initModel(const std::shared_ptr<Evaluations::Interface::Dtc> &dtc, int operatorId);
|
||||
bool initModel(const std::shared_ptr<Evaluations::Interface::Dtc>& dtc, int operatorId);
|
||||
|
||||
EvaluationElement getEvaluationElement(const QModelIndex &index) const;
|
||||
EvaluationElement getEvaluationElement(const QModelIndex& index) const;
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override final;
|
||||
QVariant data(const QModelIndex &, int) const override final;
|
||||
QModelIndex getIndex(const int &elementId) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override final;
|
||||
QVariant data(const QModelIndex&, int) const override final;
|
||||
QModelIndex getIndex(const int& elementId) const;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
public slots:
|
||||
bool onInsertRow(int &row, const QModelIndex &parent, const QVariant &data);
|
||||
public slots:
|
||||
bool onInsertRow(int& row, const QModelIndex& parent, const QVariant& data);
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Evaluations
|
||||
Q_DECLARE_METATYPE(Evaluations::EvaluationCriterium)
|
||||
Q_DECLARE_METATYPE(Evaluations::EvaluationElement)
|
||||
|
||||
|
||||
|
||||
|
||||
Executable → Regular
+147
-164
@@ -1,246 +1,229 @@
|
||||
|
||||
|
||||
|
||||
#include "topic_editor.h"
|
||||
|
||||
#include "ui_topic_editor.h"
|
||||
|
||||
#include <LtsScriptTimeline/track_entry.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <LtsUtilsCore/json_object.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonParseError>
|
||||
|
||||
#include <nglwidgets/ngltreeitem.h>
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
EvaluationTopicEditor::EvaluationTopicEditor(LtsSession::LtsSession *session, QWidget *parent)
|
||||
: TopicEditorBase::TopicEditor(parent)
|
||||
, m_session(session)
|
||||
, m_ui(new Ui::EvaluationTopicEditor)
|
||||
EvaluationTopicEditor::EvaluationTopicEditor(LtsSession::LtsSession* session, QWidget* parent)
|
||||
: TopicEditorBase::TopicEditor(parent), m_session(session), m_ui(new Ui::EvaluationTopicEditor)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
init(m_ui->widget);
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Evaluation_Topic"));
|
||||
m_ui->setupUi(this);
|
||||
init(m_ui->widget);
|
||||
setOnlineHelpFilename(QStringLiteral("Script_Editor-Add_Evaluation_Topic"));
|
||||
|
||||
m_ui->cbxOperator->clear();
|
||||
m_ui->widget->setHidden(true);
|
||||
m_ui->cbxOperator->clear();
|
||||
m_ui->widget->setHidden(true);
|
||||
|
||||
connect(m_ui->cbxOperator, static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged),
|
||||
this, &EvaluationTopicEditor::onOperatorChanged);
|
||||
connect(m_ui->cbxOperator,
|
||||
static_cast<void (LtsWidgets::LtsComboBox::*)(int)>(&LtsWidgets::LtsComboBox::currentIndexChanged), this,
|
||||
&EvaluationTopicEditor::onOperatorChanged);
|
||||
|
||||
m_model = new TopicEditorEvaluationModel(this);
|
||||
m_ui->trvEvaluations->setModel(m_model);
|
||||
m_ui->trvEvaluations->expandAll();
|
||||
m_model = new TopicEditorEvaluationModel(this);
|
||||
m_ui->trvEvaluations->setModel(m_model);
|
||||
m_ui->trvEvaluations->expandAll();
|
||||
|
||||
m_ui->trvEvaluations->hideColumn(TopicEditorEvaluationModel::Columns::ID);
|
||||
m_ui->trvEvaluations->hideColumn(TopicEditorEvaluationModel::Columns::ID);
|
||||
|
||||
|
||||
|
||||
QItemSelectionModel *selectionModel = m_ui->trvEvaluations->selectionModel();
|
||||
connect(selectionModel, &QItemSelectionModel::selectionChanged,
|
||||
this, &EvaluationTopicEditor::onSelectionChanged);
|
||||
QItemSelectionModel* selectionModel = m_ui->trvEvaluations->selectionModel();
|
||||
connect(selectionModel, &QItemSelectionModel::selectionChanged, this, &EvaluationTopicEditor::onSelectionChanged);
|
||||
}
|
||||
|
||||
EvaluationTopicEditor::~EvaluationTopicEditor()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool EvaluationTopicEditor::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<Evaluations::DataInterface>(m_evlDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to retrieve Evl Dtc";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getDtc<Evaluations::DataInterface>(m_evlDtc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to retrieve Evl Dtc";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_session->getForeignGuiInterface<OperatorManagement::ForeignGuiComboboxInterface>(m_opmCbxIfc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to retrieve Evl ForeignGuiInterface";
|
||||
return false;
|
||||
}
|
||||
if (!m_session->getForeignGuiInterface<OperatorManagement::ForeignGuiComboboxInterface>(m_opmCbxIfc))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to retrieve Evl ForeignGuiInterface";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_model->initModel(m_evlDtc, m_operatorId);
|
||||
m_model->initModel(m_evlDtc, m_operatorId);
|
||||
|
||||
|
||||
initOperatorComboBox();
|
||||
initOperatorComboBox();
|
||||
|
||||
DEBUG_LOG(m_logger) << "fillOperatorComboBox m_operatorId = " << m_operatorId;
|
||||
return true;
|
||||
DEBUG_LOG(m_logger) << "fillOperatorComboBox m_operatorId = " << m_operatorId;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void EvaluationTopicEditor::updateInternalData()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
|
||||
if (!hasTopicDataProperties())
|
||||
return;
|
||||
if (!hasTopicDataProperties())
|
||||
return;
|
||||
|
||||
m_operatorId = getTopicDataValue(QStringLiteral("operatorId")).toInt();
|
||||
DEBUG_LOG(m_logger) << "operator id = " << m_operatorId;
|
||||
m_operatorId = getTopicDataValue(QStringLiteral("operatorId")).toInt();
|
||||
DEBUG_LOG(m_logger) << "operator id = " << m_operatorId;
|
||||
|
||||
m_ui->cbxOperator->setCurrentIndex(m_ui->cbxOperator->findData(m_operatorId));
|
||||
m_model->initModel(m_evlDtc, m_operatorId);
|
||||
m_ui->cbxOperator->setCurrentIndex(m_ui->cbxOperator->findData(m_operatorId));
|
||||
m_model->initModel(m_evlDtc, m_operatorId);
|
||||
|
||||
m_evlElement.id(getTopicDataValue(QStringLiteral("elementId")).toDouble());
|
||||
DEBUG_LOG(m_logger) << "element id = " << m_evlElement.id();
|
||||
m_evlElement.timestamp(getTopicDataValue(QStringLiteral("start")).toDouble());
|
||||
m_evlElement.situation(getTopicDataValue(QStringLiteral("situation")).toBool());
|
||||
m_evlElement.audio(getTopicDataValue(QStringLiteral("audio")).toBool());
|
||||
m_evlElement.video(getTopicDataValue(QStringLiteral("video")).toBool());
|
||||
m_evlElement.id(getTopicDataValue(QStringLiteral("elementId")).toDouble());
|
||||
DEBUG_LOG(m_logger) << "element id = " << m_evlElement.id();
|
||||
m_evlElement.timestamp(getTopicDataValue(QStringLiteral("start")).toDouble());
|
||||
m_evlElement.situation(getTopicDataValue(QStringLiteral("situation")).toBool());
|
||||
m_evlElement.audio(getTopicDataValue(QStringLiteral("audio")).toBool());
|
||||
m_evlElement.video(getTopicDataValue(QStringLiteral("video")).toBool());
|
||||
|
||||
selectElement();
|
||||
selectElement();
|
||||
}
|
||||
|
||||
void EvaluationTopicEditor::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Evaluation Topic Editor"));
|
||||
translate(m_ui, tr("Evaluation Topic Editor"));
|
||||
}
|
||||
|
||||
|
||||
void EvaluationTopicEditor::selectElement()
|
||||
{
|
||||
QModelIndex idx;
|
||||
QItemSelectionModel *selectionModel = m_ui->trvEvaluations->selectionModel();
|
||||
if (m_evlElement.id() > 0)
|
||||
idx = m_model->getIndex(m_evlElement.id());
|
||||
if (idx.isValid())
|
||||
selectionModel->setCurrentIndex(idx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||
else
|
||||
selectionModel->setCurrentIndex(m_model->index(0, 0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||
QModelIndex idx;
|
||||
QItemSelectionModel* selectionModel = m_ui->trvEvaluations->selectionModel();
|
||||
if (m_evlElement.id() > 0)
|
||||
idx = m_model->getIndex(m_evlElement.id());
|
||||
if (idx.isValid())
|
||||
selectionModel->setCurrentIndex(idx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||
else
|
||||
selectionModel->setCurrentIndex(m_model->index(0, 0),
|
||||
QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
|
||||
}
|
||||
|
||||
void EvaluationTopicEditor::initOperatorComboBox()
|
||||
{
|
||||
m_opmCbxIfc->fillOperatorComboBox(m_ui->cbxOperator);
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
QMap<int, EvaluationCriterium> evaluationCriteria = m_evlDtc->evaluationCriteriums();
|
||||
for (int index = m_ui->cbxOperator->count() - 1; index >= 0; --index)
|
||||
{
|
||||
int operatorId = m_ui->cbxOperator->itemData(index).toInt();
|
||||
|
||||
if (operatorId == m_operatorId)
|
||||
continue;
|
||||
|
||||
auto it = std::find_if(evaluationCriteria.constBegin(), evaluationCriteria.constEnd(), [this, operatorId](const EvaluationCriterium &ec)
|
||||
m_opmCbxIfc->fillOperatorComboBox(m_ui->cbxOperator);
|
||||
m_operatorId = LtsSessionData::LtsSessionData::getInstance()->getOperatorId();
|
||||
QMap<int, EvaluationCriterium> evaluationCriteria = m_evlDtc->evaluationCriteriums();
|
||||
for (int index = m_ui->cbxOperator->count() - 1; index >= 0; --index)
|
||||
{
|
||||
return ec.operatorId() == operatorId;
|
||||
});
|
||||
if (it == evaluationCriteria.constEnd())
|
||||
m_ui->cbxOperator->removeItem(index);
|
||||
}
|
||||
m_ui->cbxOperator->setCurrentIndex(m_ui->cbxOperator->findData(m_operatorId));
|
||||
int operatorId = m_ui->cbxOperator->itemData(index).toInt();
|
||||
|
||||
if (operatorId == m_operatorId)
|
||||
continue;
|
||||
|
||||
auto it =
|
||||
std::find_if(evaluationCriteria.constBegin(), evaluationCriteria.constEnd(),
|
||||
[this, operatorId](const EvaluationCriterium& ec) { return ec.operatorId() == operatorId; });
|
||||
if (it == evaluationCriteria.constEnd())
|
||||
m_ui->cbxOperator->removeItem(index);
|
||||
}
|
||||
m_ui->cbxOperator->setCurrentIndex(m_ui->cbxOperator->findData(m_operatorId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool EvaluationTopicEditor::apply2()
|
||||
{
|
||||
setTopicDataProperty(QStringLiteral("operatorId"), m_operatorId);
|
||||
setTopicDataProperty(QStringLiteral("elementId"), m_evlElement.id());
|
||||
setTopicDataProperty(QStringLiteral("start"), m_evlElement.timestamp());
|
||||
setTopicDataProperty(QStringLiteral("situation"), m_evlElement.situation());
|
||||
setTopicDataProperty(QStringLiteral("audio"), m_evlElement.audio());
|
||||
setTopicDataProperty(QStringLiteral("video"), m_evlElement.video());
|
||||
setTopicDataProperty(QStringLiteral("operatorId"), m_operatorId);
|
||||
setTopicDataProperty(QStringLiteral("elementId"), m_evlElement.id());
|
||||
setTopicDataProperty(QStringLiteral("start"), m_evlElement.timestamp());
|
||||
setTopicDataProperty(QStringLiteral("situation"), m_evlElement.situation());
|
||||
setTopicDataProperty(QStringLiteral("audio"), m_evlElement.audio());
|
||||
setTopicDataProperty(QStringLiteral("video"), m_evlElement.video());
|
||||
|
||||
DEBUG_LOG(m_logger) << "operator id = " << m_operatorId << ", element id = " << m_evlElement.id();
|
||||
DEBUG_LOG(m_logger) << "timestamp: " << m_evlElement.timestamp();
|
||||
DEBUG_LOG(m_logger) << "operator id = " << m_operatorId << ", element id = " << m_evlElement.id();
|
||||
DEBUG_LOG(m_logger) << "timestamp: " << m_evlElement.timestamp();
|
||||
|
||||
if (m_evlElement.situation())
|
||||
{
|
||||
TopicEditorBase::TopicData data;
|
||||
data.topicType = TopicEditorBase::TopicType::Situation;
|
||||
setTopicDataProperty(QStringLiteral("end"), m_evlElement.timestamp() + m_evlElement.duration() * 1000);
|
||||
setTopicDataProperty(QStringLiteral("speed"), 1.0);
|
||||
|
||||
if (m_evlElement.situationContent())
|
||||
if (m_evlElement.situation())
|
||||
{
|
||||
QJsonParseError error;
|
||||
QJsonDocument doc(QJsonDocument::fromJson(QString::fromStdString(m_evlElement.situationContent().get()).toUtf8(), &error));
|
||||
TopicEditorBase::TopicData data;
|
||||
data.topicType = TopicEditorBase::TopicType::Situation;
|
||||
setTopicDataProperty(QStringLiteral("end"), m_evlElement.timestamp() + m_evlElement.duration() * 1000);
|
||||
setTopicDataProperty(QStringLiteral("speed"), 1.0);
|
||||
|
||||
if (error.error == QJsonParseError::NoError)
|
||||
{
|
||||
QJsonObject root(doc.object());
|
||||
setTopicDataProperty(QStringLiteral("filters"), root[QStringLiteral("filters")]);
|
||||
setTopicDataProperty(QStringLiteral("settings"), root[QStringLiteral("settings")]);
|
||||
}
|
||||
else
|
||||
new LtsWidgets::LtsMessageDialogNew(this, tr("The selected marker has invalid filter and/or map settings."));
|
||||
if (m_evlElement.situationContent())
|
||||
{
|
||||
QJsonParseError error;
|
||||
QJsonDocument doc(QJsonDocument::fromJson(
|
||||
QString::fromStdString(m_evlElement.situationContent().get()).toUtf8(), &error));
|
||||
|
||||
if (error.error == QJsonParseError::NoError)
|
||||
{
|
||||
QJsonObject root(doc.object());
|
||||
setTopicDataProperty(QStringLiteral("filters"), root[QStringLiteral("filters")]);
|
||||
setTopicDataProperty(QStringLiteral("settings"), root[QStringLiteral("settings")]);
|
||||
}
|
||||
else
|
||||
new LtsWidgets::LtsMessageDialogNew(this,
|
||||
tr("The selected marker has invalid filter and/or map settings."));
|
||||
}
|
||||
|
||||
data.duration = m_evlElement.duration();
|
||||
data.properties = m_topicData.properties;
|
||||
|
||||
DEBUG_LOG(m_logger) << "topicData - properties: "
|
||||
<< QJsonDocument(m_topicData.properties).toJson(QJsonDocument::Compact);
|
||||
|
||||
emit topicEditorRequested(data);
|
||||
}
|
||||
|
||||
data.duration = m_evlElement.duration();
|
||||
data.properties = m_topicData.properties;
|
||||
if (m_evlElement.audio())
|
||||
{
|
||||
TopicEditorBase::TopicData data;
|
||||
data.topicType = TopicEditorBase::TopicType::Audio;
|
||||
setTopicDataProperty(QStringLiteral("end"), m_evlElement.timestamp() + m_evlElement.duration() * 1000);
|
||||
LtsUtils::JsonObject jsonObj = LtsUtils::JsonObject::fromJson(m_evlElement.audioContent().get());
|
||||
setTopicDataProperty(QStringLiteral("stream"), jsonObj.value<QString>("actualStream"));
|
||||
data.duration = m_evlElement.duration();
|
||||
data.properties = m_topicData.properties;
|
||||
emit topicEditorRequested(data);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "topicData - properties: " << QJsonDocument(m_topicData.properties).toJson(QJsonDocument::Compact);
|
||||
if (m_evlElement.video())
|
||||
{
|
||||
LtsUtils::JsonObject jsonObj = LtsUtils::JsonObject::fromJson(m_evlElement.videoContent().get());
|
||||
TopicEditorBase::TopicData data;
|
||||
data.topicType = TopicEditorBase::TopicType::Video;
|
||||
setTopicDataProperty(QStringLiteral("end"), m_evlElement.timestamp() + m_evlElement.duration() * 1000);
|
||||
setTopicDataProperty(QStringLiteral("stream"), jsonObj.value<QString>("actualStream"));
|
||||
data.duration = m_evlElement.duration();
|
||||
data.properties = m_topicData.properties;
|
||||
emit topicEditorRequested(data);
|
||||
}
|
||||
|
||||
emit topicEditorRequested(data);
|
||||
}
|
||||
|
||||
if (m_evlElement.audio())
|
||||
{
|
||||
TopicEditorBase::TopicData data;
|
||||
data.topicType = TopicEditorBase::TopicType::Audio;
|
||||
setTopicDataProperty(QStringLiteral("end"), m_evlElement.timestamp() + m_evlElement.duration() * 1000);
|
||||
LtsUtils::JsonObject jsonObj = LtsUtils::JsonObject::fromJson(m_evlElement.audioContent().get());
|
||||
setTopicDataProperty(QStringLiteral("stream"), jsonObj.value<QString>("actualStream"));
|
||||
data.duration = m_evlElement.duration();
|
||||
data.properties = m_topicData.properties;
|
||||
emit topicEditorRequested(data);
|
||||
}
|
||||
|
||||
if (m_evlElement.video())
|
||||
{
|
||||
LtsUtils::JsonObject jsonObj = LtsUtils::JsonObject::fromJson(m_evlElement.videoContent().get());
|
||||
TopicEditorBase::TopicData data;
|
||||
data.topicType = TopicEditorBase::TopicType::Video;
|
||||
setTopicDataProperty(QStringLiteral("end"), m_evlElement.timestamp() + m_evlElement.duration() * 1000);
|
||||
setTopicDataProperty(QStringLiteral("stream"), jsonObj.value<QString>("actualStream"));
|
||||
data.duration = m_evlElement.duration();
|
||||
data.properties = m_topicData.properties;
|
||||
emit topicEditorRequested(data);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void EvaluationTopicEditor::onOperatorChanged()
|
||||
{
|
||||
m_operatorId = m_ui->cbxOperator->currentData().toInt();
|
||||
DEBUG_LOG(m_logger) << "operator id = " << m_operatorId;
|
||||
m_operatorId = m_ui->cbxOperator->currentData().toInt();
|
||||
DEBUG_LOG(m_logger) << "operator id = " << m_operatorId;
|
||||
|
||||
m_model->initModel(m_evlDtc, m_operatorId);
|
||||
m_ui->trvEvaluations->expandAll();
|
||||
m_model->initModel(m_evlDtc, m_operatorId);
|
||||
m_ui->trvEvaluations->expandAll();
|
||||
}
|
||||
|
||||
void EvaluationTopicEditor::onSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
|
||||
void EvaluationTopicEditor::onSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
|
||||
{
|
||||
Q_UNUSED(selected);
|
||||
Q_UNUSED(deselected);
|
||||
Q_UNUSED(selected);
|
||||
Q_UNUSED(deselected);
|
||||
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
DEBUG_LOG(m_logger) << Q_FUNC_INFO;
|
||||
|
||||
QModelIndex index = m_ui->trvEvaluations->currentIndex();
|
||||
m_evlElement = m_model->getEvaluationElement(index);
|
||||
DEBUG_LOG(m_logger) << "element id = " << m_evlElement.id();
|
||||
QModelIndex index = m_ui->trvEvaluations->currentIndex();
|
||||
m_evlElement = m_model->getEvaluationElement(index);
|
||||
DEBUG_LOG(m_logger) << "element id = " << m_evlElement.id();
|
||||
|
||||
m_topicData.description = QString::number(m_evlElement.id());
|
||||
slotChangesMade();
|
||||
m_topicData.description = QString::number(m_evlElement.id());
|
||||
slotChangesMade();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
} // namespace Evaluations
|
||||
Executable → Regular
+33
-31
@@ -1,6 +1,5 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "evl_topic_editor_model.h"
|
||||
@@ -11,51 +10,54 @@
|
||||
#include <Plugins/OperatorManagement/opm_gui_combobox_plugin_interface.h>
|
||||
#include <TopicEditorBase/topic_editor_base.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class EvaluationTopicEditor;
|
||||
}
|
||||
|
||||
namespace Ui { class EvaluationTopicEditor; }
|
||||
|
||||
namespace LtsScriptTimeline { class TrackEntry; }
|
||||
|
||||
namespace LtsScriptTimeline
|
||||
{
|
||||
class TrackEntry;
|
||||
}
|
||||
|
||||
namespace Evaluations
|
||||
{
|
||||
|
||||
class EvaluationTopicEditor : public TopicEditorBase::TopicEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EvaluationTopicEditor(LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~EvaluationTopicEditor();
|
||||
public:
|
||||
explicit EvaluationTopicEditor(LtsSession::LtsSession* session, QWidget* parent = nullptr);
|
||||
~EvaluationTopicEditor();
|
||||
|
||||
void selected();
|
||||
bool fetchInterfaces();
|
||||
void selected();
|
||||
bool fetchInterfaces();
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void updateInternalData() override final;
|
||||
void retranslate() override final;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void updateInternalData() override final;
|
||||
void retranslate() override final;
|
||||
void selectElement();
|
||||
void initOperatorComboBox();
|
||||
|
||||
void selectElement();
|
||||
void initOperatorComboBox();
|
||||
private slots:
|
||||
bool apply2() override final;
|
||||
|
||||
private slots:
|
||||
bool apply2() override final;
|
||||
void onOperatorChanged();
|
||||
void onSelectionChanged(const QItemSelection&, const QItemSelection&);
|
||||
|
||||
void onOperatorChanged();
|
||||
void onSelectionChanged(const QItemSelection & , const QItemSelection & );
|
||||
private:
|
||||
LtsSession::LtsSession* m_session{nullptr};
|
||||
std::shared_ptr<Evaluations::Interface::Dtc> m_evlDtc{nullptr};
|
||||
std::shared_ptr<OperatorManagement::ForeignGuiComboboxInterface> m_opmCbxIfc{nullptr};
|
||||
|
||||
private:
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
std::shared_ptr<Evaluations::Interface::Dtc> m_evlDtc{nullptr};
|
||||
std::shared_ptr<OperatorManagement::ForeignGuiComboboxInterface> m_opmCbxIfc{nullptr};
|
||||
int m_operatorId{0};
|
||||
EvaluationElement m_evlElement;
|
||||
TopicEditorEvaluationModel* m_model{nullptr};
|
||||
|
||||
int m_operatorId{0};
|
||||
EvaluationElement m_evlElement;
|
||||
TopicEditorEvaluationModel *m_model{nullptr};
|
||||
|
||||
Ui::EvaluationTopicEditor *m_ui{nullptr};
|
||||
Ui::EvaluationTopicEditor* m_ui{nullptr};
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace Evaluations
|
||||
Reference in new issue
Block a user