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:
torstenandCopilot committed 2026-08-19 14:46:29 +02:00
1 parent 1881d68aef
commit d6b6ffce7c
848 files changed
+89305 -100020

No files matched your search

@@ -1,11 +1,10 @@
#pragma once
#include <LtsWidgets/lts_dialog.h>
#include <Evaluations/logger.h>
#include <Evaluations/evl_dtc.h>
#include <Evaluations/logger.h>
#include <LtsWidgets/lts_dialog.h>
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
namespace Ui
@@ -20,33 +19,30 @@ class EvlCommentDataViewProxyModel;
class EvlCommentsView : public LtsWidgets::LtsDialog
{
Q_OBJECT
Q_OBJECT
public:
public:
EvlCommentsView(const std::shared_ptr<Interface::Dtc>& evlDtc,
const std::shared_ptr<OperatorManagement::Interface::Dtc>& opmDtc, QWidget* parent = nullptr);
~EvlCommentsView();
EvlCommentsView(const std::shared_ptr<Interface::Dtc> &evlDtc,
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
QWidget *parent = nullptr);
~EvlCommentsView();
private slots:
void onLtsDataView_DoubleClicked();
void onCommentChanged(const Evaluations::EvaluationComment& data, DataModification modType);
private slots:
void onLtsDataView_DoubleClicked();
void onCommentChanged(const Evaluations::EvaluationComment &data, DataModification modType);
private:
NGL::INGLLogger& m_logger;
bool insertComment(const Evaluations::EvaluationComment& c);
void retranslate() override;
bool eventFilter(QObject* object, QEvent* event) override;
void tableColumnOrganiserSetting() override;
private:
Ui::EvlCommentsDialog* m_ui{nullptr};
NGL::INGLLogger &m_logger;
bool insertComment(const Evaluations::EvaluationComment &c);
void retranslate() override;
bool eventFilter(QObject *object, QEvent *event) override;
void tableColumnOrganiserSetting() override;
std::shared_ptr<Interface::Dtc> m_evlDtc;
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
Ui::EvlCommentsDialog *m_ui{nullptr};
std::shared_ptr<Interface::Dtc> m_evlDtc;
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
EvlCommentDataViewModel *m_model{nullptr};
EvlCommentDataViewProxyModel *m_proxyModel{nullptr};
EvlCommentDataViewModel* m_model{nullptr};
EvlCommentDataViewProxyModel* m_proxyModel{nullptr};
};
}
} // namespace Evaluations
File diff suppressed because it is too large. Load diff
@@ -2,137 +2,142 @@
#pragma once
#include <Evaluations/logger.h>
#include "evl_edit_treemodel_schema.h"
#include <Evaluations/evl_dtc.h>
#include <Evaluations/evl_ftc.h>
#include <OcSituationClient/osc_ftc.h>
#include <Evaluations/logger.h>
#include <FileManagement/flm_dtc.h>
#include <FileManagement/flm_ftc.h>
#include <LtsWidgets/lts_dialog.h>
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
#include <Plugins/FileManagement/Data/flm_data_plugin.h>
#include <LtsSession/lts_session.h>
#include "evl_edit_treemodel_schema.h"
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
#include <LtsWidgets/lts_dialog.h>
#include <OcSituationClient/osc_ftc.h>
#include <Plugins/FileManagement/Data/flm_data_plugin.h>
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
#include <Plugins/OperatorManagement/opm_data_plugin_interface.h>
namespace Ui
{
class EditSchemaDialog;
}
namespace Evaluations
{
class EvlNewCommentDialog;
class EditSchemaDialog : public LtsWidgets::LtsDialog
, protected Interface::Ftc::EvlCommentModifyReplyHandler
, protected Interface::Ftc::EvlSchemaModifyReplyHandler
, protected FileManagement::Interface::Ftc::FileContentModifyReplyHandler
, protected OcSituationClient::Interface::Ftc::SendEvaluationReplyHandler
class EditSchemaDialog : public LtsWidgets::LtsDialog,
protected Interface::Ftc::EvlCommentModifyReplyHandler,
protected Interface::Ftc::EvlSchemaModifyReplyHandler,
protected FileManagement::Interface::Ftc::FileContentModifyReplyHandler,
protected OcSituationClient::Interface::Ftc::SendEvaluationReplyHandler
{
Q_OBJECT
Q_OBJECT
public:
explicit EditSchemaDialog(bool ocMode, bool runningOnTablet, LtsSession::LtsSession *session, QWidget *parent = nullptr);
~EditSchemaDialog();
public:
explicit EditSchemaDialog(bool ocMode, bool runningOnTablet, LtsSession::LtsSession* session,
QWidget* parent = nullptr);
~EditSchemaDialog();
bool init(const std::shared_ptr<OcSituationClient::Interface::Ftc> &ocFtc,
const std::shared_ptr<Interface::Ftc> &evlFtc,
const std::shared_ptr<Interface::Dtc> &evlDtc,
const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
const std::shared_ptr<FileManagement::Interface::Ftc> &flmFtc,
const std::shared_ptr<FileManagement::Interface::Dtc> &flmDtc,
const std::shared_ptr<FileManagement::ForeignGuiInterface> &flmGui);
void retranslate() override;
bool init(const std::shared_ptr<OcSituationClient::Interface::Ftc>& ocFtc,
const std::shared_ptr<Interface::Ftc>& evlFtc, const std::shared_ptr<Interface::Dtc>& evlDtc,
const std::shared_ptr<OperatorManagement::Interface::Dtc>& opmDtc,
const std::shared_ptr<FileManagement::Interface::Ftc>& flmFtc,
const std::shared_ptr<FileManagement::Interface::Dtc>& flmDtc,
const std::shared_ptr<FileManagement::ForeignGuiInterface>& flmGui);
void retranslate() override;
private:
private:
NGL::INGLLogger& m_logger;
void onSendEvaluationReply(const Core::FunctionReplyObject& replyObject) override final;
NGL::INGLLogger &m_logger;
void onSendEvaluationReply(const Core::FunctionReplyObject &replyObject) override final;
void onEvlCommentModifyReply(const Core::FunctionReplyObject& replyObject) override final
{
m_requestHelper->requestReply(replyObject);
}
void onEvlCommentModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
void onEvlSchemaModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject); }
void onEvlSchemaModifyReply(const Core::FunctionReplyObject& replyObject) override final
{
m_requestHelper->requestReply(replyObject);
}
void onFileContentModifyReply(const Core::FunctionReplyObject &replyObject) override final { m_requestHelper->requestReply(replyObject);}
void onFileContentModifyReply(const Core::FunctionReplyObject& replyObject) override final
{
m_requestHelper->requestReply(replyObject);
}
private slots:
void onRequestSchema();
void onNotifyAboutSchema(const Evaluations::EvaluationSchema &data, DataModification modType);
void onAddNewComment();
void onCommentAccepted();
void onCommentEditAccepted();
void onSendComment();
void onSendAllComments();
private slots:
void onRequestSchema();
void onNotifyAboutSchema(const Evaluations::EvaluationSchema& data, DataModification modType);
void onAddNewComment();
void onCommentAccepted();
void onCommentEditAccepted();
void onSendComment();
void onSendAllComments();
void onTreeViewDoubleClicked();
void onEditComment();
void onModifySelectedEntry();
void onTreeViewModelIndexChanged(const QModelIndex &curr);
void onTriedToDropFolderToElement();
void onDropActionFinished(const QModelIndex &parent);
void onShowContextMenu(const QPoint &position);
void onTreeViewDoubleClicked();
void onEditComment();
void onModifySelectedEntry();
void onTreeViewModelIndexChanged(const QModelIndex& curr);
void onTriedToDropFolderToElement();
void onDropActionFinished(const QModelIndex& parent);
void onShowContextMenu(const QPoint& position);
bool onSaveToLibrary();
void onLoadFromLibrary();
void onAddElement();
void onAddFolder();
void onAddRootFolder();
bool onSaveToLibrary();
void onLoadFromLibrary();
void onAddElement();
void onAddFolder();
void onAddRootFolder();
void onCreateNewSchema();
void onRemoveSelectedElement();
void onCreateNewSchema();
void onRemoveSelectedElement();
void DebugonLoadSchema();
void onSendSchema();
void DebugonLoadSchema();
void onSendSchema();
private:
void loadLatestSchema();
void handleUnsentComments();
void updateCommentLabel();
void markCommentAsSent(const QPersistentModelIndex &idx);
private:
void loadLatestSchema();
void handleUnsentComments();
void updateCommentLabel();
void markCommentAsSent(const QPersistentModelIndex& idx);
EvlCommentModifyRequest createEvlCommentModifyRequest(const ItemComment &c) const;
OcSituationClient::SendEvaluationRequest createSendEvaluationRequest(const ItemComment &c) const;
QVector<QPersistentModelIndex> m_vecCommentsInSendState;
EvlCommentModifyRequest createEvlCommentModifyRequest(const ItemComment& c) const;
OcSituationClient::SendEvaluationRequest createSendEvaluationRequest(const ItemComment& c) const;
QVector<QPersistentModelIndex> m_vecCommentsInSendState;
bool eventFilter(QObject *object, QEvent *event) override;
void addEntry(bool isFolder, bool isNewRoot = false);
bool eventFilter(QObject* object, QEvent* event) override;
void addEntry(bool isFolder, bool isNewRoot = false);
void removeEntry(const QModelIndex &idx);
void removeComment(const QModelIndex &idx);
void sendComment(const QModelIndex &idx);
void removeEntry(const QModelIndex& idx);
void removeComment(const QModelIndex& idx);
void sendComment(const QModelIndex& idx);
void createExampleSchema();
void loadSchema(qint32 schemaId);
void saveSchema(bool sendToTa);
bool apply() override;
void createExampleSchema();
void loadSchema(qint32 schemaId);
void saveSchema(bool sendToTa);
bool apply() override;
bool m_ocMode{false};
bool m_runningOnTablet{false};
TreeModelSchema *m_pModel{nullptr};
bool m_ocMode{false};
bool m_runningOnTablet{false};
TreeModelSchema* m_pModel{nullptr};
QMap<qint32, Evaluations::EvaluationSchema> m_mapSchemata;
qint32 m_loadedSchemaId{0};
QMap<qint32, Evaluations::EvaluationSchema> m_mapSchemata;
qint32 m_loadedSchemaId{0};
std::shared_ptr<OcSituationClient::Interface::Ftc> m_ocFtc;
std::shared_ptr<Interface::Dtc> m_evlDtc;
std::shared_ptr<Interface::Ftc> m_evlFtc;
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
std::shared_ptr<OcSituationClient::Interface::Ftc> m_ocFtc;
std::shared_ptr<Interface::Dtc> m_evlDtc;
std::shared_ptr<Interface::Ftc> m_evlFtc;
std::shared_ptr<OperatorManagement::Interface::Dtc> m_opmDtc;
std::shared_ptr<FileManagement::Interface::Ftc> m_flmFtc;
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
std::shared_ptr<FileManagement::Interface::Ftc> m_flmFtc;
std::shared_ptr<FileManagement::Interface::Dtc> m_flmDtc;
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
QString m_lastFileName;
Evaluations::EvlNewCommentDialog *m_commentDlg{nullptr};
LtsSession::LtsSession *m_session{nullptr};
QString m_lastFileName;
Evaluations::EvlNewCommentDialog* m_commentDlg{nullptr};
LtsSession::LtsSession* m_session{nullptr};
LtsUtils::RequestHelper *m_requestHelper{nullptr};
Ui::EditSchemaDialog *m_ui{nullptr};
LtsUtils::RequestHelper* m_requestHelper{nullptr};
Ui::EditSchemaDialog* m_ui{nullptr};
};
}
} // namespace Evaluations
@@ -1,33 +1,33 @@
#pragma once
#include <Evaluations/logger.h>
#include <nglwidgets/ngltreemodel.h>
#include <nglwidgets/ngltreeitem.h>
#include "evl_edit_schema_element_data.h"
#include <Evaluations/logger.h>
#include <nglwidgets/ngltreeitem.h>
#include <nglwidgets/ngltreemodel.h>
namespace Evaluations
{
class TreeModelGeneral : public NGLTreeModel
{
Q_OBJECT
public:
TreeModelGeneral(QObject *parent,
NGL::INGLLogger &logger);
Q_OBJECT
public:
TreeModelGeneral(QObject* parent, NGL::INGLLogger& logger);
void iterateModel(const QModelIndex &parent, const std::function<void(const QModelIndex &, const QVariant &)> &fCallback, bool recursive = true) const;
void iterateModel(const QModelIndex& parent,
const std::function<void(const QModelIndex&, const QVariant&)>& fCallback,
bool recursive = true) const;
QVariant dataAsVariant(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QVariant dataAsVariant(const QModelIndex& index) const;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QModelIndex insertRow(const QModelIndex &parent, const QVariant &data, const QIcon &icon);
bool updateRow(const QModelIndex &index, const QVariant &data, const QIcon &icon);
void removeRow(const QModelIndex &idx, bool deleteRootAllowed = false);
QModelIndex insertRow(const QModelIndex& parent, const QVariant& data, const QIcon& icon);
bool updateRow(const QModelIndex& index, const QVariant& data, const QIcon& icon);
void removeRow(const QModelIndex& idx, bool deleteRootAllowed = false);
protected:
NGL::INGLLogger &m_logger;
protected:
NGL::INGLLogger& m_logger;
};
}
} // namespace Evaluations
@@ -1,302 +1,281 @@
#include "evl_edit_treemodel_schema.h"
#include <ngltools/ngltools_dtg.h>
#include <QJsonArray>
#include <QJsonObject>
#include <ngltools/ngltools_dtg.h>
namespace Evaluations
{
TreeModelSchema::TreeModelSchema(QObject *parent, NGL::INGLLogger &logger)
: TreeModelGeneral(parent, logger)
TreeModelSchema::TreeModelSchema(QObject* parent, NGL::INGLLogger& logger) : TreeModelGeneral(parent, logger)
{
qRegisterMetaTypeStreamOperators<Evaluations::ElementData>();
qRegisterMetaTypeStreamOperators<Evaluations::ElementData>();
}
void TreeModelSchema::resetModel()
{
TreeModelGeneral::resetModel();
m_elementId = 1;
m_cntComments = 0;
m_cntSentComments = 0;
TreeModelGeneral::resetModel();
m_elementId = 1;
m_cntComments = 0;
m_cntSentComments = 0;
}
bool TreeModelSchema::dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent)
bool TreeModelSchema::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column,
const QModelIndex& parent)
{
ElementData p = getSelectedIndexDataAsElement(parent);
ElementData p = getSelectedIndexDataAsElement(parent);
if (!p.isFolder())
{
emit signalTriedToDropFolderToElement();
return false;
}
bool success = TreeModelGeneral::dropMimeData(data, action, row, column, parent);
if (success)
{
int parentId = getSelectedIndexDataAsElement(parent).m_id;
iterateModel(parent, [this, parentId](const QModelIndex & idx, const QVariant & v)
if (!p.isFolder())
{
Evaluations::ElementData e = v.value<Evaluations::ElementData>();
e.m_parentId = parentId;
updateElementData(idx, e);
}, false);
emit signalTriedToDropFolderToElement();
return false;
}
refreshAllIcons();
emit signalSuccessfulDropPerformed(parent);
}
bool success = TreeModelGeneral::dropMimeData(data, action, row, column, parent);
return success;
if (success)
{
int parentId = getSelectedIndexDataAsElement(parent).m_id;
iterateModel(
parent,
[this, parentId](const QModelIndex& idx, const QVariant& v) {
Evaluations::ElementData e = v.value<Evaluations::ElementData>();
e.m_parentId = parentId;
updateElementData(idx, e);
},
false);
refreshAllIcons();
emit signalSuccessfulDropPerformed(parent);
}
return success;
}
QVariant TreeModelSchema::data(const QModelIndex &index, int role) const
QVariant TreeModelSchema::data(const QModelIndex& index, int role) const
{
QVariant v = TreeModelGeneral::data(index, role);
QVariant v = TreeModelGeneral::data(index, role);
if (v.isNull())
return v;
if (v.canConvert<Evaluations::ElementData>())
{
Evaluations::ElementData e = v.value<Evaluations::ElementData>();
return e.getText();
}
else if (v.canConvert<Evaluations::ItemComment>())
{
Evaluations::ItemComment c = v.value<Evaluations::ItemComment>();
QString str(DTG::toStringMSec(c.getTimeStamp().toMSecsSinceEpoch()));
str += QLatin1Char(' ');
str += c.getText();
return str;
}
if (v.isNull())
return v;
if (v.canConvert<Evaluations::ElementData>())
{
Evaluations::ElementData e = v.value<Evaluations::ElementData>();
return e.getText();
}
else if (v.canConvert<Evaluations::ItemComment>())
{
Evaluations::ItemComment c = v.value<Evaluations::ItemComment>();
QString str(DTG::toStringMSec(c.getTimeStamp().toMSecsSinceEpoch()));
str += QLatin1Char(' ');
str += c.getText();
return str;
}
return v;
}
ElementData TreeModelSchema::getSelectedIndexDataAsElement(const QModelIndex &idx) const
ElementData TreeModelSchema::getSelectedIndexDataAsElement(const QModelIndex& idx) const
{
if (!idx.isValid())
ElementData();
if (!idx.isValid())
ElementData();
QVariant v = TreeModelGeneral::dataAsVariant(idx);
return v.value<Evaluations::ElementData>();
QVariant v = TreeModelGeneral::dataAsVariant(idx);
return v.value<Evaluations::ElementData>();
}
QVector<QString> TreeModelSchema::getSelectedIndexHierarchy(const QModelIndex &idx) const
QVector<QString> TreeModelSchema::getSelectedIndexHierarchy(const QModelIndex& idx) const
{
if (!idx.isValid())
QString();
if (!idx.isValid())
QString();
QVector<QString> vecHierarchy;
QVector<QString> vecHierarchy;
QModelIndex iterIdx = idx;
QModelIndex iterIdx = idx;
while (iterIdx.parent() != QModelIndex())
{
Evaluations::ElementData e = getSelectedIndexDataAsElement(iterIdx);
vecHierarchy.push_front(e.getText());
iterIdx = iterIdx.parent();
}
while (iterIdx.parent() != QModelIndex())
{
Evaluations::ElementData e = getSelectedIndexDataAsElement(iterIdx);
vecHierarchy.push_front(e.getText());
iterIdx = iterIdx.parent();
}
Evaluations::ElementData e = getSelectedIndexDataAsElement(iterIdx);
vecHierarchy.push_front(e.getText());
return vecHierarchy;
return vecHierarchy;
}
QJsonDocument TreeModelSchema::toJsonDocument() const
{
QJsonArray arr;
QJsonArray arr;
QModelIndex root;
iterateModel(root, [this, &arr](const QModelIndex & idx, const QVariant & v)
{
Q_UNUSED(idx);
Evaluations::ElementData e = v.value<Evaluations::ElementData>();
INFO_LOG(m_logger) << "toJsonDocument: Name: " << e.getText() << ", elementId: " << e.m_id << ", parent id: " << e.m_parentId;
QModelIndex root;
iterateModel(root, [this, &arr](const QModelIndex& idx, const QVariant& v) {
Q_UNUSED(idx);
Evaluations::ElementData e = v.value<Evaluations::ElementData>();
INFO_LOG(m_logger) << "toJsonDocument: Name: " << e.getText() << ", elementId: " << e.m_id
<< ", parent id: " << e.m_parentId;
QJsonObject obj;
obj[QStringLiteral("id")] = e.m_id;
obj[QStringLiteral("parentId")] = e.m_parentId;
obj[QStringLiteral("text")] = e.getText();
obj[QStringLiteral("state")] = int(e.getState());
QJsonObject obj;
obj[QStringLiteral("id")] = e.m_id;
obj[QStringLiteral("parentId")] = e.m_parentId;
obj[QStringLiteral("text")] = e.getText();
obj[QStringLiteral("state")] = int(e.getState());
arr.append(obj);
});
QJsonDocument doc(arr);
return doc;
}
bool TreeModelSchema::fromQJsonDocument(const QJsonDocument &doc)
{
resetModel();
const QJsonArray arr(doc.array());
if (!arr.size())
return false;
QHash<int, QPersistentModelIndex> mapId2Index;
for (const QJsonValue &val : arr)
{
const QJsonObject obj = val.toObject();
ElementData d(obj[QStringLiteral("text")].toString());
d.m_id = obj[QStringLiteral("id")].toInt();
d.m_parentId = obj[QStringLiteral("parentId")].toInt();
d.switchState((ElementData::State)obj[QStringLiteral("state")].toInt());
QPersistentModelIndex parent = (d.m_parentId == 0) ? QPersistentModelIndex() : mapId2Index[d.m_parentId];
QModelIndex newIdx = TreeModelGeneral::insertRow(parent, QVariant::fromValue(d), d.getIcon());
mapId2Index[d.m_id] = newIdx;
m_elementId = std::max(m_elementId, d.m_id);
INFO_LOG(m_logger) << "fromQJsonDocument: " << d.getText() << ", own id = " << d.m_id << ", parent id = " << d.m_parentId;
}
++m_elementId;
return true;
}
QModelIndex TreeModelSchema::insertComment(const QModelIndex &parent, const ItemComment &data)
{
QModelIndex idx = TreeModelGeneral::insertRow(parent, QVariant::fromValue(data), data.getIcon());
if (idx.isValid())
{
++m_cntComments;
if (data.isSent())
++m_cntSentComments;
refreshElementDataIconState(parent);
}
return idx;
}
void TreeModelSchema::insertComment(const ItemComment &data)
{
QModelIndex root = QModelIndex();
iterateModel(root, [&data, this](const QModelIndex & idx, const QVariant & v)
{
if (v.canConvert<Evaluations::ElementData>())
{
ElementData e = v.value<Evaluations::ElementData>();
if (e.m_id == data.elementId())
TreeModelSchema::insertComment(idx, data);
}
});
}
bool TreeModelSchema::updateComment(const QModelIndex &index, const ItemComment &data)
{
bool success = TreeModelGeneral::updateRow(index, QVariant::fromValue(data), data.getIcon());
if (success)
{
if (data.isSent())
++m_cntSentComments;
refreshElementDataIconState(index.parent());
}
return success;
}
void TreeModelSchema::removeComment(const QModelIndex &idx)
{
if (!idx.isValid())
return;
--m_cntComments;
QModelIndex idxParentElement = idx.parent();
removeRow(idx);
refreshElementDataIconState(idxParentElement);
}
QModelIndex TreeModelSchema::insertElementData(const QModelIndex &parent, const ElementData &data)
{
ElementData d(data);
d.m_id = m_elementId++;
d.m_parentId = !parent.isValid() ? 0 : getSelectedIndexDataAsElement(parent).m_id;
return TreeModelGeneral::insertRow(parent, QVariant::fromValue(d), d.getIcon());
}
bool TreeModelSchema::updateElementData(const QModelIndex &index, const ElementData &data)
{
return TreeModelGeneral::updateRow(index, QVariant::fromValue(data), data.getIcon());
}
void TreeModelSchema::refreshElementDataIconState(const QModelIndex &idx)
{
ElementData e = getSelectedIndexDataAsElement(idx);
if (e.isFolder())
return;
if (!rowCount(idx))
e.switchState(ElementData::State::ElementWithoutComments);
else
{
bool hasUnsentComments = false;
iterateModel(idx, [&hasUnsentComments](const QModelIndex & idx, const QVariant & v)
{
Q_UNUSED(idx);
const Evaluations::ItemComment d = v.value<Evaluations::ItemComment>();
if (!d.isSent())
hasUnsentComments = true;
arr.append(obj);
});
e.switchState(hasUnsentComments ? ElementData::State::ElementWithUnsentComments : ElementData::State::ElementAllCommentsSent);
}
TreeModelGeneral::updateRow(idx, QVariant::fromValue(e), e.getIcon());
QJsonDocument doc(arr);
return doc;
}
bool TreeModelSchema::fromQJsonDocument(const QJsonDocument& doc)
{
resetModel();
const QJsonArray arr(doc.array());
if (!arr.size())
return false;
QHash<int, QPersistentModelIndex> mapId2Index;
for (const QJsonValue& val : arr)
{
const QJsonObject obj = val.toObject();
ElementData d(obj[QStringLiteral("text")].toString());
d.m_id = obj[QStringLiteral("id")].toInt();
d.m_parentId = obj[QStringLiteral("parentId")].toInt();
d.switchState((ElementData::State)obj[QStringLiteral("state")].toInt());
QPersistentModelIndex parent = (d.m_parentId == 0) ? QPersistentModelIndex() : mapId2Index[d.m_parentId];
QModelIndex newIdx = TreeModelGeneral::insertRow(parent, QVariant::fromValue(d), d.getIcon());
mapId2Index[d.m_id] = newIdx;
m_elementId = std::max(m_elementId, d.m_id);
INFO_LOG(m_logger) << "fromQJsonDocument: " << d.getText() << ", own id = " << d.m_id
<< ", parent id = " << d.m_parentId;
}
++m_elementId;
return true;
}
QModelIndex TreeModelSchema::insertComment(const QModelIndex& parent, const ItemComment& data)
{
QModelIndex idx = TreeModelGeneral::insertRow(parent, QVariant::fromValue(data), data.getIcon());
if (idx.isValid())
{
++m_cntComments;
if (data.isSent())
++m_cntSentComments;
refreshElementDataIconState(parent);
}
return idx;
}
void TreeModelSchema::insertComment(const ItemComment& data)
{
QModelIndex root = QModelIndex();
iterateModel(root, [&data, this](const QModelIndex& idx, const QVariant& v) {
if (v.canConvert<Evaluations::ElementData>())
{
ElementData e = v.value<Evaluations::ElementData>();
if (e.m_id == data.elementId())
TreeModelSchema::insertComment(idx, data);
}
});
}
bool TreeModelSchema::updateComment(const QModelIndex& index, const ItemComment& data)
{
bool success = TreeModelGeneral::updateRow(index, QVariant::fromValue(data), data.getIcon());
if (success)
{
if (data.isSent())
++m_cntSentComments;
refreshElementDataIconState(index.parent());
}
return success;
}
void TreeModelSchema::removeComment(const QModelIndex& idx)
{
if (!idx.isValid())
return;
--m_cntComments;
QModelIndex idxParentElement = idx.parent();
removeRow(idx);
refreshElementDataIconState(idxParentElement);
}
QModelIndex TreeModelSchema::insertElementData(const QModelIndex& parent, const ElementData& data)
{
ElementData d(data);
d.m_id = m_elementId++;
d.m_parentId = !parent.isValid() ? 0 : getSelectedIndexDataAsElement(parent).m_id;
return TreeModelGeneral::insertRow(parent, QVariant::fromValue(d), d.getIcon());
}
bool TreeModelSchema::updateElementData(const QModelIndex& index, const ElementData& data)
{
return TreeModelGeneral::updateRow(index, QVariant::fromValue(data), data.getIcon());
}
void TreeModelSchema::refreshElementDataIconState(const QModelIndex& idx)
{
ElementData e = getSelectedIndexDataAsElement(idx);
if (e.isFolder())
return;
if (!rowCount(idx))
e.switchState(ElementData::State::ElementWithoutComments);
else
{
bool hasUnsentComments = false;
iterateModel(idx, [&hasUnsentComments](const QModelIndex& idx, const QVariant& v) {
Q_UNUSED(idx);
const Evaluations::ItemComment d = v.value<Evaluations::ItemComment>();
if (!d.isSent())
hasUnsentComments = true;
});
e.switchState(hasUnsentComments ? ElementData::State::ElementWithUnsentComments
: ElementData::State::ElementAllCommentsSent);
}
TreeModelGeneral::updateRow(idx, QVariant::fromValue(e), e.getIcon());
}
void TreeModelSchema::refreshAllIcons()
{
QModelIndex root;
iterateModel(root, [this](const QModelIndex & idx, const QVariant & v)
{
Evaluations::ElementData d = v.value<Evaluations::ElementData>();
d.refreshIcon();
QModelIndex root;
iterateModel(root, [this](const QModelIndex& idx, const QVariant& v) {
Evaluations::ElementData d = v.value<Evaluations::ElementData>();
d.refreshIcon();
NGLTreeItem *item = privateData(idx);
item->setIcon(d.getIcon());
});
NGLTreeItem* item = privateData(idx);
item->setIcon(d.getIcon());
});
emit dataChanged(QModelIndex(), QModelIndex());
emit dataChanged(QModelIndex(), QModelIndex());
}
}
} // namespace Evaluations
@@ -1,94 +1,92 @@
#include "evl_new_comment_dialog.h"
#include "ui_evl_new_comment_dialog.h"
#include "evl_new_comment_dialog.h"
#include <Evaluations/logger.h>
#include <LtsUtilsSettings/settings.h>
namespace Evaluations
{
EvlNewCommentDialog::EvlNewCommentDialog(const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
QWidget *parent) : QDialog(parent),
m_ui(new Ui::EvlNewCommentDialog),
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
m_ui->setupUi(this);
setWindowFlags(Qt::Tool);
m_ui->m_ltsComboBox_ReceiverOperator->addItem(tr("All (Default)"), 0);
EvlNewCommentDialog::EvlNewCommentDialog(const std::shared_ptr<OperatorManagement::Interface::Dtc>& opmDtc,
QWidget* parent)
: QDialog(parent), m_ui(new Ui::EvlNewCommentDialog), m_logger(NGL::NGLLoggerBootstrap::getLogger())
{
m_ui->setupUi(this);
setWindowFlags(Qt::Tool);
m_ui->m_ltsComboBox_ReceiverOperator->addItem(tr("All (Default)"), 0);
auto cbUser = [this](const OperatorManagement::User &user)
{
m_ui->m_ltsComboBox_ReceiverOperator->addItem(QString::fromStdString(user.name()), user.id());
};
opmDtc->users(cbUser);
auto cbUser = [this](const OperatorManagement::User& user) {
m_ui->m_ltsComboBox_ReceiverOperator->addItem(QString::fromStdString(user.name()), user.id());
};
opmDtc->users(cbUser);
connect(m_ui->m_pushButton_AddComment, &QPushButton::clicked, this, &QDialog::accept);
connect(m_ui->m_pushButton_Cancel, &QPushButton::clicked, this, &QDialog::reject);
connect(m_ui->m_plainTextEdit_Comment, &QPlainTextEdit::textChanged, this, &EvlNewCommentDialog::onTextChanged);
connect(m_ui->m_pushButton_AddComment, &QPushButton::clicked, this, &QDialog::accept);
connect(m_ui->m_pushButton_Cancel, &QPushButton::clicked, this, &QDialog::reject);
connect(m_ui->m_plainTextEdit_Comment, &QPlainTextEdit::textChanged, this, &EvlNewCommentDialog::onTextChanged);
m_ui->m_checkBox_SendComment->setChecked(LtsUtils::OperatorSettings::getInstance()->value(QStringLiteral("Evaluations"), QStringLiteral("setAutoSendComments"), false).toBool());
m_ui->m_checkBox_SendComment->setChecked(
LtsUtils::OperatorSettings::getInstance()
->value(QStringLiteral("Evaluations"), QStringLiteral("setAutoSendComments"), false)
.toBool());
onTextChanged();
onTextChanged();
}
EvlNewCommentDialog::~EvlNewCommentDialog()
{
LtsUtils::OperatorSettings::getInstance()->setValue(QStringLiteral("Evaluations"), QStringLiteral("setAutoSendComments"), m_ui->m_checkBox_SendComment->isChecked());
delete m_ui;
LtsUtils::OperatorSettings::getInstance()->setValue(QStringLiteral("Evaluations"),
QStringLiteral("setAutoSendComments"),
m_ui->m_checkBox_SendComment->isChecked());
delete m_ui;
}
void EvlNewCommentDialog::onTextChanged()
{
QString plainText(m_ui->m_plainTextEdit_Comment->toPlainText());
int currentUsedChars = plainText.toUtf8().size();
bool bNeedSetNew = false;
QString plainText(m_ui->m_plainTextEdit_Comment->toPlainText());
int currentUsedChars = plainText.toUtf8().size();
bool bNeedSetNew = false;
while (currentUsedChars > m_maxChars)
{
plainText.chop(1);
currentUsedChars = plainText.toUtf8().size();
bNeedSetNew = true;
}
while (currentUsedChars > m_maxChars)
{
plainText.chop(1);
currentUsedChars = plainText.toUtf8().size();
bNeedSetNew = true;
}
if (bNeedSetNew)
{
m_ui->m_plainTextEdit_Comment->setPlainText(plainText);
m_ui->m_plainTextEdit_Comment->moveCursor(QTextCursor::End);
}
if (bNeedSetNew)
{
m_ui->m_plainTextEdit_Comment->setPlainText(plainText);
m_ui->m_plainTextEdit_Comment->moveCursor(QTextCursor::End);
}
m_ui->m_label_CharsLeft->setText(tr("Characters left: %1").arg(m_maxChars - currentUsedChars));
m_ui->m_label_CharsLeft->setText(tr("Characters left: %1").arg(m_maxChars - currentUsedChars));
}
bool EvlNewCommentDialog::autoSend() const
{
return m_ui->m_checkBox_SendComment->isChecked();
return m_ui->m_checkBox_SendComment->isChecked();
}
QString EvlNewCommentDialog::comment() const
{
return m_ui->m_plainTextEdit_Comment->toPlainText();
return m_ui->m_plainTextEdit_Comment->toPlainText();
}
int EvlNewCommentDialog::selectedReceiverId() const
{
return m_ui->m_ltsComboBox_ReceiverOperator->currentData().toInt();
return m_ui->m_ltsComboBox_ReceiverOperator->currentData().toInt();
}
void EvlNewCommentDialog::setAsEditComment(const QString &text)
void EvlNewCommentDialog::setAsEditComment(const QString& text)
{
m_ui->m_plainTextEdit_Comment->setPlainText(text);
m_ui->m_label_CharsLeft->hide();
m_ui->label->hide();
m_ui->m_ltsComboBox_ReceiverOperator->hide();
m_ui->m_checkBox_SendComment->hide();
m_ui->m_plainTextEdit_Comment->setPlainText(text);
m_ui->m_label_CharsLeft->hide();
m_ui->label->hide();
m_ui->m_ltsComboBox_ReceiverOperator->hide();
m_ui->m_checkBox_SendComment->hide();
m_ui->m_pushButton_AddComment->setText(tr("Edit Comment"));
m_ui->m_pushButton_AddComment->setText(tr("Edit Comment"));
}
}
} // namespace Evaluations
@@ -1,6 +1,5 @@
#pragma once
#include <LtsWidgets/lts_dialog.h>
@@ -11,30 +10,28 @@ namespace Ui
class EvlNewCommentDialog;
}
namespace Evaluations
{
class EvlNewCommentDialog : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
explicit EvlNewCommentDialog(const std::shared_ptr<OperatorManagement::Interface::Dtc> &opmDtc,
QWidget *parent = nullptr);
~EvlNewCommentDialog();
public:
explicit EvlNewCommentDialog(const std::shared_ptr<OperatorManagement::Interface::Dtc>& opmDtc,
QWidget* parent = nullptr);
~EvlNewCommentDialog();
bool autoSend() const;
QString comment() const;
int selectedReceiverId() const;
void setAsEditComment(const QString &text);
bool autoSend() const;
QString comment() const;
int selectedReceiverId() const;
void setAsEditComment(const QString& text);
private slots:
void onTextChanged();
private slots:
void onTextChanged();
private:
NGL::INGLLogger &m_logger;
Ui::EvlNewCommentDialog *m_ui{nullptr};
const int m_maxChars{255};
private:
NGL::INGLLogger& m_logger;
Ui::EvlNewCommentDialog* m_ui{nullptr};
const int m_maxChars{255};
};
}
} // namespace Evaluations