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
+145
-163
@@ -1,207 +1,189 @@
|
||||
|
||||
|
||||
|
||||
#include "cod_assign_codification_data_table.h"
|
||||
#include <utility>
|
||||
|
||||
#include "cod_codification_data_overview_model.h"
|
||||
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <QLabel>
|
||||
#include <utility>
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
AssignCodificationDataTable::AssignCodificationDataTable(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_ui(new Ui::AssignCodificationDataTable)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
AssignCodificationDataTable::AssignCodificationDataTable(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel), m_dtc(nullptr), m_ftc(nullptr),
|
||||
m_ppmDtc(nullptr), m_ui(new Ui::AssignCodificationDataTable), m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Assign_Codification_Data"));
|
||||
|
||||
}
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Assign_Codification_Data"));
|
||||
}
|
||||
|
||||
AssignCodificationDataTable::~AssignCodificationDataTable()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_requestHelper;
|
||||
}
|
||||
|
||||
delete m_ui;
|
||||
delete m_requestHelper;
|
||||
}
|
||||
|
||||
void AssignCodificationDataTable::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Assign Codification Data"));
|
||||
}
|
||||
translate(m_ui, tr("Assign Codification Data"));
|
||||
}
|
||||
|
||||
|
||||
bool AssignCodificationDataTable::init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
LtsSession::LtsSession *session)
|
||||
bool AssignCodificationDataTable::init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc,
|
||||
LtsSession::LtsSession* session)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AssignCodificationDataTable::init()";
|
||||
DEBUG_LOG(m_logger) << "AssignCodificationDataTable::init()";
|
||||
|
||||
if (!dtc || !ftc || !session || !ppmDtc)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "AssignCodificationDataTable::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_session = session;
|
||||
|
||||
m_model = new CodificationDataOverviewModel(this);
|
||||
m_model->initModel(m_dtc, m_ppmDtc);
|
||||
|
||||
int i = 0;
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> userVisibleParties;
|
||||
m_ppmDtc->visibleParties(userVisibleParties, LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(m_session->exerciseId()));
|
||||
DEBUG_LOG(m_logger) << "Number of parties visible to the user in the exercise: " << userVisibleParties.size();
|
||||
|
||||
for (const ParticipantManagement::Party &party : std::as_const(userVisibleParties))
|
||||
{
|
||||
|
||||
if (party.id() != 2 && party.id() != 3)
|
||||
continue;
|
||||
|
||||
|
||||
QString partyName;
|
||||
if (party.id() == 2)
|
||||
partyName = tr("OPFOR:");
|
||||
else if (party.id() == 3)
|
||||
partyName = tr("BLUFOR:");
|
||||
else
|
||||
partyName = ParticipantManagement::trPartyName(party.name());
|
||||
m_ui->partyLayout->addWidget(new QLabel(partyName, this), i, 0, 1, 1);
|
||||
|
||||
LtsWidgets::LtsComboBox *cb = new LtsWidgets::LtsComboBox(this);
|
||||
cb->setProperty(QLatin1String("partyId").data(), party.id());
|
||||
m_tableVec.append(cb);
|
||||
cb->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
cb->addItem(QStringLiteral("---"), 0);
|
||||
for (int row = 0; row < m_model->rowCount(); ++row)
|
||||
if (!dtc || !ftc || !session || !ppmDtc)
|
||||
{
|
||||
cb->addItem(m_model->data(m_model->index(row, CodificationDataOverviewModel::Identifier), Qt::DisplayRole).toString(),
|
||||
m_model->data(m_model->index(row, CodificationDataOverviewModel::Id), Qt::DisplayRole));
|
||||
|
||||
DEBUG_LOG(m_logger) << "Init Combobox[" << row << "]: PartyId: " << party.id()
|
||||
<< " Identifier: " << m_model->data(m_model->index(row, CodificationDataOverviewModel::Identifier), Qt::DisplayRole).toString()
|
||||
<< " CodTabId: " << m_model->data(m_model->index(row, CodificationDataOverviewModel::Id), Qt::DisplayRole).toInt();
|
||||
ERROR_LOG(m_logger) << "AssignCodificationDataTable::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
cb->model()->sort(0);
|
||||
|
||||
|
||||
int tableId = 0;
|
||||
for (int row = 0; row < m_model->rowCount(); ++row)
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_session = session;
|
||||
|
||||
m_model = new CodificationDataOverviewModel(this);
|
||||
m_model->initModel(m_dtc, m_ppmDtc);
|
||||
|
||||
int i = 0;
|
||||
|
||||
QMap<qint32, ParticipantManagement::Party> userVisibleParties;
|
||||
m_ppmDtc->visibleParties(userVisibleParties,
|
||||
LtsSessionData::LtsSessionData::getInstance()->getVisibleParties(m_session->exerciseId()));
|
||||
DEBUG_LOG(m_logger) << "Number of parties visible to the user in the exercise: " << userVisibleParties.size();
|
||||
|
||||
for (const ParticipantManagement::Party& party : std::as_const(userVisibleParties))
|
||||
{
|
||||
tableId = 0;
|
||||
int assignedPartyId = m_model->data(m_model->index(row, CodificationDataOverviewModel::PartyIdHiddenColumn), Qt::DisplayRole).toInt();
|
||||
DEBUG_LOG(m_logger) << "Assignment[" << row << "]: assignedPartyId: " << assignedPartyId;
|
||||
|
||||
if (party.id() == assignedPartyId)
|
||||
{
|
||||
tableId = m_model->data(m_model->index(row, CodificationDataOverviewModel::Id), Qt::DisplayRole).toInt();
|
||||
DEBUG_LOG(m_logger) << "Assignment[" << row << "]: assignedPartyId: " << assignedPartyId
|
||||
<< " tableId: " << tableId;
|
||||
break;
|
||||
}
|
||||
if (party.id() != 2 && party.id() != 3)
|
||||
continue;
|
||||
|
||||
QString partyName;
|
||||
if (party.id() == 2)
|
||||
partyName = tr("OPFOR:");
|
||||
else if (party.id() == 3)
|
||||
partyName = tr("BLUFOR:");
|
||||
else
|
||||
partyName = ParticipantManagement::trPartyName(party.name());
|
||||
m_ui->partyLayout->addWidget(new QLabel(partyName, this), i, 0, 1, 1);
|
||||
|
||||
LtsWidgets::LtsComboBox* cb = new LtsWidgets::LtsComboBox(this);
|
||||
cb->setProperty(QLatin1String("partyId").data(), party.id());
|
||||
m_tableVec.append(cb);
|
||||
cb->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
cb->addItem(QStringLiteral("---"), 0);
|
||||
for (int row = 0; row < m_model->rowCount(); ++row)
|
||||
{
|
||||
cb->addItem(m_model->data(m_model->index(row, CodificationDataOverviewModel::Identifier), Qt::DisplayRole)
|
||||
.toString(),
|
||||
m_model->data(m_model->index(row, CodificationDataOverviewModel::Id), Qt::DisplayRole));
|
||||
|
||||
DEBUG_LOG(m_logger)
|
||||
<< "Init Combobox[" << row << "]: PartyId: " << party.id() << " Identifier: "
|
||||
<< m_model->data(m_model->index(row, CodificationDataOverviewModel::Identifier), Qt::DisplayRole)
|
||||
.toString()
|
||||
<< " CodTabId: "
|
||||
<< m_model->data(m_model->index(row, CodificationDataOverviewModel::Id), Qt::DisplayRole).toInt();
|
||||
}
|
||||
cb->model()->sort(0);
|
||||
|
||||
int tableId = 0;
|
||||
for (int row = 0; row < m_model->rowCount(); ++row)
|
||||
{
|
||||
tableId = 0;
|
||||
int assignedPartyId =
|
||||
m_model->data(m_model->index(row, CodificationDataOverviewModel::PartyIdHiddenColumn), Qt::DisplayRole)
|
||||
.toInt();
|
||||
DEBUG_LOG(m_logger) << "Assignment[" << row << "]: assignedPartyId: " << assignedPartyId;
|
||||
|
||||
if (party.id() == assignedPartyId)
|
||||
{
|
||||
tableId =
|
||||
m_model->data(m_model->index(row, CodificationDataOverviewModel::Id), Qt::DisplayRole).toInt();
|
||||
DEBUG_LOG(m_logger) << "Assignment[" << row << "]: assignedPartyId: " << assignedPartyId
|
||||
<< " tableId: " << tableId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Assignment currentIndex: " << cb->findData(tableId);
|
||||
cb->setCurrentIndex(cb->findData(tableId));
|
||||
|
||||
m_ui->partyLayout->addWidget(cb, i, 1, 1, 1);
|
||||
++i;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Assignment currentIndex: " << cb->findData(tableId);
|
||||
cb->setCurrentIndex(cb->findData(tableId));
|
||||
|
||||
m_ui->partyLayout->addWidget(cb, i, 1, 1, 1);
|
||||
++i;
|
||||
}
|
||||
m_ui->partyLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding),
|
||||
i, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
m_ui->partyLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding), i, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AssignCodificationDataTable::apply()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AssignCodificationDataTable::apply()";
|
||||
DEBUG_LOG(m_logger) << "AssignCodificationDataTable::apply()";
|
||||
|
||||
removeAllAssignments();
|
||||
removeAllAssignments();
|
||||
|
||||
bool bStartRequests = false;
|
||||
for (LtsWidgets::LtsComboBox *cb : std::as_const(m_tableVec))
|
||||
{
|
||||
int partyId = cb->property("partyId").toInt();
|
||||
int tableId = cb->currentData().toInt();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Assignments: partyId: " << partyId
|
||||
<< " codTableId: " << tableId;
|
||||
|
||||
if (tableId < 1)
|
||||
bool bStartRequests = false;
|
||||
for (LtsWidgets::LtsComboBox* cb : std::as_const(m_tableVec))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("All parties must be assigned to a valid coding table."));
|
||||
return false;
|
||||
int partyId = cb->property("partyId").toInt();
|
||||
int tableId = cb->currentData().toInt();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Assignments: partyId: " << partyId << " codTableId: " << tableId;
|
||||
|
||||
if (tableId < 1)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("All parties must be assigned to a valid coding table."));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isTableAlreadyAssigned(tableId))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this,
|
||||
tr("All parties must be assigned to different coding tables."));
|
||||
return false;
|
||||
}
|
||||
|
||||
CodificationManagement::CodificationData codDdsData = m_dtc->codificationData(tableId);
|
||||
|
||||
bStartRequests = true;
|
||||
codDdsData.partyId(partyId);
|
||||
m_requestHelper->addRequest(
|
||||
[this, codDdsData]() { return m_ftc->codificationDataModifyRequest(codDdsData, this); });
|
||||
}
|
||||
|
||||
|
||||
if (isTableAlreadyAssigned(tableId) )
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("All parties must be assigned to different coding tables."));
|
||||
return false;
|
||||
}
|
||||
|
||||
CodificationManagement::CodificationData codDdsData = m_dtc->codificationData(tableId);
|
||||
|
||||
|
||||
|
||||
|
||||
bStartRequests = true;
|
||||
codDdsData.partyId(partyId);
|
||||
m_requestHelper->addRequest([this, codDdsData]()
|
||||
{
|
||||
return m_ftc->codificationDataModifyRequest(codDdsData, this);
|
||||
});
|
||||
|
||||
}
|
||||
if (!bStartRequests)
|
||||
return true;
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
if (!bStartRequests)
|
||||
return true;
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
bool AssignCodificationDataTable::removeAllAssignments()
|
||||
{
|
||||
const QMap<qint32, CodificationManagement::CodificationData> codMap = m_dtc->codificationDatas();
|
||||
const QMap<qint32, CodificationManagement::CodificationData> codMap = m_dtc->codificationDatas();
|
||||
|
||||
bool bStartRequests = false;
|
||||
for (CodificationManagement::CodificationData codData : codMap)
|
||||
{
|
||||
if (codData.partyId() < 0)
|
||||
continue;
|
||||
|
||||
bStartRequests = true;
|
||||
codData.partyId(-1);
|
||||
m_requestHelper->addRequest([this, codData]()
|
||||
bool bStartRequests = false;
|
||||
for (CodificationManagement::CodificationData codData : codMap)
|
||||
{
|
||||
return m_ftc->codificationDataModifyRequest(codData, this);
|
||||
});
|
||||
}
|
||||
if (!bStartRequests)
|
||||
return true;
|
||||
if (codData.partyId() < 0)
|
||||
continue;
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
bStartRequests = true;
|
||||
codData.partyId(-1);
|
||||
m_requestHelper->addRequest([this, codData]() { return m_ftc->codificationDataModifyRequest(codData, this); });
|
||||
}
|
||||
if (!bStartRequests)
|
||||
return true;
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
bool AssignCodificationDataTable::isTableAlreadyAssigned(int codTableId) const
|
||||
{
|
||||
const CodificationManagement::CodificationData &codData = m_dtc->codificationData(codTableId);
|
||||
return codData.partyId() > 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const CodificationManagement::CodificationData& codData = m_dtc->codificationData(codTableId);
|
||||
return codData.partyId() > 0;
|
||||
}
|
||||
Executable → Regular
+34
-40
@@ -1,72 +1,66 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
#include "ui_cod_assign_codification_data_table.h"
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <Services/CodificationManagement/cod_dtc.h>
|
||||
#include <Services/CodificationManagement/cod_ftc.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AssignCodificationDataTable;
|
||||
}
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
class CodificationDataOverviewModel;
|
||||
|
||||
class AssignCodificationDataTable : public LtsWidgets::LtsDialog,
|
||||
protected CodificationManagement::Interface::Ftc::CodificationDataModifyReplyHandler
|
||||
protected CodificationManagement::Interface::Ftc::CodificationDataModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AssignCodificationDataTable(QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit AssignCodificationDataTable(QWidget* parent = nullptr);
|
||||
|
||||
~AssignCodificationDataTable();
|
||||
~AssignCodificationDataTable();
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
LtsSession::LtsSession *session);
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc, LtsSession::LtsSession* session);
|
||||
|
||||
|
||||
void onCodificationDataModifyReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
|
||||
void onCodificationDataModifyReply(const Core::FunctionReplyObject& replyObject) override
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
bool apply() override;
|
||||
|
||||
bool apply() override;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
|
||||
private:
|
||||
bool removeAllAssignments();
|
||||
bool isTableAlreadyAssigned(int codTableId) const;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
private:
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
LtsSession::LtsSession* m_session{nullptr};
|
||||
CodificationDataOverviewModel* m_model{nullptr};
|
||||
Ui::AssignCodificationDataTable* m_ui{nullptr};
|
||||
|
||||
bool removeAllAssignments();
|
||||
bool isTableAlreadyAssigned(int codTableId) const;
|
||||
|
||||
private:
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
CodificationDataOverviewModel *m_model{nullptr};
|
||||
Ui::AssignCodificationDataTable *m_ui{nullptr};
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper{nullptr};
|
||||
QVector<LtsWidgets::LtsComboBox*> m_tableVec;
|
||||
LtsUtils::RequestHelper* m_requestHelper{nullptr};
|
||||
QVector<LtsWidgets::LtsComboBox*> m_tableVec;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+168
-190
@@ -1,262 +1,240 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "cod_authentication_code_model.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QPalette>
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
AuthenticationCodeModel::AuthenticationCodeModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_codificationDataId(0)
|
||||
, m_isEditMode(false)
|
||||
AuthenticationCodeModel::AuthenticationCodeModel(QObject* parent)
|
||||
: QAbstractTableModel(parent), m_dtc(nullptr), m_codificationDataId(0), m_isEditMode(false)
|
||||
{
|
||||
memset(m_matrix, 0, sizeof m_matrix);
|
||||
DEBUG_LOG(m_logger) << "ctor AuthenticationCodeModel";
|
||||
memset(m_matrix, 0, sizeof m_matrix);
|
||||
DEBUG_LOG(m_logger) << "ctor AuthenticationCodeModel";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool AuthenticationCodeModel::init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode)
|
||||
bool AuthenticationCodeModel::init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc,
|
||||
int codificationDataId, bool isEditMode)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AuthenticationCodeModel::init()";
|
||||
if (!dtc)
|
||||
return false;
|
||||
DEBUG_LOG(m_logger) << "AuthenticationCodeModel::init()";
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
DEBUG_LOG(m_logger) << "AuthenticationCodeModel::init()...";
|
||||
DEBUG_LOG(m_logger) << "AuthenticationCodeModel::init()...";
|
||||
|
||||
m_dtc = dtc;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_isEditMode = isEditMode;
|
||||
m_dtc = dtc;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_isEditMode = isEditMode;
|
||||
|
||||
|
||||
m_ColumnSelectionValues.resize(5);
|
||||
for (char i = 0; i < 5; ++i)
|
||||
m_ColumnSelectionValues[i] = QLatin1Char('V' + i);
|
||||
m_ColumnSelectionValues.resize(5);
|
||||
for (char i = 0; i < 5; ++i)
|
||||
m_ColumnSelectionValues[i] = QLatin1Char('V' + i);
|
||||
|
||||
|
||||
m_RowSelectionValues << QLatin1Char('A') << QLatin1Char('D') << QLatin1Char('E')
|
||||
<< QLatin1Char('G') << QLatin1Char('H') << QLatin1Char('I')
|
||||
<< QLatin1Char('L') << QLatin1Char('N') << QLatin1Char('O')
|
||||
<< QLatin1Char('R') << QLatin1Char('S') << QLatin1Char('T')
|
||||
<< QLatin1Char('U') ;
|
||||
m_RowSelectionValues << QLatin1Char('A') << QLatin1Char('D') << QLatin1Char('E') << QLatin1Char('G')
|
||||
<< QLatin1Char('H') << QLatin1Char('I') << QLatin1Char('L') << QLatin1Char('N')
|
||||
<< QLatin1Char('O') << QLatin1Char('R') << QLatin1Char('S') << QLatin1Char('T')
|
||||
<< QLatin1Char('U');
|
||||
|
||||
resetMatrix();
|
||||
|
||||
if (!isEditMode)
|
||||
{
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged,
|
||||
this, &AuthenticationCodeModel::onCodificationDataChanged);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
resetMatrix();
|
||||
|
||||
if (!isEditMode)
|
||||
{
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged, this,
|
||||
&AuthenticationCodeModel::onCodificationDataChanged);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void AuthenticationCodeModel::resetMatrix()
|
||||
{
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
m_matrix[row][column] = 0;
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
{
|
||||
m_matrix[row][column] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
return ;
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool AuthenticationCodeModel::setMatrixValuesCSV(const QString &csvData)
|
||||
bool AuthenticationCodeModel::setMatrixValuesCSV(const QString& csvData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setMatrixValuesCSV: " << csvData;
|
||||
DEBUG_LOG(m_logger) << "setMatrixValuesCSV: " << csvData;
|
||||
|
||||
const QVector<QStringRef> slRows = csvData.splitRef(QLatin1Char('\n'));
|
||||
if (slRows.size() != rowCount())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid row data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << rowCount() - 1 << "/" << slRows.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int row = 0; row < slRows.size(); ++row)
|
||||
{
|
||||
const QVector<QStringRef> slColumns = slRows[row].split(QLatin1Char(';'));
|
||||
if (slColumns.size() != columnCount())
|
||||
const QVector<QStringRef> slRows = csvData.splitRef(QLatin1Char('\n'));
|
||||
if (slRows.size() != rowCount())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << columnCount() - 1 << "/" << slColumns.size();
|
||||
return false;
|
||||
ERROR_LOG(m_logger) << "Invalid row data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << rowCount() - 1 << "/" << slRows.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
for (int row = 0; row < slRows.size(); ++row)
|
||||
{
|
||||
m_matrix[row][column] = slColumns.at(column).toInt();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const QVector<QStringRef> slColumns = slRows[row].split(QLatin1Char(';'));
|
||||
if (slColumns.size() != columnCount())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << columnCount() - 1 << "/" << slColumns.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
{
|
||||
m_matrix[row][column] = slColumns.at(column).toInt();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString AuthenticationCodeModel::getMatrixDataCSVString() const
|
||||
{
|
||||
QStringList slColumns;
|
||||
slColumns.reserve(columnCount());
|
||||
QStringList slRows;
|
||||
slRows.reserve(rowCount() * columnCount());
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
slColumns.clear();
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
QStringList slColumns;
|
||||
slColumns.reserve(columnCount());
|
||||
QStringList slRows;
|
||||
slRows.reserve(rowCount() * columnCount());
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
slColumns << QStringLiteral("%1").arg(m_matrix[row][column], 2, 10, QLatin1Char('0'));
|
||||
slColumns.clear();
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
{
|
||||
slColumns << QStringLiteral("%1").arg(m_matrix[row][column], 2, 10, QLatin1Char('0'));
|
||||
}
|
||||
slRows << slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
slRows << slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
return slRows.join(QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
return slRows.join(QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
void AuthenticationCodeModel::setEditMode(bool isEditMode)
|
||||
{
|
||||
m_isEditMode = isEditMode;
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
}
|
||||
|
||||
m_isEditMode = isEditMode;
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
}
|
||||
|
||||
bool AuthenticationCodeModel::isEditMode() const
|
||||
{
|
||||
return m_isEditMode;
|
||||
}
|
||||
return m_isEditMode;
|
||||
}
|
||||
|
||||
|
||||
int AuthenticationCodeModel::rowCount(const QModelIndex &parent) const
|
||||
int AuthenticationCodeModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 13;
|
||||
}
|
||||
Q_UNUSED(parent)
|
||||
return 13;
|
||||
}
|
||||
|
||||
|
||||
int AuthenticationCodeModel::columnCount(const QModelIndex &parent) const
|
||||
int AuthenticationCodeModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 5;
|
||||
}
|
||||
|
||||
Q_UNUSED(parent)
|
||||
return 5;
|
||||
}
|
||||
|
||||
QVariant AuthenticationCodeModel::headerData(int column, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
if (role != Qt::DisplayRole)
|
||||
return QAbstractTableModel::headerData(column, orientation, role);
|
||||
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
if (!m_ColumnSelectionValues.isEmpty())
|
||||
return m_ColumnSelectionValues.at(column);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
if (orientation == Qt::Vertical)
|
||||
{
|
||||
if (!m_RowSelectionValues.isEmpty())
|
||||
return m_RowSelectionValues.at(column);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
return QAbstractTableModel::headerData(column, orientation, role);
|
||||
}
|
||||
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
if (!m_ColumnSelectionValues.isEmpty())
|
||||
return m_ColumnSelectionValues.at(column);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
if (orientation == Qt::Vertical)
|
||||
{
|
||||
if (!m_RowSelectionValues.isEmpty())
|
||||
return m_RowSelectionValues.at(column);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
return QAbstractTableModel::headerData(column, orientation, role);
|
||||
}
|
||||
|
||||
|
||||
QVariant AuthenticationCodeModel::data(const QModelIndex &index, int role) const
|
||||
QVariant AuthenticationCodeModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if ((role == Qt::DisplayRole || role == Qt::EditRole))
|
||||
{
|
||||
if ((role == Qt::DisplayRole || role == Qt::EditRole))
|
||||
{
|
||||
|
||||
return QStringLiteral("%1").arg(m_matrix[index.row()][index.column()], 2, 10, QLatin1Char('0'));
|
||||
}
|
||||
return QStringLiteral("%1").arg(m_matrix[index.row()][index.column()], 2, 10, QLatin1Char('0'));
|
||||
}
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignCenter;
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignCenter;
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (m_isEditMode)
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
else
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (m_isEditMode)
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
else
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool AuthenticationCodeModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
bool AuthenticationCodeModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setData() row/col: " << index.row() << "/" << index.column()
|
||||
<< " char:" << value.toString() << " int:" << value.toInt();
|
||||
DEBUG_LOG(m_logger) << "setData() row/col: " << index.row() << "/" << index.column() << " char:" << value.toString()
|
||||
<< " int:" << value.toInt();
|
||||
|
||||
bool bOk;
|
||||
int val = value.toInt(&bOk);
|
||||
bool bOk;
|
||||
int val = value.toInt(&bOk);
|
||||
|
||||
if ((!bOk) || (val < 0) || (val > 99))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "setData() row/col: " << index.row() << "/" << index.column()
|
||||
<< " Invalid Input! " << value.toString() << " Required input value in the range 0-99.";
|
||||
return false;
|
||||
}
|
||||
if ((!bOk) || (val < 0) || (val > 99))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "setData() row/col: " << index.row() << "/" << index.column() << " Invalid Input! "
|
||||
<< value.toString() << " Required input value in the range 0-99.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
m_matrix[index.row()][index.column()] = val;
|
||||
emit dataModified();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
m_matrix[index.row()][index.column()] = val;
|
||||
emit dataModified();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Qt::ItemFlags AuthenticationCodeModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags AuthenticationCodeModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
Qt::ItemFlags flags = QAbstractTableModel::flags(index);
|
||||
Qt::ItemFlags flags = QAbstractTableModel::flags(index);
|
||||
|
||||
if ((index.row() <= rowCount()-1) && (index.column() <= columnCount() - 1))
|
||||
{
|
||||
if (isEditMode())
|
||||
flags |= Qt::ItemIsEditable;
|
||||
else
|
||||
flags &= ~Qt::ItemIsEditable;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
if ((index.row() <= rowCount() - 1) && (index.column() <= columnCount() - 1))
|
||||
{
|
||||
if (isEditMode())
|
||||
flags |= Qt::ItemIsEditable;
|
||||
else
|
||||
flags &= ~Qt::ItemIsEditable;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
||||
void AuthenticationCodeModel::onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
void AuthenticationCodeModel::onCodificationDataChanged(const CodificationManagement::CodificationData& data,
|
||||
DataModification modType)
|
||||
{
|
||||
const int id = data.id();
|
||||
const int id = data.id();
|
||||
|
||||
DEBUG_LOG(m_logger) << "onCodificationDataChanged for CodificationData id: " << id
|
||||
<< " - AuthenticationCodeMatrix data: " << data.authenticationTableMatirx().c_str()
|
||||
<< " - modType: " << (int)modType;
|
||||
DEBUG_LOG(m_logger) << "onCodificationDataChanged for CodificationData id: " << id
|
||||
<< " - AuthenticationCodeMatrix data: " << data.authenticationTableMatirx().c_str()
|
||||
<< " - modType: " << (int)modType;
|
||||
|
||||
if (m_codificationDataId != data.id())
|
||||
return;
|
||||
if (m_codificationDataId != data.id())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "CodificationData was removed. id: " << id << " ToDo: 'ShowCodificationData' Tab loeschen !?";
|
||||
|
||||
resetMatrix();
|
||||
return;
|
||||
}
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "CodificationData was removed. id: " << id
|
||||
<< " ToDo: 'ShowCodificationData' Tab loeschen !?";
|
||||
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationData was modifed. id: " << id << " - " << data.note();
|
||||
resetMatrix();
|
||||
return;
|
||||
}
|
||||
|
||||
QString qs = QString::fromStdString(data.authenticationTableMatirx());
|
||||
setMatrixValuesCSV(qs);
|
||||
}
|
||||
}
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationData was modifed. id: " << id << " - " << data.note();
|
||||
|
||||
QString qs = QString::fromStdString(data.authenticationTableMatirx());
|
||||
setMatrixValuesCSV(qs);
|
||||
}
|
||||
}
|
||||
Executable → Regular
+32
-67
@@ -1,99 +1,64 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <CodificationManagement/cod_dtc.h>
|
||||
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class AuthenticationCodeModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AuthenticationCodeModel(QObject *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AuthenticationCodeModel(QObject* parent);
|
||||
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc, int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
void resetMatrix();
|
||||
|
||||
|
||||
bool setMatrixValuesCSV(const QString& csvData);
|
||||
|
||||
void resetMatrix();
|
||||
QString getMatrixDataCSVString() const;
|
||||
|
||||
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
|
||||
bool setMatrixValuesCSV(const QString &csvData);
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
QString getMatrixDataCSVString() const;
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role) override;
|
||||
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
Q_SIGNALS:
|
||||
|
||||
|
||||
void dataModified();
|
||||
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData& data, DataModification modType);
|
||||
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void setMatrix(const QVector<int>& data);
|
||||
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
int m_matrix[13][5];
|
||||
|
||||
|
||||
QVector<QChar> m_RowSelectionValues;
|
||||
QVector<QChar> m_ColumnSelectionValues;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
|
||||
|
||||
void dataModified();
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void setMatrix(const QVector <int> &data);
|
||||
|
||||
int m_matrix[13][5];
|
||||
|
||||
QVector <QChar> m_RowSelectionValues;
|
||||
QVector <QChar> m_ColumnSelectionValues;
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
int m_codificationDataId;
|
||||
bool m_isEditMode;
|
||||
int m_codificationDataId;
|
||||
bool m_isEditMode;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+95
-113
@@ -1,133 +1,115 @@
|
||||
|
||||
|
||||
|
||||
#include "cod_code_table_edit_delegate.h"
|
||||
|
||||
#include <QtWidgets/QLineEdit>
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
CodeTableEditDelegate::CodeTableEditDelegate(QWidget *parent, TableType tableType) : QItemDelegate(parent)
|
||||
, m_tableType(tableType),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
DEBUG_LOG(m_logger) << "CodeTableEditDelegate::ctor()";
|
||||
}
|
||||
|
||||
|
||||
QWidget *CodeTableEditDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
CodeTableEditDelegate::CodeTableEditDelegate(QWidget* parent, TableType tableType)
|
||||
: QItemDelegate(parent), m_tableType(tableType), m_logger(NGL::NGLLoggerBootstrap::getLogger())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodeTableEditDelegate::createEditor() TableType: " << m_tableType
|
||||
<< " rox/column: " << index.row() << "/" << index.column() ;
|
||||
DEBUG_LOG(m_logger) << "CodeTableEditDelegate::ctor()";
|
||||
}
|
||||
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(index)
|
||||
QLineEdit *le = new QLineEdit(parent);
|
||||
|
||||
switch (m_tableType)
|
||||
{
|
||||
case NumeralCode:
|
||||
{
|
||||
le->setMaxLength(1);
|
||||
break;
|
||||
}
|
||||
case AuthenticationCode:
|
||||
{
|
||||
QValidator *v = new QIntValidator(0, 99, le);
|
||||
le->setValidator(v);
|
||||
le->setMaxLength(2);
|
||||
break;
|
||||
}
|
||||
case LogisticalTerms:
|
||||
|
||||
if ((index.row() == 0) ||
|
||||
((index.column() == 0) && (index.row() > 0)))
|
||||
{
|
||||
le->setMaxLength(1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ((index.column() > 0) && (index.row() > 0))
|
||||
{
|
||||
|
||||
le->setMaxLength(20);
|
||||
break;
|
||||
}
|
||||
le->setMaxLength(15);
|
||||
break;
|
||||
case PhraseTable:
|
||||
le->setMaxLength(15);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return le;
|
||||
}
|
||||
|
||||
|
||||
void CodeTableEditDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
QWidget* CodeTableEditDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option,
|
||||
const QModelIndex& index) const
|
||||
{
|
||||
QLineEdit *le = qobject_cast<QLineEdit *>(editor);
|
||||
if (!le)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "CodeTableEditDelegate::createEditor() TableType: " << m_tableType
|
||||
<< " rox/column: " << index.row() << "/" << index.column();
|
||||
|
||||
QVariant v = index.data(Qt::EditRole);
|
||||
le->setText(v.toString());
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(index)
|
||||
QLineEdit* le = new QLineEdit(parent);
|
||||
|
||||
DEBUG_LOG(m_logger) << "CodeTableEditDelegate::setEditorData() TableType: " << m_tableType
|
||||
<< " rox/column: " << index.row() << "/" << index.column()
|
||||
<< " Input: " << v.toString();
|
||||
switch (m_tableType)
|
||||
{
|
||||
case NumeralCode: {
|
||||
le->setMaxLength(1);
|
||||
break;
|
||||
}
|
||||
case AuthenticationCode: {
|
||||
QValidator* v = new QIntValidator(0, 99, le);
|
||||
le->setValidator(v);
|
||||
le->setMaxLength(2);
|
||||
break;
|
||||
}
|
||||
case LogisticalTerms:
|
||||
|
||||
}
|
||||
if ((index.row() == 0) || ((index.column() == 0) && (index.row() > 0)))
|
||||
{
|
||||
le->setMaxLength(1);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((index.column() > 0) && (index.row() > 0))
|
||||
{
|
||||
|
||||
void CodeTableEditDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const
|
||||
le->setMaxLength(20);
|
||||
break;
|
||||
}
|
||||
le->setMaxLength(15);
|
||||
break;
|
||||
case PhraseTable:
|
||||
le->setMaxLength(15);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return le;
|
||||
}
|
||||
|
||||
void CodeTableEditDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
|
||||
{
|
||||
QLineEdit *le = qobject_cast<QLineEdit *>(editor);
|
||||
if (!le)
|
||||
return;
|
||||
QLineEdit* le = qobject_cast<QLineEdit*>(editor);
|
||||
if (!le)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "CodeTableEditDelegate::setModelData() TableType: " << m_tableType
|
||||
<< " rox/column: " << index.row() << "/" << index.column()
|
||||
<< " Input: " << le->text();
|
||||
QVariant v = index.data(Qt::EditRole);
|
||||
le->setText(v.toString());
|
||||
|
||||
switch (m_tableType)
|
||||
{
|
||||
case NumeralCode:
|
||||
case AuthenticationCode:
|
||||
case PhraseTable:
|
||||
{
|
||||
model->setData(index, le->text(), Qt::EditRole);
|
||||
break;
|
||||
}
|
||||
case LogisticalTerms:
|
||||
{
|
||||
|
||||
if ((index.row() == 0) ||
|
||||
((index.column() == 0) && (index.row() > 0)))
|
||||
DEBUG_LOG(m_logger) << "CodeTableEditDelegate::setEditorData() TableType: " << m_tableType
|
||||
<< " rox/column: " << index.row() << "/" << index.column() << " Input: " << v.toString();
|
||||
}
|
||||
|
||||
void CodeTableEditDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
|
||||
{
|
||||
QLineEdit* le = qobject_cast<QLineEdit*>(editor);
|
||||
if (!le)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "CodeTableEditDelegate::setModelData() TableType: " << m_tableType
|
||||
<< " rox/column: " << index.row() << "/" << index.column() << " Input: " << le->text();
|
||||
|
||||
switch (m_tableType)
|
||||
{
|
||||
model->setData(index, le->text(), Qt::EditRole);
|
||||
break;
|
||||
case NumeralCode:
|
||||
case AuthenticationCode:
|
||||
case PhraseTable: {
|
||||
model->setData(index, le->text(), Qt::EditRole);
|
||||
break;
|
||||
}
|
||||
case LogisticalTerms: {
|
||||
|
||||
if ((index.row() == 0) || ((index.column() == 0) && (index.row() > 0)))
|
||||
{
|
||||
model->setData(index, le->text(), Qt::EditRole);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((index.column() > 0) && (index.row() > 0))
|
||||
{
|
||||
QString qs = le->text();
|
||||
if (qs.size() > 10)
|
||||
{
|
||||
qs.insert(10, QLatin1String("\n"));
|
||||
}
|
||||
model->setData(index, qs, Qt::EditRole);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if ((index.column() > 0) && (index.row() > 0))
|
||||
{
|
||||
QString qs = le->text();
|
||||
if (qs.size() > 10)
|
||||
{
|
||||
qs.insert(10, QLatin1String("\n"));
|
||||
}
|
||||
model->setData(index, qs, Qt::EditRole);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Executable → Regular
+13
-32
@@ -1,51 +1,32 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QItemDelegate>
|
||||
#include <CodificationManagement/logger.h>
|
||||
|
||||
#include <QItemDelegate>
|
||||
#include <QObject>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class CodeTableEditDelegate : public QItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
enum TableType { Undefined, NumeralCode, AuthenticationCode, LogisticalTerms, PhraseTable };
|
||||
|
||||
enum TableType
|
||||
{
|
||||
Undefined,
|
||||
NumeralCode,
|
||||
AuthenticationCode,
|
||||
LogisticalTerms,
|
||||
PhraseTable
|
||||
};
|
||||
explicit CodeTableEditDelegate(QWidget* parent = nullptr, TableType tableType = Undefined);
|
||||
|
||||
explicit CodeTableEditDelegate(QWidget *parent = nullptr, TableType tableType = Undefined);
|
||||
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
|
||||
|
||||
void setEditorData(QWidget* editor, const QModelIndex& index) const override;
|
||||
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override ;
|
||||
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
|
||||
|
||||
|
||||
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||
|
||||
|
||||
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
TableType m_tableType;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
TableType m_tableType;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+127
-147
@@ -1,179 +1,159 @@
|
||||
|
||||
|
||||
|
||||
#include "cod_codification_data_overview_model.h"
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <QColor>
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
CodificationDataOverviewModel::CodificationDataOverviewModel(QObject *parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<CodificationManagement::CodificationData>({tr("Id"),
|
||||
tr("Identifier"),
|
||||
tr("Validity Time"),
|
||||
tr("Party"),
|
||||
QStringLiteral("PartyIdHiddenColumn"),
|
||||
QStringLiteral("NumCodeTableColIndex"),
|
||||
QStringLiteral("NumCodeTableRowIndex"),
|
||||
QStringLiteral("AuthentTableColIndex"),
|
||||
QStringLiteral("AuthentTableColIndex"),
|
||||
QStringLiteral("AuthenTableMatrix"),
|
||||
QStringLiteral("LogTermTableColIndex"),
|
||||
QStringLiteral("LogTermTableRowIndex"),
|
||||
QStringLiteral("LogTermTableMatrix"),
|
||||
QStringLiteral("PhraseTable"),
|
||||
tr("Note")},
|
||||
parent)
|
||||
, m_codDtc(nullptr)
|
||||
CodificationDataOverviewModel::CodificationDataOverviewModel(QObject* parent)
|
||||
: LtsWidgets::LtsAbstractTableModel<CodificationManagement::CodificationData>(
|
||||
{tr("Id"), tr("Identifier"), tr("Validity Time"), tr("Party"), QStringLiteral("PartyIdHiddenColumn"),
|
||||
QStringLiteral("NumCodeTableColIndex"), QStringLiteral("NumCodeTableRowIndex"),
|
||||
QStringLiteral("AuthentTableColIndex"), QStringLiteral("AuthentTableColIndex"),
|
||||
QStringLiteral("AuthenTableMatrix"), QStringLiteral("LogTermTableColIndex"),
|
||||
QStringLiteral("LogTermTableRowIndex"), QStringLiteral("LogTermTableMatrix"), QStringLiteral("PhraseTable"),
|
||||
tr("Note")},
|
||||
parent),
|
||||
m_codDtc(nullptr)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CodificationDataOverviewModel::initModel(const std::shared_ptr<CodificationManagement::Interface::Dtc> &codDtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc)
|
||||
bool CodificationDataOverviewModel::initModel(const std::shared_ptr<CodificationManagement::Interface::Dtc>& codDtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationDataModel::initModel()";
|
||||
DEBUG_LOG(m_logger) << "CodificationDataModel::initModel()";
|
||||
|
||||
if (!codDtc || !ppmDtc)
|
||||
return false;
|
||||
if (!codDtc || !ppmDtc)
|
||||
return false;
|
||||
|
||||
m_codDtc = codDtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
connect(m_codDtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged,
|
||||
this, &CodificationDataOverviewModel::onDataChanged);
|
||||
m_codDtc->codificationDatas([this](const CodificationData &item) { insertRow(item); });
|
||||
return true;
|
||||
}
|
||||
m_codDtc = codDtc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
connect(m_codDtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged, this,
|
||||
&CodificationDataOverviewModel::onDataChanged);
|
||||
m_codDtc->codificationDatas([this](const CodificationData& item) { insertRow(item); });
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
QVariant CodificationDataOverviewModel::data(const QModelIndex &index, int role) const
|
||||
QVariant CodificationDataOverviewModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole &&
|
||||
role != Qt::BackgroundRole )
|
||||
return QVariant();
|
||||
if (role != Qt::DisplayRole && role != Qt::BackgroundRole)
|
||||
return QVariant();
|
||||
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const CodificationManagement::CodificationData &codificationData = m_vecData.at(index.row());
|
||||
const CodificationManagement::CodificationData& codificationData = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
switch (index.column())
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
case Id:
|
||||
return codificationData.id();
|
||||
case Identifier:
|
||||
return QString::fromUtf8(codificationData.identifier().c_str());
|
||||
case ValidityTime:
|
||||
return QDateTime::fromMSecsSinceEpoch(codificationData.validityTime());
|
||||
case PartyId:
|
||||
if (codificationData.partyId() < 0)
|
||||
return QStringLiteral("---");
|
||||
|
||||
if (codificationData.partyId() == 2)
|
||||
return tr("OPFOR");
|
||||
else if (codificationData.partyId() == 3)
|
||||
return tr("BLUFOR");
|
||||
return ParticipantManagement::trPartyName(m_ppmDtc->party(codificationData.partyId()).name());
|
||||
case PartyIdHiddenColumn:
|
||||
|
||||
return codificationData.partyId();
|
||||
case NumeralCodeTableColumnIndex:
|
||||
return QString::fromUtf8(codificationData.numeralCodeTableColumnIndex().c_str());
|
||||
case NumeralCodeTableRowIndex:
|
||||
return QString::fromUtf8(codificationData.numeralCodeTableRowIndex().c_str());
|
||||
case AuthenticationTableColumnIndex:
|
||||
return QString::fromUtf8(codificationData.authenticationTableColumnIndex().c_str());
|
||||
case AuthenticationTableRowIndex:
|
||||
return QString::fromUtf8(codificationData.authenticationTableRowIndex().c_str());
|
||||
case AuthenticationTableMatrix:
|
||||
return QString::fromUtf8(codificationData.authenticationTableMatirx().c_str());
|
||||
case LogisticalTermTableColumnIndex:
|
||||
return QString::fromUtf8(codificationData.logisticalTermTableColumnIndex().c_str());
|
||||
case LogisticalTermTableRowIndex:
|
||||
return QString::fromUtf8(codificationData.logisticalTermTableRowIndex().c_str());
|
||||
case LogisticalTermTableMatrix:
|
||||
return QString::fromUtf8(codificationData.logisticalTermTableMatrix().c_str());
|
||||
case PhraseTable:
|
||||
return QString::fromUtf8(codificationData.phraseTable().c_str());
|
||||
case Note:
|
||||
return QString::fromUtf8(codificationData.note().c_str());
|
||||
}
|
||||
}
|
||||
switch (index.column())
|
||||
{
|
||||
case Id:
|
||||
return codificationData.id();
|
||||
case Identifier:
|
||||
return QString::fromUtf8(codificationData.identifier().c_str());
|
||||
case ValidityTime:
|
||||
return QDateTime::fromMSecsSinceEpoch(codificationData.validityTime());
|
||||
case PartyId:
|
||||
if (codificationData.partyId() < 0)
|
||||
return QStringLiteral("---");
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
switch (index.column())
|
||||
if (codificationData.partyId() == 2)
|
||||
return tr("OPFOR");
|
||||
else if (codificationData.partyId() == 3)
|
||||
return tr("BLUFOR");
|
||||
return ParticipantManagement::trPartyName(m_ppmDtc->party(codificationData.partyId()).name());
|
||||
case PartyIdHiddenColumn:
|
||||
|
||||
return codificationData.partyId();
|
||||
case NumeralCodeTableColumnIndex:
|
||||
return QString::fromUtf8(codificationData.numeralCodeTableColumnIndex().c_str());
|
||||
case NumeralCodeTableRowIndex:
|
||||
return QString::fromUtf8(codificationData.numeralCodeTableRowIndex().c_str());
|
||||
case AuthenticationTableColumnIndex:
|
||||
return QString::fromUtf8(codificationData.authenticationTableColumnIndex().c_str());
|
||||
case AuthenticationTableRowIndex:
|
||||
return QString::fromUtf8(codificationData.authenticationTableRowIndex().c_str());
|
||||
case AuthenticationTableMatrix:
|
||||
return QString::fromUtf8(codificationData.authenticationTableMatirx().c_str());
|
||||
case LogisticalTermTableColumnIndex:
|
||||
return QString::fromUtf8(codificationData.logisticalTermTableColumnIndex().c_str());
|
||||
case LogisticalTermTableRowIndex:
|
||||
return QString::fromUtf8(codificationData.logisticalTermTableRowIndex().c_str());
|
||||
case LogisticalTermTableMatrix:
|
||||
return QString::fromUtf8(codificationData.logisticalTermTableMatrix().c_str());
|
||||
case PhraseTable:
|
||||
return QString::fromUtf8(codificationData.phraseTable().c_str());
|
||||
case Note:
|
||||
return QString::fromUtf8(codificationData.note().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
case PartyId:
|
||||
if (codificationData.partyId() >= 0)
|
||||
return QColor::fromRgb(QRgb(m_ppmDtc->party(codificationData.partyId()).color()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (index.column())
|
||||
{
|
||||
case PartyId:
|
||||
if (codificationData.partyId() >= 0)
|
||||
return QColor::fromRgb(QRgb(m_ppmDtc->party(codificationData.partyId()).color()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int CodificationDataOverviewModel::getCodTableId(int partyId) const
|
||||
{
|
||||
for (const CodificationManagement::CodificationData &codificationData : m_vecData)
|
||||
{
|
||||
if (codificationData.partyId() == partyId)
|
||||
return codificationData.id();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void CodificationDataOverviewProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
m_sourceModel = qobject_cast<CodificationDataOverviewModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
for (const CodificationManagement::CodificationData& codificationData : m_vecData)
|
||||
{
|
||||
if (codificationData.partyId() == partyId)
|
||||
return codificationData.id();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool CodificationDataOverviewProxyModel::lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const
|
||||
void CodificationDataOverviewProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
|
||||
{
|
||||
if (!m_sourceModel ||
|
||||
source_left.column() != source_right.column() ||
|
||||
!source_left.isValid() ||
|
||||
!source_right.isValid())
|
||||
m_sourceModel = qobject_cast<CodificationDataOverviewModel*>(sourceModel);
|
||||
LtsWidgets::LtsColumnFilterProxyModel::setSourceModel(sourceModel);
|
||||
}
|
||||
|
||||
bool CodificationDataOverviewProxyModel::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())
|
||||
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 CodificationDataOverviewModel::ValidityTime:
|
||||
return dataLeft.validityTime() < dataRight.validityTime();
|
||||
|
||||
case CodificationDataOverviewModel::Id:
|
||||
case CodificationDataOverviewModel::Identifier:
|
||||
|
||||
case CodificationDataOverviewModel::PartyId:
|
||||
case CodificationDataOverviewModel::PartyIdHiddenColumn:
|
||||
case CodificationDataOverviewModel::NumeralCodeTableColumnIndex:
|
||||
case CodificationDataOverviewModel::NumeralCodeTableRowIndex:
|
||||
case CodificationDataOverviewModel::AuthenticationTableColumnIndex:
|
||||
case CodificationDataOverviewModel::AuthenticationTableRowIndex:
|
||||
case CodificationDataOverviewModel::AuthenticationTableMatrix:
|
||||
case CodificationDataOverviewModel::LogisticalTermTableColumnIndex:
|
||||
case CodificationDataOverviewModel::LogisticalTermTableRowIndex:
|
||||
case CodificationDataOverviewModel::LogisticalTermTableMatrix:
|
||||
case CodificationDataOverviewModel::PhraseTable:
|
||||
case CodificationDataOverviewModel::Note:
|
||||
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 CodificationDataOverviewModel::ValidityTime:
|
||||
return dataLeft.validityTime() < dataRight.validityTime();
|
||||
|
||||
case CodificationDataOverviewModel::Id:
|
||||
case CodificationDataOverviewModel::Identifier:
|
||||
|
||||
case CodificationDataOverviewModel::PartyId:
|
||||
case CodificationDataOverviewModel::PartyIdHiddenColumn:
|
||||
case CodificationDataOverviewModel::NumeralCodeTableColumnIndex:
|
||||
case CodificationDataOverviewModel::NumeralCodeTableRowIndex:
|
||||
case CodificationDataOverviewModel::AuthenticationTableColumnIndex:
|
||||
case CodificationDataOverviewModel::AuthenticationTableRowIndex:
|
||||
case CodificationDataOverviewModel::AuthenticationTableMatrix:
|
||||
case CodificationDataOverviewModel::LogisticalTermTableColumnIndex:
|
||||
case CodificationDataOverviewModel::LogisticalTermTableRowIndex:
|
||||
case CodificationDataOverviewModel::LogisticalTermTableMatrix:
|
||||
case CodificationDataOverviewModel::PhraseTable:
|
||||
case CodificationDataOverviewModel::Note:
|
||||
break;
|
||||
}
|
||||
return LtsWidgets::LtsColumnFilterProxyModel::lessThan(source_left, source_right);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+43
-48
@@ -1,72 +1,67 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/CodificationManagement/logger.h>
|
||||
#include <Services/CodificationManagement/cod_dtc.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Services/CodificationManagement/cod_dtc.h>
|
||||
#include <Services/CodificationManagement/logger.h>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
|
||||
|
||||
class CodificationDataOverviewModel : public LtsWidgets::LtsAbstractTableModel<CodificationManagement::CodificationData>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
Identifier,
|
||||
ValidityTime,
|
||||
PartyId,
|
||||
PartyIdHiddenColumn,
|
||||
NumeralCodeTableColumnIndex,
|
||||
NumeralCodeTableRowIndex,
|
||||
AuthenticationTableColumnIndex,
|
||||
AuthenticationTableRowIndex,
|
||||
AuthenticationTableMatrix,
|
||||
LogisticalTermTableColumnIndex,
|
||||
LogisticalTermTableRowIndex,
|
||||
LogisticalTermTableMatrix,
|
||||
PhraseTable,
|
||||
Note
|
||||
};
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns {
|
||||
Id,
|
||||
Identifier,
|
||||
ValidityTime,
|
||||
PartyId,
|
||||
PartyIdHiddenColumn,
|
||||
NumeralCodeTableColumnIndex,
|
||||
NumeralCodeTableRowIndex,
|
||||
AuthenticationTableColumnIndex,
|
||||
AuthenticationTableRowIndex,
|
||||
AuthenticationTableMatrix,
|
||||
LogisticalTermTableColumnIndex,
|
||||
LogisticalTermTableRowIndex,
|
||||
LogisticalTermTableMatrix,
|
||||
PhraseTable,
|
||||
Note
|
||||
};
|
||||
|
||||
explicit CodificationDataOverviewModel(QObject* parent = nullptr);
|
||||
|
||||
explicit CodificationDataOverviewModel(QObject *parent = nullptr);
|
||||
bool initModel(const std::shared_ptr<CodificationManagement::Interface::Dtc>& codDtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc);
|
||||
|
||||
bool initModel(const std::shared_ptr<CodificationManagement::Interface::Dtc> &codDtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc);
|
||||
int getCodTableId(int partyId) const;
|
||||
|
||||
int getCodTableId(int partyId) const;
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override final;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override final;
|
||||
friend class CodificationDataOverviewProxyModel;
|
||||
|
||||
friend class CodificationDataOverviewProxyModel;
|
||||
|
||||
private:
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_codDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_codDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
};
|
||||
|
||||
class CodificationDataOverviewProxyModel 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:
|
||||
CodificationDataOverviewModel *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:
|
||||
CodificationDataOverviewModel* m_sourceModel = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+105
-130
@@ -1,203 +1,178 @@
|
||||
|
||||
|
||||
|
||||
#include "cod_codification_data_overview_view.h"
|
||||
#include "ui_cod_codification_data_overview_view.h"
|
||||
|
||||
#include "cod_codification_data_table_view.h"
|
||||
#include "cod_codification_data_table_edit_view.h"
|
||||
#include "cod_codification_data_table_view.h"
|
||||
#include "ui_cod_codification_data_overview_view.h"
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
#include <QTreeView>
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
|
||||
CodificationDataOverviewView::CodificationDataOverviewView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_session(session)
|
||||
, m_model(nullptr)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_ui(new Ui::CodificationDataOverviewView)
|
||||
CodificationDataOverviewView::CodificationDataOverviewView(const QString& menuGroup, LtsSession::LtsSession* session,
|
||||
QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_menuGroup(menuGroup),
|
||||
m_session(session), m_model(nullptr), m_dtc(nullptr), m_ftc(nullptr),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this)), m_ui(new Ui::CodificationDataOverviewView)
|
||||
{
|
||||
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, &CodificationDataOverviewView::onSelectionChanged);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this,
|
||||
&CodificationDataOverviewView::onSelectionChanged);
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked,
|
||||
this, &CodificationDataOverviewView::onEditCodificationData);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this,
|
||||
&CodificationDataOverviewView::onEditCodificationData);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this, &CodificationDataOverviewView::onShowCodificationData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Show, false);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Show, this,
|
||||
&CodificationDataOverviewView::onShowCodificationData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, false);
|
||||
m_buttonBox->setButtonVisible(LtsWidgets::DialogButton::Show, false);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &CodificationDataOverviewView::onAddCodificationData);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this,
|
||||
&CodificationDataOverviewView::onAddCodificationData);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &CodificationDataOverviewView::onEditCodificationData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this,
|
||||
&CodificationDataOverviewView::onEditCodificationData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, false);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &CodificationDataOverviewView::onRemoveCodificationData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CodificationDataOverviewView::onPrint);
|
||||
|
||||
}
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this,
|
||||
&CodificationDataOverviewView::onRemoveCodificationData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CodificationDataOverviewView::onPrint);
|
||||
}
|
||||
|
||||
CodificationDataOverviewView::~CodificationDataOverviewView()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void CodificationDataOverviewView::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Codification Data"));
|
||||
translate(m_ui, tr("Codification Data"));
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Codification_Data"));
|
||||
}
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Codification_Data"));
|
||||
}
|
||||
|
||||
|
||||
bool CodificationDataOverviewView::init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc)
|
||||
bool CodificationDataOverviewView::init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc)
|
||||
{
|
||||
if (!dtc || !ftc || !ppmDtc)
|
||||
return false;
|
||||
if (!dtc || !ftc || !ppmDtc)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_ppmDtc = ppmDtc;
|
||||
|
||||
m_model = new CodificationDataOverviewModel(this);
|
||||
m_model->initModel(m_dtc, m_ppmDtc);
|
||||
m_proxyModel = new CodificationDataOverviewProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->widget->setModel(m_proxyModel);
|
||||
m_model = new CodificationDataOverviewModel(this);
|
||||
m_model->initModel(m_dtc, m_ppmDtc);
|
||||
m_proxyModel = new CodificationDataOverviewProxyModel(this);
|
||||
m_proxyModel->setSourceModel(m_model);
|
||||
m_ui->widget->setModel(m_proxyModel);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::Id);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::Id);
|
||||
#endif
|
||||
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::PartyIdHiddenColumn);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::NumeralCodeTableColumnIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::NumeralCodeTableRowIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::AuthenticationTableColumnIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::AuthenticationTableRowIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::AuthenticationTableMatrix);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::LogisticalTermTableColumnIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::LogisticalTermTableRowIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::LogisticalTermTableMatrix);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::PhraseTable);
|
||||
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::PartyIdHiddenColumn);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::NumeralCodeTableColumnIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::NumeralCodeTableRowIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::AuthenticationTableColumnIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::AuthenticationTableRowIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::AuthenticationTableMatrix);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::LogisticalTermTableColumnIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::LogisticalTermTableRowIndex);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::LogisticalTermTableMatrix);
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::PhraseTable);
|
||||
|
||||
|
||||
|
||||
m_ui->widget->setSortIndicator(CodificationDataOverviewModel::Note, Qt::AscendingOrder);
|
||||
|
||||
return true;
|
||||
}
|
||||
m_ui->widget->setSortIndicator(CodificationDataOverviewModel::Note, Qt::AscendingOrder);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CodificationDataOverviewView::onSelectionChanged()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, true);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, true);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, true);
|
||||
|
||||
|
||||
|
||||
}
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Show, true);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, true);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, true);
|
||||
}
|
||||
|
||||
void CodificationDataOverviewView::onShowCodificationData()
|
||||
{
|
||||
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;
|
||||
|
||||
CodificationManagement::CodificationData codificationData = m_model->getRowData(row);
|
||||
CodificationManagement::CodificationData codificationData = m_model->getRowData(row);
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- onShowCodificationData() "
|
||||
<< " id: " << codificationData.id();
|
||||
DEBUG_LOG(m_logger) << "--- onShowCodificationData() "
|
||||
<< " id: " << codificationData.id();
|
||||
|
||||
CodificationDataTableView *dialog = new CodificationDataTableView;
|
||||
dialog->init(m_dtc, m_ftc, m_session, codificationData.partyId(), codificationData.id());
|
||||
dialog->setUnchangeable(true);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("codShowCodificationData"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
|
||||
}
|
||||
CodificationDataTableView* dialog = new CodificationDataTableView;
|
||||
dialog->init(m_dtc, m_ftc, m_session, codificationData.partyId(), codificationData.id());
|
||||
dialog->setUnchangeable(true);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("codShowCodificationData"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void CodificationDataOverviewView::onAddCodificationData()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "--- onAddCodificationData() ";
|
||||
DEBUG_LOG(m_logger) << "--- onAddCodificationData() ";
|
||||
|
||||
CodificationDataTableEditView *dialog = new CodificationDataTableEditView(this);
|
||||
dialog->init(m_dtc, m_ftc, m_session, 0);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("codSetCodificationData"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
|
||||
}
|
||||
CodificationDataTableEditView* dialog = new CodificationDataTableEditView(this);
|
||||
dialog->init(m_dtc, m_ftc, m_session, 0);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("codSetCodificationData"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void CodificationDataOverviewView::onEditCodificationData()
|
||||
{
|
||||
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;
|
||||
|
||||
CodificationManagement::CodificationData codificationData = m_model->getRowData(row);
|
||||
CodificationManagement::CodificationData codificationData = m_model->getRowData(row);
|
||||
|
||||
DEBUG_LOG(m_logger) << "--- onEditCodificationData() "
|
||||
<< " id: " << codificationData.id();
|
||||
DEBUG_LOG(m_logger) << "--- onEditCodificationData() "
|
||||
<< " id: " << codificationData.id();
|
||||
|
||||
CodificationDataTableEditView *dialog = new CodificationDataTableEditView(this);
|
||||
dialog->init(m_dtc, m_ftc, m_session, codificationData.id());
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("codSetCodificationData"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
|
||||
}
|
||||
CodificationDataTableEditView* dialog = new CodificationDataTableEditView(this);
|
||||
dialog->init(m_dtc, m_ftc, m_session, codificationData.id());
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("codSetCodificationData"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void CodificationDataOverviewView::onRemoveCodificationData()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
CodificationManagement::CodificationData codificationData = m_model->getRowData(idx.row());
|
||||
Core::RemoveElementRequest request(codificationData.id());
|
||||
|
||||
m_requestHelper->startSingleRequest([request, this]()
|
||||
{
|
||||
return m_ftc->codificationDataRemoveRequest(request, this);
|
||||
});
|
||||
}
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
CodificationManagement::CodificationData codificationData = m_model->getRowData(idx.row());
|
||||
Core::RemoveElementRequest request(codificationData.id());
|
||||
|
||||
m_requestHelper->startSingleRequest(
|
||||
[request, this]() { return m_ftc->codificationDataRemoveRequest(request, this); });
|
||||
}
|
||||
|
||||
void CodificationDataOverviewView::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
|
||||
}
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView());
|
||||
}
|
||||
|
||||
void CodificationDataOverviewView::tableColumnOrganiserSetting()
|
||||
{
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
+40
-42
@@ -1,17 +1,15 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cod_codification_data_overview_model.h"
|
||||
|
||||
#include <Services/CodificationManagement/logger.h>
|
||||
#include <Services/CodificationManagement/cod_dtc.h>
|
||||
#include <Services/CodificationManagement/cod_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 <Services/CodificationManagement/cod_dtc.h>
|
||||
#include <Services/CodificationManagement/cod_ftc.h>
|
||||
#include <Services/CodificationManagement/logger.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -21,49 +19,49 @@ class CodificationDataOverviewView;
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
|
||||
class CodificationDataOverviewView : public LtsWidgets::LtsDialog,
|
||||
protected CodificationManagement::Interface::Ftc::CodificationDataRemoveReplyHandler
|
||||
class CodificationDataOverviewView
|
||||
: public LtsWidgets::LtsDialog,
|
||||
protected CodificationManagement::Interface::Ftc::CodificationDataRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CodificationDataOverviewView(const QString &menuGroup, LtsSession::LtsSession *session, QWidget *parent = nullptr);
|
||||
~CodificationDataOverviewView();
|
||||
public:
|
||||
explicit CodificationDataOverviewView(const QString& menuGroup, LtsSession::LtsSession* session,
|
||||
QWidget* parent = nullptr);
|
||||
~CodificationDataOverviewView();
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc> &ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc);
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc>& ftc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc>& ppmDtc);
|
||||
|
||||
|
||||
void onCodificationDataRemoveReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
|
||||
void onCodificationDataRemoveReply(const Core::FunctionReplyObject& replyObject) override
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onShowCodificationData();
|
||||
void onAddCodificationData();
|
||||
void onEditCodificationData();
|
||||
void onRemoveCodificationData();
|
||||
void onPrint();
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
private:
|
||||
QString m_menuGroup;
|
||||
LtsSession::LtsSession* m_session;
|
||||
CodificationDataOverviewModel* m_model;
|
||||
CodificationDataOverviewProxyModel* m_proxyModel;
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
|
||||
LtsUtils::RequestHelper* m_requestHelper;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void onSelectionChanged();
|
||||
void onShowCodificationData();
|
||||
void onAddCodificationData();
|
||||
void onEditCodificationData();
|
||||
void onRemoveCodificationData();
|
||||
void onPrint();
|
||||
void tableColumnOrganiserSetting() override;
|
||||
|
||||
private:
|
||||
QString m_menuGroup;
|
||||
LtsSession::LtsSession *m_session;
|
||||
CodificationDataOverviewModel *m_model;
|
||||
CodificationDataOverviewProxyModel *m_proxyModel;
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
|
||||
LtsUtils::RequestHelper *m_requestHelper;
|
||||
|
||||
Ui::CodificationDataOverviewView *m_ui;
|
||||
Ui::CodificationDataOverviewView* m_ui;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+314
-348
@@ -1,497 +1,463 @@
|
||||
|
||||
|
||||
|
||||
#include "cod_codification_data_table_edit_view.h"
|
||||
#include "cod_codification_data_report.h"
|
||||
#include "ui_cod_codification_data_table_view.h"
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include "cod_numeral_code_model.h"
|
||||
|
||||
#include "cod_authentication_code_model.h"
|
||||
#include "cod_logistical_terms_model.h"
|
||||
#include "cod_phrase_table_model.h"
|
||||
#include "cod_code_table_edit_delegate.h"
|
||||
#include "cod_codification_data_report.h"
|
||||
#include "cod_csv_export.h"
|
||||
#include "cod_csv_import.h"
|
||||
#include "cod_logistical_terms_model.h"
|
||||
#include "cod_numeral_code_model.h"
|
||||
#include "cod_phrase_table_model.h"
|
||||
#include "ui_cod_codification_data_table_view.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
#include <QBuffer>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
CodificationDataTableEditView::CodificationDataTableEditView(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::CodificationDataTableView)
|
||||
, m_numCodeModel(new NumeralCodeModel(this))
|
||||
, m_authenticationCodeModel(new AuthenticationCodeModel(this))
|
||||
, m_logisticalTermsModel(new LogisticalTermsModel(this))
|
||||
, m_phraseTableModel(new PhraseTableModel(this))
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
CodificationDataTableEditView::CodificationDataTableEditView(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel),
|
||||
m_ui(new Ui::CodificationDataTableView), m_numCodeModel(new NumeralCodeModel(this)),
|
||||
m_authenticationCodeModel(new AuthenticationCodeModel(this)),
|
||||
m_logisticalTermsModel(new LogisticalTermsModel(this)), m_phraseTableModel(new PhraseTableModel(this)),
|
||||
m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CodificationDataTableEditView::onPrint);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Add_Codification_Data"));
|
||||
|
||||
}
|
||||
m_ui->setupUi(this);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CodificationDataTableEditView::onPrint);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Add_Codification_Data"));
|
||||
}
|
||||
|
||||
CodificationDataTableEditView::~CodificationDataTableEditView()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void CodificationDataTableEditView::retranslate()
|
||||
{
|
||||
translate(m_ui, m_dtc->codificationData(m_codificationDataId), tr("Codification Data"));
|
||||
}
|
||||
translate(m_ui, m_dtc->codificationData(m_codificationDataId), tr("Codification Data"));
|
||||
}
|
||||
|
||||
|
||||
bool CodificationDataTableEditView::init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc> &ftc,
|
||||
LtsSession::LtsSession *session,
|
||||
int codificationDataId)
|
||||
bool CodificationDataTableEditView::init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc>& ftc,
|
||||
LtsSession::LtsSession* session, int codificationDataId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::init() codificationDataId: " << codificationDataId;
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::init() codificationDataId: " << codificationDataId;
|
||||
|
||||
if (!dtc || !ftc || !session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "CodificationDataTableEditView::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
if (!dtc || !ftc || !session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "CodificationDataTableEditView::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_session = session;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_session = session;
|
||||
m_codificationDataId = codificationDataId;
|
||||
|
||||
m_uiRequirements->addRequirement({ m_ui->lbIdentifier, [this]() { return (!m_ui->leIdentifier->text().isEmpty()); } });
|
||||
std::function<bool()> cbIsTimeValid = [this]()-> bool
|
||||
{
|
||||
if (m_ui->dteValidityTime->isEmpty())
|
||||
return true;
|
||||
return m_ui->dteValidityTime->msecsSinceEpoch() >= m_session->partitionTime();
|
||||
};
|
||||
m_uiRequirements->addRequirement({ m_ui->lbDteValidityTime, cbIsTimeValid });
|
||||
m_uiRequirements->addRequirement(
|
||||
{m_ui->lbIdentifier, [this]() { return (!m_ui->leIdentifier->text().isEmpty()); }});
|
||||
std::function<bool()> cbIsTimeValid = [this]() -> bool {
|
||||
if (m_ui->dteValidityTime->isEmpty())
|
||||
return true;
|
||||
return m_ui->dteValidityTime->msecsSinceEpoch() >= m_session->partitionTime();
|
||||
};
|
||||
m_uiRequirements->addRequirement({m_ui->lbDteValidityTime, cbIsTimeValid});
|
||||
|
||||
loadCodificationDataFromDatabase();
|
||||
loadCodificationDataFromDatabase();
|
||||
|
||||
initNumeralModel();
|
||||
initAuthenticationModel();
|
||||
initLogisticalTermsModel();
|
||||
initPhraseTableModel();
|
||||
initNumeralModel();
|
||||
initAuthenticationModel();
|
||||
initLogisticalTermsModel();
|
||||
initPhraseTableModel();
|
||||
|
||||
|
||||
m_ui->pteNote->setPlainText(QString::fromStdString(m_lastDdsCodificationData.note()));
|
||||
m_ui->pteNote->setPlainText(QString::fromStdString(m_lastDdsCodificationData.note()));
|
||||
|
||||
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(m_lastDdsCodificationData.identifier()));
|
||||
m_ui->dteValidityTime->setMsecsSinceEpoch(m_lastDdsCodificationData.validityTime());
|
||||
m_ui->dteValidityTime->setRetrieveCurrentTimeCallback([this]() { return m_session->partitionTime(); });
|
||||
m_ui->leIdentifier->setText(QString::fromStdString(m_lastDdsCodificationData.identifier()));
|
||||
m_ui->dteValidityTime->setMsecsSinceEpoch(m_lastDdsCodificationData.validityTime());
|
||||
m_ui->dteValidityTime->setRetrieveCurrentTimeCallback([this]() { return m_session->partitionTime(); });
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Load, this, &CodificationDataTableEditView::onLoadCodificationData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, true);
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Load, tr("CSV Import"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Load, this,
|
||||
&CodificationDataTableEditView::onLoadCodificationData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Load, true);
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Load, tr("CSV Import"));
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this, &CodificationDataTableEditView::onSaveCodificationData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, true);
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Save, tr("CSV Export"));
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Save, this,
|
||||
&CodificationDataTableEditView::onSaveCodificationData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Save, true);
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Save, tr("CSV Export"));
|
||||
|
||||
if (m_codificationDataId < 1)
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Ok, tr("Add"));
|
||||
m_ui->dteValidityTime->setMinimumTimeMSec(m_session->partitionTime());
|
||||
}
|
||||
if (m_codificationDataId < 1)
|
||||
{
|
||||
m_buttonBox->setText(LtsWidgets::DialogButton::Ok, tr("Add"));
|
||||
m_ui->dteValidityTime->setMinimumTimeMSec(m_session->partitionTime());
|
||||
}
|
||||
|
||||
|
||||
connect(m_numCodeModel, &NumeralCodeModel::dataModified, this, &CodificationDataTableEditView::onDataModified);
|
||||
connect(m_authenticationCodeModel, &AuthenticationCodeModel::dataModified, this, &CodificationDataTableEditView::onDataModified);
|
||||
connect(m_logisticalTermsModel, &LogisticalTermsModel::dataModified, this, &CodificationDataTableEditView::onDataModified);
|
||||
connect(m_phraseTableModel, &PhraseTableModel::dataModified, this, &CodificationDataTableEditView::onDataModified);
|
||||
connect(m_ui->pteNote, &QPlainTextEdit::textChanged, this, &CodificationDataTableEditView::onDataModified);
|
||||
connect(m_numCodeModel, &NumeralCodeModel::dataModified, this, &CodificationDataTableEditView::onDataModified);
|
||||
connect(m_authenticationCodeModel, &AuthenticationCodeModel::dataModified, this,
|
||||
&CodificationDataTableEditView::onDataModified);
|
||||
connect(m_logisticalTermsModel, &LogisticalTermsModel::dataModified, this,
|
||||
&CodificationDataTableEditView::onDataModified);
|
||||
connect(m_phraseTableModel, &PhraseTableModel::dataModified, this, &CodificationDataTableEditView::onDataModified);
|
||||
connect(m_ui->pteNote, &QPlainTextEdit::textChanged, this, &CodificationDataTableEditView::onDataModified);
|
||||
|
||||
|
||||
m_buttonBox->connectLibraryButton(this,
|
||||
&CodificationDataTableEditView::onImportButtonClicked,
|
||||
&CodificationDataTableEditView::onExportButtonClicked);
|
||||
m_buttonBox->connectLibraryButton(this, &CodificationDataTableEditView::onImportButtonClicked,
|
||||
&CodificationDataTableEditView::onExportButtonClicked);
|
||||
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
if (!m_session->getForeignGuiInterface<FileManagement::ForeignGuiInterface>(m_flmGui))
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Library, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CodificationDataTableEditView::onLoadCodificationData()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::onLoadCodificationData()";
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::onLoadCodificationData()";
|
||||
|
||||
QString note;
|
||||
CSVImport csvImport(m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel,
|
||||
m_phraseTableModel, ¬e, this);
|
||||
QString note;
|
||||
CSVImport csvImport(m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel, m_phraseTableModel, ¬e,
|
||||
this);
|
||||
|
||||
CSVImport::CSVImportResult result = csvImport.loadCSVData();
|
||||
CSVImport::CSVImportResult result = csvImport.loadCSVData();
|
||||
|
||||
if (result == CSVImport::LoadOk)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Load CSV data ok!";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load CSV data ok. The loaded data must be taken over with the 'Apply' or 'Add' button."), tr("CSV Import Info"));
|
||||
m_ui->pteNote->setPlainText(note);
|
||||
if (result == CSVImport::LoadOk)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Load CSV data ok!";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(
|
||||
this, tr("Load CSV data ok. The loaded data must be taken over with the 'Apply' or 'Add' button."),
|
||||
tr("CSV Import Info"));
|
||||
m_ui->pteNote->setPlainText(note);
|
||||
|
||||
|
||||
onDataModified();
|
||||
return;
|
||||
}
|
||||
onDataModified();
|
||||
return;
|
||||
}
|
||||
|
||||
if (result == CSVImport::LoadFailed)
|
||||
{
|
||||
m_numCodeModel->resetHeader();
|
||||
m_authenticationCodeModel->resetMatrix();
|
||||
m_logisticalTermsModel->resetHeader();
|
||||
m_logisticalTermsModel->resetMatrix();
|
||||
m_phraseTableModel->resetMatrix();
|
||||
m_ui->pteNote->clear();
|
||||
if (result == CSVImport::LoadFailed)
|
||||
{
|
||||
m_numCodeModel->resetHeader();
|
||||
m_authenticationCodeModel->resetMatrix();
|
||||
m_logisticalTermsModel->resetHeader();
|
||||
m_logisticalTermsModel->resetMatrix();
|
||||
m_phraseTableModel->resetMatrix();
|
||||
m_ui->pteNote->clear();
|
||||
|
||||
ERROR_LOG(m_logger) << "Load CSV data failed!";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load CSV data failed!"), tr("CSV Import Info"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result == CSVImport::UserAbort)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Load CSV data abort by user";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load CSV data abort by user"), tr("CSV Import Info"));
|
||||
}
|
||||
}
|
||||
ERROR_LOG(m_logger) << "Load CSV data failed!";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load CSV data failed!"), tr("CSV Import Info"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (result == CSVImport::UserAbort)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Load CSV data abort by user";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load CSV data abort by user"), tr("CSV Import Info"));
|
||||
}
|
||||
}
|
||||
|
||||
void CodificationDataTableEditView::onSaveCodificationData()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::onSaveCodificationData()";
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::onSaveCodificationData()";
|
||||
|
||||
CSVExport csvExport(m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel,
|
||||
m_phraseTableModel, m_ui->pteNote->toPlainText(), this);
|
||||
|
||||
if (!csvExport.writeCSVData())
|
||||
ERROR_LOG(m_logger) << "Write CSV data to file failed! id:" << m_codificationDataId;
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "Write CSV data to file ok! id:" << m_codificationDataId;
|
||||
}
|
||||
CSVExport csvExport(m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel, m_phraseTableModel,
|
||||
m_ui->pteNote->toPlainText(), this);
|
||||
|
||||
if (!csvExport.writeCSVData())
|
||||
ERROR_LOG(m_logger) << "Write CSV data to file failed! id:" << m_codificationDataId;
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "Write CSV data to file ok! id:" << m_codificationDataId;
|
||||
}
|
||||
|
||||
void CodificationDataTableEditView::loadCodificationDataFromDatabase()
|
||||
{
|
||||
m_lastDdsCodificationData = m_dtc->codificationData(m_codificationDataId);
|
||||
DEBUG_LOG(m_logger) << "Load from database: ---";
|
||||
DEBUG_LOG(m_logger) << "NumCodeHorizontalHeader: " << m_lastDdsCodificationData.numeralCodeTableColumnIndex();
|
||||
DEBUG_LOG(m_logger) << "NumCodeVerticalHeader: " << m_lastDdsCodificationData.numeralCodeTableRowIndex();
|
||||
m_lastDdsCodificationData = m_dtc->codificationData(m_codificationDataId);
|
||||
DEBUG_LOG(m_logger) << "Load from database: ---";
|
||||
DEBUG_LOG(m_logger) << "NumCodeHorizontalHeader: " << m_lastDdsCodificationData.numeralCodeTableColumnIndex();
|
||||
DEBUG_LOG(m_logger) << "NumCodeVerticalHeader: " << m_lastDdsCodificationData.numeralCodeTableRowIndex();
|
||||
|
||||
DEBUG_LOG(m_logger) << "AuthenticationMatrix: " << m_lastDdsCodificationData.authenticationTableMatirx();
|
||||
DEBUG_LOG(m_logger) << "AuthenticationMatrix: " << m_lastDdsCodificationData.authenticationTableMatirx();
|
||||
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsHorizontalHeader: " << m_lastDdsCodificationData.logisticalTermTableColumnIndex();
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsVerticalHeader: " << m_lastDdsCodificationData.logisticalTermTableRowIndex();
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsMatrix :" << m_lastDdsCodificationData.logisticalTermTableMatrix();
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsHorizontalHeader: "
|
||||
<< m_lastDdsCodificationData.logisticalTermTableColumnIndex();
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsVerticalHeader: " << m_lastDdsCodificationData.logisticalTermTableRowIndex();
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsMatrix :" << m_lastDdsCodificationData.logisticalTermTableMatrix();
|
||||
|
||||
DEBUG_LOG(m_logger) << "PhraseTable :" << m_lastDdsCodificationData.phraseTable();
|
||||
DEBUG_LOG(m_logger) << "PhraseTable :" << m_lastDdsCodificationData.phraseTable();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Note: " << m_lastDdsCodificationData.note();
|
||||
|
||||
return;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Note: " << m_lastDdsCodificationData.note();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool CodificationDataTableEditView::initNumeralModel()
|
||||
{
|
||||
if (!m_numCodeModel->init(m_dtc, m_codificationDataId, true))
|
||||
return false;
|
||||
if (!m_numCodeModel->init(m_dtc, m_codificationDataId, true))
|
||||
return false;
|
||||
|
||||
m_ui->tvNumeralCode->setModel(m_numCodeModel);
|
||||
m_ui->tvNumeralCode->setItemDelegate(new CodeTableEditDelegate(this, CodeTableEditDelegate::NumeralCode));
|
||||
m_ui->tvNumeralCode->setModel(m_numCodeModel);
|
||||
m_ui->tvNumeralCode->setItemDelegate(new CodeTableEditDelegate(this, CodeTableEditDelegate::NumeralCode));
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rect = fm.boundingRect(QLatin1String("W"));
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rect = fm.boundingRect(QLatin1String("W"));
|
||||
|
||||
QHeaderView *header = m_ui->tvNumeralCode->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
header->resizeSection(0, rect.width() * 1.3);
|
||||
|
||||
for (int i = 1; i <= 13; ++i)
|
||||
header->resizeSection(i, rect.width() * 1.5);
|
||||
QHeaderView* header = m_ui->tvNumeralCode->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvNumeralCode->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
header->resizeSection(0, rect.width() * 1.3);
|
||||
|
||||
vheader->resizeSection(0, rect.height() * 1.3);
|
||||
for (int i = 1; i <= 13; ++i)
|
||||
vheader->resizeSection(i, rect.height() * 1.5);
|
||||
for (int i = 1; i <= 13; ++i)
|
||||
header->resizeSection(i, rect.width() * 1.5);
|
||||
|
||||
m_ui->tvNumeralCode->setShowGrid(true);
|
||||
m_ui->tvNumeralCode->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
QHeaderView* vheader = m_ui->tvNumeralCode->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
|
||||
header->setVisible(false);
|
||||
vheader->setVisible(false);
|
||||
m_ui->tvNumeralCode->setColumnHidden(0, false);
|
||||
m_ui->tvNumeralCode->setRowHidden(0, false);
|
||||
vheader->resizeSection(0, rect.height() * 1.3);
|
||||
for (int i = 1; i <= 13; ++i)
|
||||
vheader->resizeSection(i, rect.height() * 1.5);
|
||||
|
||||
m_ui->tvNumeralCode->setMinimumWidth((rect.width() * 1.5 * 13) + rect.width() * 1.3 + 10);
|
||||
m_ui->tvNumeralCode->setMinimumHeight((rect.height() * 1.5 * 13) + rect.height() * 1.3 + 10);
|
||||
m_ui->tvNumeralCode->setShowGrid(true);
|
||||
m_ui->tvNumeralCode->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
QString qs = QString::fromStdString(m_lastDdsCodificationData.numeralCodeTableColumnIndex());
|
||||
m_numCodeModel->setColumnSelectionValuesCSV(qs);
|
||||
header->setVisible(false);
|
||||
vheader->setVisible(false);
|
||||
m_ui->tvNumeralCode->setColumnHidden(0, false);
|
||||
m_ui->tvNumeralCode->setRowHidden(0, false);
|
||||
|
||||
qs = QString::fromStdString(m_lastDdsCodificationData.numeralCodeTableRowIndex());
|
||||
m_numCodeModel->setRowSelectionValuesCSV(qs);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
m_ui->tvNumeralCode->setMinimumWidth((rect.width() * 1.5 * 13) + rect.width() * 1.3 + 10);
|
||||
m_ui->tvNumeralCode->setMinimumHeight((rect.height() * 1.5 * 13) + rect.height() * 1.3 + 10);
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
QString qs = QString::fromStdString(m_lastDdsCodificationData.numeralCodeTableColumnIndex());
|
||||
m_numCodeModel->setColumnSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(m_lastDdsCodificationData.numeralCodeTableRowIndex());
|
||||
m_numCodeModel->setRowSelectionValuesCSV(qs);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CodificationDataTableEditView::initAuthenticationModel()
|
||||
{
|
||||
if (!m_authenticationCodeModel->init(m_dtc, m_codificationDataId, true))
|
||||
return false;
|
||||
if (!m_authenticationCodeModel->init(m_dtc, m_codificationDataId, true))
|
||||
return false;
|
||||
|
||||
m_ui->tvAuthenticationTable->setModel(m_authenticationCodeModel);
|
||||
m_ui->tvAuthenticationTable->setItemDelegate(new CodeTableEditDelegate(this, CodeTableEditDelegate::AuthenticationCode));
|
||||
m_ui->tvAuthenticationTable->setModel(m_authenticationCodeModel);
|
||||
m_ui->tvAuthenticationTable->setItemDelegate(
|
||||
new CodeTableEditDelegate(this, CodeTableEditDelegate::AuthenticationCode));
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectHeader = fm.boundingRect(QLatin1String("W"));
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WW"));
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectHeader = fm.boundingRect(QLatin1String("W"));
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WW"));
|
||||
|
||||
QHeaderView *header = m_ui->tvAuthenticationTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 2.1);
|
||||
QHeaderView* header = m_ui->tvAuthenticationTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvAuthenticationTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
vheader->setMinimumWidth(rectHeader.width() * 1.3);
|
||||
|
||||
vheader->setDefaultSectionSize(rectMatrix.height() * 1.5);
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 2.1);
|
||||
|
||||
m_ui->tvAuthenticationTable->setShowGrid(true);
|
||||
m_ui->tvAuthenticationTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
QHeaderView* vheader = m_ui->tvAuthenticationTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
header->setVisible(true);
|
||||
vheader->setVisible(true);
|
||||
vheader->setMinimumWidth(rectHeader.width() * 1.3);
|
||||
|
||||
m_ui->tvAuthenticationTable->setMinimumWidth((rectMatrix.width() * 2.1 * 5) + rectHeader.width() * 1.3 + 5);
|
||||
m_ui->tvAuthenticationTable->setMinimumHeight((rectMatrix.height() * 1.5 * 13) + rectHeader.height() * 1.3);
|
||||
vheader->setDefaultSectionSize(rectMatrix.height() * 1.5);
|
||||
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
m_authenticationCodeModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.authenticationTableMatirx()));
|
||||
return true;
|
||||
}
|
||||
m_ui->tvAuthenticationTable->setShowGrid(true);
|
||||
m_ui->tvAuthenticationTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
header->setVisible(true);
|
||||
vheader->setVisible(true);
|
||||
|
||||
m_ui->tvAuthenticationTable->setMinimumWidth((rectMatrix.width() * 2.1 * 5) + rectHeader.width() * 1.3 + 5);
|
||||
m_ui->tvAuthenticationTable->setMinimumHeight((rectMatrix.height() * 1.5 * 13) + rectHeader.height() * 1.3);
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
m_authenticationCodeModel->setMatrixValuesCSV(
|
||||
QString::fromStdString(m_lastDdsCodificationData.authenticationTableMatirx()));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CodificationDataTableEditView::initLogisticalTermsModel()
|
||||
{
|
||||
if (!m_logisticalTermsModel->init(m_dtc, m_codificationDataId, true))
|
||||
return false;
|
||||
if (!m_logisticalTermsModel->init(m_dtc, m_codificationDataId, true))
|
||||
return false;
|
||||
|
||||
m_ui->tvLogisticalTermsTable->setModel(m_logisticalTermsModel);
|
||||
m_ui->tvLogisticalTermsTable->setItemDelegate(new CodeTableEditDelegate(this, CodeTableEditDelegate::LogisticalTerms));
|
||||
m_ui->tvLogisticalTermsTable->setModel(m_logisticalTermsModel);
|
||||
m_ui->tvLogisticalTermsTable->setItemDelegate(
|
||||
new CodeTableEditDelegate(this, CodeTableEditDelegate::LogisticalTerms));
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectHeader = fm.boundingRect(QLatin1String("W"));
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WWWWWWWWWW"));
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectHeader = fm.boundingRect(QLatin1String("W"));
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WWWWWWWWWW"));
|
||||
|
||||
QHeaderView *header = m_ui->tvLogisticalTermsTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
header->resizeSection(0, rectHeader.width() * 1.3);
|
||||
|
||||
for (int i = 1; i <= 5; ++i)
|
||||
header->resizeSection(i, rectMatrix.width() * 1.08);
|
||||
QHeaderView* header = m_ui->tvLogisticalTermsTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvLogisticalTermsTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
header->resizeSection(0, rectHeader.width() * 1.3);
|
||||
|
||||
|
||||
vheader->resizeSection(0, rectHeader.height() * 1.3);
|
||||
for (int i = 1; i <= 5; ++i)
|
||||
vheader->resizeSection(i, rectMatrix.height() * 2.3);
|
||||
for (int i = 1; i <= 5; ++i)
|
||||
header->resizeSection(i, rectMatrix.width() * 1.08);
|
||||
|
||||
m_ui->tvLogisticalTermsTable->setShowGrid(true);
|
||||
m_ui->tvLogisticalTermsTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
QHeaderView* vheader = m_ui->tvLogisticalTermsTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
|
||||
header->setVisible(false);
|
||||
vheader->setVisible(false);
|
||||
m_ui->tvLogisticalTermsTable->setColumnHidden(0, false);
|
||||
m_ui->tvLogisticalTermsTable->setRowHidden(0, false);
|
||||
vheader->resizeSection(0, rectHeader.height() * 1.3);
|
||||
for (int i = 1; i <= 5; ++i)
|
||||
vheader->resizeSection(i, rectMatrix.height() * 2.3);
|
||||
|
||||
m_ui->tvLogisticalTermsTable->setMinimumWidth((rectMatrix.width() * 1.08 * 5) + rectHeader.width() * 1.3 + 5);
|
||||
m_ui->tvLogisticalTermsTable->setMinimumHeight((rectMatrix.height() * 2.3 * 5) + rectHeader.height() * 1.3);
|
||||
m_ui->tvLogisticalTermsTable->setShowGrid(true);
|
||||
m_ui->tvLogisticalTermsTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
QString qs = QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableColumnIndex());
|
||||
m_logisticalTermsModel->setColumnSelectionValuesCSV(qs);
|
||||
header->setVisible(false);
|
||||
vheader->setVisible(false);
|
||||
m_ui->tvLogisticalTermsTable->setColumnHidden(0, false);
|
||||
m_ui->tvLogisticalTermsTable->setRowHidden(0, false);
|
||||
|
||||
qs = QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableRowIndex());
|
||||
m_logisticalTermsModel->setRowSelectionValuesCSV(qs);
|
||||
m_ui->tvLogisticalTermsTable->setMinimumWidth((rectMatrix.width() * 1.08 * 5) + rectHeader.width() * 1.3 + 5);
|
||||
m_ui->tvLogisticalTermsTable->setMinimumHeight((rectMatrix.height() * 2.3 * 5) + rectHeader.height() * 1.3);
|
||||
|
||||
|
||||
m_logisticalTermsModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableMatrix()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
QString qs = QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableColumnIndex());
|
||||
m_logisticalTermsModel->setColumnSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableRowIndex());
|
||||
m_logisticalTermsModel->setRowSelectionValuesCSV(qs);
|
||||
|
||||
m_logisticalTermsModel->setMatrixValuesCSV(
|
||||
QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableMatrix()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CodificationDataTableEditView::initPhraseTableModel()
|
||||
{
|
||||
if (!m_phraseTableModel->init(m_dtc, m_codificationDataId, true))
|
||||
return false;
|
||||
if (!m_phraseTableModel->init(m_dtc, m_codificationDataId, true))
|
||||
return false;
|
||||
|
||||
m_ui->tvPhraseTable->setModel(m_phraseTableModel);
|
||||
m_ui->tvPhraseTable->setItemDelegate(new CodeTableEditDelegate(this, CodeTableEditDelegate::PhraseTable));
|
||||
m_ui->tvPhraseTable->setModel(m_phraseTableModel);
|
||||
m_ui->tvPhraseTable->setItemDelegate(new CodeTableEditDelegate(this, CodeTableEditDelegate::PhraseTable));
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WWWWWWWWWWWWWWW"));
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WWWWWWWWWWWWWWW"));
|
||||
|
||||
QHeaderView *header = m_ui->tvPhraseTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 1.08);
|
||||
QHeaderView* header = m_ui->tvPhraseTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 1.08);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvPhraseTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
vheader->setDefaultSectionSize(rectMatrix.height() * 1.3);
|
||||
QHeaderView* vheader = m_ui->tvPhraseTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
vheader->setDefaultSectionSize(rectMatrix.height() * 1.3);
|
||||
|
||||
m_ui->tvPhraseTable->setShowGrid(true);
|
||||
m_ui->tvPhraseTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_ui->tvPhraseTable->setShowGrid(true);
|
||||
m_ui->tvPhraseTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
|
||||
header->setVisible(false);
|
||||
vheader->setVisible(false);
|
||||
header->setVisible(false);
|
||||
vheader->setVisible(false);
|
||||
|
||||
m_ui->tvPhraseTable->setMinimumWidth((rectMatrix.width() * 1.08 * 2) + 5);
|
||||
m_ui->tvPhraseTable->setMinimumHeight((rectMatrix.height() * 1.3 * 13));
|
||||
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
m_phraseTableModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.phraseTable()));
|
||||
return true;
|
||||
}
|
||||
m_ui->tvPhraseTable->setMinimumWidth((rectMatrix.width() * 1.08 * 2) + 5);
|
||||
m_ui->tvPhraseTable->setMinimumHeight((rectMatrix.height() * 1.3 * 13));
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
m_phraseTableModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.phraseTable()));
|
||||
return true;
|
||||
}
|
||||
|
||||
void CodificationDataTableEditView::onDataModified()
|
||||
{
|
||||
slotChangesMade();
|
||||
}
|
||||
|
||||
slotChangesMade();
|
||||
}
|
||||
|
||||
void CodificationDataTableEditView::onPrint()
|
||||
{
|
||||
CodificationDataReport report(this, m_session, m_ui, m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel, m_phraseTableModel);
|
||||
report.print(false);
|
||||
}
|
||||
|
||||
CodificationDataReport report(this, m_session, m_ui, m_numCodeModel, m_authenticationCodeModel,
|
||||
m_logisticalTermsModel, m_phraseTableModel);
|
||||
report.print(false);
|
||||
}
|
||||
|
||||
bool CodificationDataTableEditView::apply()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::onOkayCodificationData()";
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::onOkayCodificationData()";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CodificationManagement::CodificationData modifiedCodificationData(m_lastDdsCodificationData);
|
||||
|
||||
CodificationManagement::CodificationData modifiedCodificationData(m_lastDdsCodificationData);
|
||||
modifiedCodificationData.name(m_ui->leIdentifier->text().toStdString());
|
||||
|
||||
|
||||
modifiedCodificationData.name(m_ui->leIdentifier->text().toStdString());
|
||||
modifiedCodificationData.numeralCodeTableColumnIndex(m_numCodeModel->getHorizontalHeaderCSVString().toStdString());
|
||||
modifiedCodificationData.numeralCodeTableRowIndex(m_numCodeModel->getVerticalHeaderCSVString().toStdString());
|
||||
|
||||
|
||||
modifiedCodificationData.numeralCodeTableColumnIndex(m_numCodeModel->getHorizontalHeaderCSVString().toStdString());
|
||||
modifiedCodificationData.numeralCodeTableRowIndex(m_numCodeModel->getVerticalHeaderCSVString().toStdString()) ;
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() HH: " << m_numCodeModel->getHorizontalHeaderCSVString();
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() VH: " << m_numCodeModel->getVerticalHeaderCSVString();
|
||||
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() HH: " << m_numCodeModel->getHorizontalHeaderCSVString();
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() VH: " << m_numCodeModel->getVerticalHeaderCSVString();
|
||||
modifiedCodificationData.authenticationTableMatirx(
|
||||
m_authenticationCodeModel->getMatrixDataCSVString().toStdString());
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() authMatrix: "
|
||||
<< m_authenticationCodeModel->getMatrixDataCSVString();
|
||||
|
||||
|
||||
modifiedCodificationData.authenticationTableMatirx(m_authenticationCodeModel->getMatrixDataCSVString().toStdString());
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() authMatrix: " << m_authenticationCodeModel->getMatrixDataCSVString();
|
||||
modifiedCodificationData.logisticalTermTableColumnIndex(
|
||||
m_logisticalTermsModel->getHorizontalHeaderCSVString().toStdString());
|
||||
modifiedCodificationData.logisticalTermTableRowIndex(
|
||||
m_logisticalTermsModel->getVerticalHeaderCSVString().toStdString());
|
||||
modifiedCodificationData.logisticalTermTableMatrix(m_logisticalTermsModel->getMatrixDataCSVString().toStdString());
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() HH: " << m_logisticalTermsModel->getHorizontalHeaderCSVString();
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() VH: " << m_logisticalTermsModel->getVerticalHeaderCSVString();
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() logTermsMatrix: "
|
||||
<< m_logisticalTermsModel->getMatrixDataCSVString();
|
||||
|
||||
|
||||
modifiedCodificationData.logisticalTermTableColumnIndex(m_logisticalTermsModel->getHorizontalHeaderCSVString().toStdString());
|
||||
modifiedCodificationData.logisticalTermTableRowIndex(m_logisticalTermsModel->getVerticalHeaderCSVString().toStdString());
|
||||
modifiedCodificationData.logisticalTermTableMatrix(m_logisticalTermsModel->getMatrixDataCSVString().toStdString());
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() HH: " << m_logisticalTermsModel->getHorizontalHeaderCSVString();
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() VH: " << m_logisticalTermsModel->getVerticalHeaderCSVString();
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() logTermsMatrix: " << m_logisticalTermsModel->getMatrixDataCSVString();
|
||||
modifiedCodificationData.phraseTable(m_phraseTableModel->getMatrixDataCSVString().toStdString());
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() phraseTable: " << m_phraseTableModel->getMatrixDataCSVString();
|
||||
|
||||
|
||||
modifiedCodificationData.phraseTable(m_phraseTableModel->getMatrixDataCSVString().toStdString());
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() phraseTable: " << m_phraseTableModel->getMatrixDataCSVString();
|
||||
modifiedCodificationData.note(m_ui->pteNote->toPlainText().toStdString());
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::onOkayCodificationData()";
|
||||
|
||||
|
||||
modifiedCodificationData.note(m_ui->pteNote->toPlainText().toStdString());
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::onOkayCodificationData()";
|
||||
modifiedCodificationData.identifier(m_ui->leIdentifier->text().toStdString());
|
||||
modifiedCodificationData.validityTime(m_ui->dteValidityTime->msecsSinceEpoch());
|
||||
|
||||
modifiedCodificationData.identifier(m_ui->leIdentifier->text().toStdString());
|
||||
modifiedCodificationData.validityTime(m_ui->dteValidityTime->msecsSinceEpoch());
|
||||
if (m_codificationDataId < 1)
|
||||
modifiedCodificationData.partyId(-1);
|
||||
|
||||
if (m_codificationDataId < 1)
|
||||
modifiedCodificationData.partyId(-1);
|
||||
|
||||
m_requestHelper->addRequest([this, modifiedCodificationData]()
|
||||
{
|
||||
return m_ftc->codificationDataModifyRequest(modifiedCodificationData, this);
|
||||
});
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
m_requestHelper->addRequest([this, modifiedCodificationData]() {
|
||||
return m_ftc->codificationDataModifyRequest(modifiedCodificationData, this);
|
||||
});
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
}
|
||||
|
||||
void CodificationDataTableEditView::onExportButtonClicked()
|
||||
{
|
||||
CSVExport csvExport(m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel,
|
||||
m_phraseTableModel, m_ui->pteNote->toPlainText(), this);
|
||||
CSVExport csvExport(m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel, m_phraseTableModel,
|
||||
m_ui->pteNote->toPlainText(), this);
|
||||
|
||||
const QByteArray byteArray = csvExport.exportToByteArray();
|
||||
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Text, 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 ";
|
||||
const QByteArray byteArray = csvExport.exportToByteArray();
|
||||
|
||||
int fileId = m_flmGui->saveFileContent(this, FileManagement::FileType::Text, 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 CodificationDataTableEditView::onImportButtonClicked()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
QString note;
|
||||
CSVImport csvImport(m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel,
|
||||
m_phraseTableModel, ¬e, this);
|
||||
DEBUG_LOG(m_logger) << " onImportButtonClicked() ";
|
||||
QString note;
|
||||
CSVImport csvImport(m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel, m_phraseTableModel, ¬e,
|
||||
this);
|
||||
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Text}, m_session->exerciseId());
|
||||
if (fileId > 0)
|
||||
{
|
||||
if (!content.isEmpty())
|
||||
QByteArray content;
|
||||
int fileId = m_flmGui->loadFileContent(this, content, {FileManagement::FileType::Text}, m_session->exerciseId());
|
||||
if (fileId > 0)
|
||||
{
|
||||
|
||||
if (!content.isEmpty())
|
||||
{
|
||||
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
csvImport.loadCSVDataByteArray(content);
|
||||
m_ui->pteNote->setPlainText(note);
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
csvImport.loadCSVDataByteArray(content);
|
||||
m_ui->pteNote->setPlainText(note);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+49
-66
@@ -1,16 +1,14 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <CodificationManagement/logger.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/CodificationManagement/cod_dtc.h>
|
||||
#include <Services/CodificationManagement/cod_ftc.h>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <LtsUtils/LtsUtilsGui/LtsUtilsGuiDds/request_helper.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
@@ -26,82 +24,67 @@ class LogisticalTermsModel;
|
||||
class PhraseTableModel;
|
||||
class CSVExport;
|
||||
|
||||
class CodificationDataTableEditView : public LtsWidgets::LtsDialog,
|
||||
protected CodificationManagement::Interface::Ftc::CodificationDataModifyReplyHandler
|
||||
class CodificationDataTableEditView
|
||||
: public LtsWidgets::LtsDialog,
|
||||
protected CodificationManagement::Interface::Ftc::CodificationDataModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CodificationDataTableEditView(QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit CodificationDataTableEditView(QWidget* parent = nullptr);
|
||||
|
||||
~CodificationDataTableEditView();
|
||||
~CodificationDataTableEditView();
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc> &ftc,
|
||||
LtsSession::LtsSession *session,
|
||||
int codificationDataId);
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc>& ftc, LtsSession::LtsSession* session,
|
||||
int codificationDataId);
|
||||
|
||||
void onCodificationDataModifyReply(const Core::FunctionReplyObject& replyObject) override
|
||||
{
|
||||
m_requestHelper->requestReply(replyObject);
|
||||
}
|
||||
|
||||
|
||||
void onCodificationDataModifyReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
|
||||
QByteArray exportToByteArray();
|
||||
QByteArray exportToByteArray();
|
||||
|
||||
private slots:
|
||||
|
||||
private slots:
|
||||
|
||||
void onDataModified();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
void onDataModified();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
|
||||
|
||||
bool apply() override;
|
||||
|
||||
bool apply() override;
|
||||
void onLoadCodificationData();
|
||||
void onSaveCodificationData();
|
||||
|
||||
void onLoadCodificationData();
|
||||
void onSaveCodificationData();
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void loadCodificationDataFromDatabase();
|
||||
|
||||
bool initNumeralModel();
|
||||
|
||||
private:
|
||||
bool initAuthenticationModel();
|
||||
|
||||
bool initLogisticalTermsModel();
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void loadCodificationDataFromDatabase();
|
||||
bool initPhraseTableModel();
|
||||
|
||||
|
||||
private:
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
LtsSession::LtsSession* m_session{nullptr};
|
||||
int m_codificationDataId{0};
|
||||
|
||||
bool initNumeralModel();
|
||||
|
||||
|
||||
|
||||
bool initAuthenticationModel();
|
||||
|
||||
|
||||
|
||||
bool initLogisticalTermsModel();
|
||||
|
||||
|
||||
|
||||
bool initPhraseTableModel();
|
||||
|
||||
private:
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<FileManagement::ForeignGuiInterface> m_flmGui;
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
int m_codificationDataId{0};
|
||||
|
||||
Ui::CodificationDataTableView *m_ui{nullptr};
|
||||
NumeralCodeModel *m_numCodeModel{nullptr};
|
||||
AuthenticationCodeModel *m_authenticationCodeModel{nullptr};
|
||||
LogisticalTermsModel *m_logisticalTermsModel{nullptr};
|
||||
PhraseTableModel *m_phraseTableModel{nullptr};
|
||||
LtsUtils::RequestHelper *m_requestHelper{nullptr};
|
||||
CodificationManagement::CodificationData m_lastDdsCodificationData;
|
||||
Ui::CodificationDataTableView* m_ui{nullptr};
|
||||
NumeralCodeModel* m_numCodeModel{nullptr};
|
||||
AuthenticationCodeModel* m_authenticationCodeModel{nullptr};
|
||||
LogisticalTermsModel* m_logisticalTermsModel{nullptr};
|
||||
PhraseTableModel* m_phraseTableModel{nullptr};
|
||||
LtsUtils::RequestHelper* m_requestHelper{nullptr};
|
||||
CodificationManagement::CodificationData m_lastDdsCodificationData;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+239
-271
@@ -1,339 +1,307 @@
|
||||
|
||||
|
||||
|
||||
#include "cod_codification_data_table_view.h"
|
||||
#include "ui_cod_codification_data_table_view.h"
|
||||
#include "cod_numeral_code_model.h"
|
||||
|
||||
#include "cod_authentication_code_model.h"
|
||||
#include "cod_logistical_terms_model.h"
|
||||
#include "cod_phrase_table_model.h"
|
||||
#include "cod_codification_data_report.h"
|
||||
#include "cod_logistical_terms_model.h"
|
||||
#include "cod_numeral_code_model.h"
|
||||
#include "cod_phrase_table_model.h"
|
||||
#include "ui_cod_codification_data_table_view.h"
|
||||
|
||||
#include <LtsWidgets/lts_base_layout_widget.h>
|
||||
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
CodificationDataTableView::CodificationDataTableView(QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_ui(new Ui::CodificationDataTableView)
|
||||
, m_numCodeModel(new NumeralCodeModel(this))
|
||||
, m_authenticationCodeModel(new AuthenticationCodeModel(this))
|
||||
, m_logisticalTermsModel(new LogisticalTermsModel(this))
|
||||
, m_phraseTableModel(new PhraseTableModel(this))
|
||||
CodificationDataTableView::CodificationDataTableView(QWidget* parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly), m_ui(new Ui::CodificationDataTableView),
|
||||
m_numCodeModel(new NumeralCodeModel(this)), m_authenticationCodeModel(new AuthenticationCodeModel(this)),
|
||||
m_logisticalTermsModel(new LogisticalTermsModel(this)), m_phraseTableModel(new PhraseTableModel(this))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CodificationDataTableView::onPrint);
|
||||
|
||||
}
|
||||
|
||||
m_ui->setupUi(this);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CodificationDataTableView::onPrint);
|
||||
}
|
||||
|
||||
CodificationDataTableView::~CodificationDataTableView()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_numCodeModel;
|
||||
delete m_authenticationCodeModel;
|
||||
delete m_logisticalTermsModel;
|
||||
delete m_phraseTableModel;
|
||||
}
|
||||
|
||||
delete m_ui;
|
||||
delete m_numCodeModel;
|
||||
delete m_authenticationCodeModel;
|
||||
delete m_logisticalTermsModel;
|
||||
delete m_phraseTableModel;
|
||||
}
|
||||
|
||||
void CodificationDataTableView::retranslate()
|
||||
{
|
||||
|
||||
if (m_partyId == 2)
|
||||
translate(m_ui, tr("Codification Data Table OPFOR"));
|
||||
|
||||
if (m_partyId == 2)
|
||||
translate(m_ui, tr("Codification Data Table OPFOR"));
|
||||
if (m_partyId == 3)
|
||||
translate(m_ui, tr("Codification Data Table BLUFOR"));
|
||||
}
|
||||
|
||||
if (m_partyId == 3)
|
||||
translate(m_ui, tr("Codification Data Table BLUFOR"));
|
||||
}
|
||||
|
||||
|
||||
bool CodificationDataTableView::init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc> &ftc,
|
||||
LtsSession::LtsSession *session,
|
||||
int partyId,
|
||||
int codificationDataId)
|
||||
bool CodificationDataTableView::init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc>& ftc,
|
||||
LtsSession::LtsSession* session, int partyId, int codificationDataId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableView::init()";
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableView::init()";
|
||||
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_session = session;
|
||||
m_partyId = partyId;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
m_session = session;
|
||||
m_partyId = partyId;
|
||||
m_codificationDataId = codificationDataId;
|
||||
|
||||
if (!m_dtc || !m_ftc || !m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "CodificationDataTableView::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
if (!m_dtc || !m_ftc || !m_session)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "CodificationDataTableView::init() Invalid shared_ptr!";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (codificationDataId < 0)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Invalid codification Data Id. Probably the table is not assigned to any party."));
|
||||
ERROR_LOG(m_logger) << "CodificationDataTableView::init() Invalid codificationDataId: " << codificationDataId;
|
||||
return false;
|
||||
}
|
||||
if (codificationDataId < 0)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(
|
||||
this, tr("Invalid codification Data Id. Probably the table is not assigned to any party."));
|
||||
ERROR_LOG(m_logger) << "CodificationDataTableView::init() Invalid codificationDataId: " << codificationDataId;
|
||||
return false;
|
||||
}
|
||||
|
||||
loadCodificationDataFromDatabase();
|
||||
loadCodificationDataFromDatabase();
|
||||
|
||||
initNumeralModel();
|
||||
initAuthenticationModel();
|
||||
initLogicalTermsModel();
|
||||
initPhraseTableModel();
|
||||
initNumeralModel();
|
||||
initAuthenticationModel();
|
||||
initLogicalTermsModel();
|
||||
initPhraseTableModel();
|
||||
|
||||
m_ui->lbIdentifier->hide();
|
||||
m_ui->leIdentifier->hide();
|
||||
m_ui->lbDteValidityTime->hide();
|
||||
m_ui->dteValidityTime->hide();
|
||||
|
||||
m_ui->pteNote->setPlainText(QString::fromStdString(m_lastDdsCodificationData.note()));
|
||||
m_ui->pteNote->setReadOnly(true);
|
||||
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged, this,
|
||||
&CodificationDataTableView::onCodificationDataChanged);
|
||||
|
||||
|
||||
m_ui->lbIdentifier->hide();
|
||||
m_ui->leIdentifier->hide();
|
||||
m_ui->lbDteValidityTime->hide();
|
||||
m_ui->dteValidityTime->hide();
|
||||
if (m_partyId == 2)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Show_OPFOR_Codification_Data"));
|
||||
|
||||
|
||||
m_ui->pteNote->setPlainText(QString::fromStdString(m_lastDdsCodificationData.note()));
|
||||
m_ui->pteNote->setReadOnly(true);
|
||||
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged,
|
||||
this, &CodificationDataTableView::onCodificationDataChanged);
|
||||
|
||||
if (m_partyId == 2)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Show_OPFOR_Codification_Data"));
|
||||
|
||||
if (m_partyId == 3)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Show_BLUFOR_Codification_Data"));
|
||||
|
||||
return true;
|
||||
}
|
||||
if (m_partyId == 3)
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Show_BLUFOR_Codification_Data"));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CodificationDataTableView::loadCodificationDataFromDatabase()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableView::loadCodificationDataFromDatabase()";
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableView::loadCodificationDataFromDatabase()";
|
||||
|
||||
m_lastDdsCodificationData = m_dtc->codificationData(m_codificationDataId);
|
||||
DEBUG_LOG(m_logger) << "Load from database: ";
|
||||
DEBUG_LOG(m_logger) << "NumCodeHorizontalHeader: " << m_lastDdsCodificationData.numeralCodeTableColumnIndex();
|
||||
DEBUG_LOG(m_logger) << "NumCodeVerticalHeader: " << m_lastDdsCodificationData.numeralCodeTableRowIndex();
|
||||
m_lastDdsCodificationData = m_dtc->codificationData(m_codificationDataId);
|
||||
DEBUG_LOG(m_logger) << "Load from database: ";
|
||||
DEBUG_LOG(m_logger) << "NumCodeHorizontalHeader: " << m_lastDdsCodificationData.numeralCodeTableColumnIndex();
|
||||
DEBUG_LOG(m_logger) << "NumCodeVerticalHeader: " << m_lastDdsCodificationData.numeralCodeTableRowIndex();
|
||||
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsHorizontalHeader: " << m_lastDdsCodificationData.logisticalTermTableColumnIndex();
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsVerticalHeader: " << m_lastDdsCodificationData.logisticalTermTableRowIndex();
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsMatrix: " << m_lastDdsCodificationData.logisticalTermTableMatrix();
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsHorizontalHeader: "
|
||||
<< m_lastDdsCodificationData.logisticalTermTableColumnIndex();
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsVerticalHeader: " << m_lastDdsCodificationData.logisticalTermTableRowIndex();
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsMatrix: " << m_lastDdsCodificationData.logisticalTermTableMatrix();
|
||||
|
||||
DEBUG_LOG(m_logger) << "AuthenticationMatrix: " << m_lastDdsCodificationData.authenticationTableMatirx();
|
||||
DEBUG_LOG(m_logger) << "AuthenticationMatrix: " << m_lastDdsCodificationData.authenticationTableMatirx();
|
||||
|
||||
DEBUG_LOG(m_logger) << "PhraseTable: " << m_lastDdsCodificationData.phraseTable();
|
||||
DEBUG_LOG(m_logger) << "PhraseTable: " << m_lastDdsCodificationData.phraseTable();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Note: " << m_lastDdsCodificationData.note();
|
||||
|
||||
return;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Note: " << m_lastDdsCodificationData.note();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void CodificationDataTableView::onPrint()
|
||||
{
|
||||
CodificationDataReport report( this, m_session, m_ui, m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel, m_phraseTableModel );
|
||||
report.print(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
CodificationDataReport report(this, m_session, m_ui, m_numCodeModel, m_authenticationCodeModel,
|
||||
m_logisticalTermsModel, m_phraseTableModel);
|
||||
report.print(true);
|
||||
}
|
||||
|
||||
bool CodificationDataTableView::initNumeralModel()
|
||||
{
|
||||
bool bOk = false;
|
||||
bool bOk = false;
|
||||
|
||||
if (!m_numCodeModel->init(m_dtc, m_codificationDataId, false))
|
||||
if (!m_numCodeModel->init(m_dtc, m_codificationDataId, false))
|
||||
return bOk;
|
||||
|
||||
m_ui->tvNumeralCode->setModel(m_numCodeModel);
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rect = fm.boundingRect(QLatin1String("W"));
|
||||
|
||||
QHeaderView* header = m_ui->tvNumeralCode->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
header->setDefaultSectionSize(rect.width() * 1.5);
|
||||
|
||||
QHeaderView* vheader = m_ui->tvNumeralCode->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
vheader->setMinimumWidth(rect.width() * 1.3);
|
||||
|
||||
vheader->setDefaultSectionSize(rect.height() * 1.5);
|
||||
|
||||
m_ui->tvNumeralCode->setShowGrid(true);
|
||||
m_ui->tvNumeralCode->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
header->setVisible(true);
|
||||
vheader->setVisible(true);
|
||||
m_ui->tvNumeralCode->setColumnHidden(0, true);
|
||||
m_ui->tvNumeralCode->setRowHidden(0, true);
|
||||
|
||||
m_ui->tvNumeralCode->setMinimumWidth((rect.width() * 1.5 * 13) + rect.width() * 1.3 + 10);
|
||||
m_ui->tvNumeralCode->setMinimumHeight((rect.height() * 1.5 * 13) + rect.height() * 1.5 + 10);
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
QString qs = QString::fromStdString(m_lastDdsCodificationData.numeralCodeTableColumnIndex());
|
||||
m_numCodeModel->setColumnSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(m_lastDdsCodificationData.numeralCodeTableRowIndex());
|
||||
m_numCodeModel->setRowSelectionValuesCSV(qs);
|
||||
}
|
||||
return bOk;
|
||||
|
||||
m_ui->tvNumeralCode->setModel(m_numCodeModel);
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rect = fm.boundingRect(QLatin1String("W"));
|
||||
|
||||
QHeaderView *header = m_ui->tvNumeralCode->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
header->setDefaultSectionSize(rect.width() * 1.5);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvNumeralCode->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
vheader->setMinimumWidth(rect.width() * 1.3);
|
||||
|
||||
vheader->setDefaultSectionSize(rect.height() * 1.5);
|
||||
|
||||
m_ui->tvNumeralCode->setShowGrid(true);
|
||||
m_ui->tvNumeralCode->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
|
||||
header->setVisible(true);
|
||||
vheader->setVisible(true);
|
||||
m_ui->tvNumeralCode->setColumnHidden(0, true);
|
||||
m_ui->tvNumeralCode->setRowHidden(0, true);
|
||||
|
||||
m_ui->tvNumeralCode->setMinimumWidth((rect.width() * 1.5 * 13) + rect.width() * 1.3 + 10);
|
||||
m_ui->tvNumeralCode->setMinimumHeight((rect.height() * 1.5 * 13) + rect.height() * 1.5 + 10);
|
||||
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
QString qs = QString::fromStdString(m_lastDdsCodificationData.numeralCodeTableColumnIndex());
|
||||
m_numCodeModel->setColumnSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(m_lastDdsCodificationData.numeralCodeTableRowIndex());
|
||||
m_numCodeModel->setRowSelectionValuesCSV(qs);
|
||||
}
|
||||
return bOk;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CodificationDataTableView::initAuthenticationModel()
|
||||
{
|
||||
bool bOk = false;
|
||||
bool bOk = false;
|
||||
|
||||
if (!m_authenticationCodeModel->init(m_dtc, m_codificationDataId, false))
|
||||
if (!m_authenticationCodeModel->init(m_dtc, m_codificationDataId, false))
|
||||
return bOk;
|
||||
|
||||
m_ui->tvAuthenticationTable->setModel(m_authenticationCodeModel);
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectHeader = fm.boundingRect(QLatin1String("W"));
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WW"));
|
||||
|
||||
QHeaderView* header = m_ui->tvAuthenticationTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 2.1);
|
||||
|
||||
QHeaderView* vheader = m_ui->tvAuthenticationTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
vheader->setMinimumWidth(rectHeader.width() * 1.3);
|
||||
|
||||
vheader->setDefaultSectionSize(rectMatrix.height() * 1.5);
|
||||
|
||||
m_ui->tvAuthenticationTable->setShowGrid(true);
|
||||
m_ui->tvAuthenticationTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
header->setVisible(true);
|
||||
vheader->setVisible(true);
|
||||
|
||||
m_ui->tvAuthenticationTable->setMinimumWidth((rectMatrix.width() * 2.1 * 5) + rectHeader.width() * 1.3 + 5);
|
||||
m_ui->tvAuthenticationTable->setMinimumHeight((rectMatrix.height() * 1.5 * 13) + rectHeader.height() * 1.3);
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
m_authenticationCodeModel->setMatrixValuesCSV(
|
||||
QString::fromStdString(m_lastDdsCodificationData.authenticationTableMatirx()));
|
||||
}
|
||||
return bOk;
|
||||
|
||||
m_ui->tvAuthenticationTable->setModel(m_authenticationCodeModel);
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectHeader = fm.boundingRect(QLatin1String("W"));
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WW"));
|
||||
|
||||
QHeaderView *header = m_ui->tvAuthenticationTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 2.1);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvAuthenticationTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
vheader->setMinimumWidth(rectHeader.width() * 1.3);
|
||||
|
||||
vheader->setDefaultSectionSize(rectMatrix.height() * 1.5);
|
||||
|
||||
m_ui->tvAuthenticationTable->setShowGrid(true);
|
||||
m_ui->tvAuthenticationTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
header->setVisible(true);
|
||||
vheader->setVisible(true);
|
||||
|
||||
m_ui->tvAuthenticationTable->setMinimumWidth((rectMatrix.width() * 2.1 * 5) + rectHeader.width() * 1.3 + 5);
|
||||
m_ui->tvAuthenticationTable->setMinimumHeight((rectMatrix.height() * 1.5 * 13) + rectHeader.height() * 1.3);
|
||||
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
m_authenticationCodeModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.authenticationTableMatirx()));
|
||||
}
|
||||
return bOk;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CodificationDataTableView::initLogicalTermsModel()
|
||||
{
|
||||
bool bOk = false;
|
||||
bool bOk = false;
|
||||
|
||||
if (!m_logisticalTermsModel->init(m_dtc, m_codificationDataId, false))
|
||||
if (!m_logisticalTermsModel->init(m_dtc, m_codificationDataId, false))
|
||||
return bOk;
|
||||
|
||||
m_ui->tvLogisticalTermsTable->setModel(m_logisticalTermsModel);
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectHeader = fm.boundingRect(QLatin1String("W"));
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WWWWWWWWWW"));
|
||||
|
||||
QHeaderView* header = m_ui->tvLogisticalTermsTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 1.08);
|
||||
|
||||
QHeaderView* vheader = m_ui->tvLogisticalTermsTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
vheader->setMinimumWidth(rectHeader.width() * 1.08);
|
||||
|
||||
vheader->setDefaultSectionSize(rectMatrix.height() * 2.3);
|
||||
|
||||
m_ui->tvLogisticalTermsTable->setShowGrid(true);
|
||||
m_ui->tvLogisticalTermsTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
header->setVisible(true);
|
||||
vheader->setVisible(true);
|
||||
|
||||
m_ui->tvLogisticalTermsTable->setMinimumWidth((rectMatrix.width() * 1.08 * 5) + rectHeader.width() * 1.08 + 5);
|
||||
m_ui->tvLogisticalTermsTable->setMinimumHeight((rectMatrix.height() * 2.3 * 5) + rectHeader.height() * 1.3);
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
QString qs = QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableColumnIndex());
|
||||
m_logisticalTermsModel->setColumnSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableRowIndex());
|
||||
m_logisticalTermsModel->setRowSelectionValuesCSV(qs);
|
||||
|
||||
m_logisticalTermsModel->setMatrixValuesCSV(
|
||||
QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableMatrix()));
|
||||
}
|
||||
return bOk;
|
||||
|
||||
m_ui->tvLogisticalTermsTable->setModel(m_logisticalTermsModel);
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectHeader = fm.boundingRect(QLatin1String("W"));
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WWWWWWWWWW"));
|
||||
|
||||
QHeaderView *header = m_ui->tvLogisticalTermsTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 1.08);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvLogisticalTermsTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
vheader->setMinimumWidth(rectHeader.width() * 1.08);
|
||||
|
||||
vheader->setDefaultSectionSize(rectMatrix.height() * 2.3);
|
||||
|
||||
m_ui->tvLogisticalTermsTable->setShowGrid(true);
|
||||
m_ui->tvLogisticalTermsTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
|
||||
header->setVisible(true);
|
||||
vheader->setVisible(true);
|
||||
|
||||
m_ui->tvLogisticalTermsTable->setMinimumWidth((rectMatrix.width() * 1.08 * 5) + rectHeader.width() * 1.08 + 5);
|
||||
m_ui->tvLogisticalTermsTable->setMinimumHeight((rectMatrix.height() * 2.3 * 5) + rectHeader.height() * 1.3);
|
||||
|
||||
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
QString qs = QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableColumnIndex());
|
||||
m_logisticalTermsModel->setColumnSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableRowIndex());
|
||||
m_logisticalTermsModel->setRowSelectionValuesCSV(qs);
|
||||
|
||||
|
||||
m_logisticalTermsModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableMatrix()));
|
||||
}
|
||||
return bOk;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CodificationDataTableView::initPhraseTableModel()
|
||||
{
|
||||
bool bOk = false;
|
||||
bool bOk = false;
|
||||
|
||||
if (!m_phraseTableModel->init(m_dtc, m_codificationDataId, false))
|
||||
if (!m_phraseTableModel->init(m_dtc, m_codificationDataId, false))
|
||||
return bOk;
|
||||
|
||||
m_ui->tvPhraseTable->setModel(m_phraseTableModel);
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WWWWWWWWWWWWWWW"));
|
||||
|
||||
QHeaderView* header = m_ui->tvPhraseTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 1.08);
|
||||
|
||||
QHeaderView* vheader = m_ui->tvPhraseTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
vheader->setDefaultSectionSize(rectMatrix.height() * 1.3);
|
||||
|
||||
m_ui->tvPhraseTable->setShowGrid(true);
|
||||
m_ui->tvPhraseTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
header->setVisible(false);
|
||||
vheader->setVisible(false);
|
||||
|
||||
m_ui->tvPhraseTable->setMinimumWidth((rectMatrix.width() * 1.08 * 2) + 5);
|
||||
m_ui->tvPhraseTable->setMinimumHeight(rectMatrix.height() * 1.3 * 13);
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
|
||||
m_phraseTableModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.phraseTable()));
|
||||
}
|
||||
return bOk;
|
||||
}
|
||||
|
||||
m_ui->tvPhraseTable->setModel(m_phraseTableModel);
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rectMatrix = fm.boundingRect(QLatin1String("WWWWWWWWWWWWWWW"));
|
||||
|
||||
QHeaderView *header = m_ui->tvPhraseTable->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 1.08);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvPhraseTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
vheader->setDefaultSectionSize(rectMatrix.height() * 1.3);
|
||||
|
||||
m_ui->tvPhraseTable->setShowGrid(true);
|
||||
m_ui->tvPhraseTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
|
||||
header->setVisible(false);
|
||||
vheader->setVisible(false);
|
||||
|
||||
m_ui->tvPhraseTable->setMinimumWidth((rectMatrix.width() * 1.08 * 2) + 5);
|
||||
m_ui->tvPhraseTable->setMinimumHeight(rectMatrix.height() * 1.3 * 13);
|
||||
|
||||
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
|
||||
m_phraseTableModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.phraseTable()));
|
||||
}
|
||||
return bOk;
|
||||
}
|
||||
|
||||
|
||||
void CodificationDataTableView::onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
void CodificationDataTableView::onCodificationDataChanged(const CodificationManagement::CodificationData& data,
|
||||
DataModification modType)
|
||||
{
|
||||
if (m_codificationDataId != data.id() || modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
m_ui->pteNote->setPlainText(QString::fromStdString(data.note()));
|
||||
|
||||
}
|
||||
|
||||
if (m_codificationDataId != data.id() || modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
m_ui->pteNote->setPlainText(QString::fromStdString(data.note()));
|
||||
}
|
||||
Executable → Regular
+33
-51
@@ -1,22 +1,18 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <Services/CodificationManagement/cod_dtc.h>
|
||||
#include <Services/CodificationManagement/cod_ftc.h>
|
||||
#include <CodificationManagement/logger.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CodificationDataTableView;
|
||||
}
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
@@ -27,61 +23,47 @@ class PhraseTableModel;
|
||||
|
||||
class CodificationDataTableView : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CodificationDataTableView(QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit CodificationDataTableView(QWidget* parent = nullptr);
|
||||
|
||||
~CodificationDataTableView();
|
||||
~CodificationDataTableView();
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc> &ftc,
|
||||
LtsSession::LtsSession *session,
|
||||
int partyId,
|
||||
int codificationDataId);
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc>& ftc, LtsSession::LtsSession* session,
|
||||
int partyId, int codificationDataId);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType);
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData& data, DataModification modType);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void retranslate() override;
|
||||
void loadCodificationDataFromDatabase();
|
||||
void onPrint();
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void retranslate() override;
|
||||
void loadCodificationDataFromDatabase();
|
||||
void onPrint();
|
||||
bool initNumeralModel();
|
||||
|
||||
|
||||
bool initAuthenticationModel();
|
||||
|
||||
bool initNumeralModel();
|
||||
bool initLogicalTermsModel();
|
||||
|
||||
|
||||
bool initPhraseTableModel();
|
||||
|
||||
bool initAuthenticationModel();
|
||||
|
||||
|
||||
|
||||
bool initLogicalTermsModel();
|
||||
|
||||
|
||||
|
||||
bool initPhraseTableModel();
|
||||
|
||||
private:
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> m_ftc;
|
||||
LtsSession::LtsSession *m_session{nullptr};
|
||||
int m_partyId{-1};
|
||||
int m_codificationDataId{0};
|
||||
Ui::CodificationDataTableView *m_ui{nullptr};
|
||||
NumeralCodeModel *m_numCodeModel{nullptr};
|
||||
AuthenticationCodeModel *m_authenticationCodeModel{nullptr};
|
||||
LogisticalTermsModel *m_logisticalTermsModel{nullptr};
|
||||
PhraseTableModel *m_phraseTableModel{nullptr};
|
||||
CodificationManagement::CodificationData m_lastDdsCodificationData;
|
||||
private:
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> m_ftc;
|
||||
LtsSession::LtsSession* m_session{nullptr};
|
||||
int m_partyId{-1};
|
||||
int m_codificationDataId{0};
|
||||
Ui::CodificationDataTableView* m_ui{nullptr};
|
||||
NumeralCodeModel* m_numCodeModel{nullptr};
|
||||
AuthenticationCodeModel* m_authenticationCodeModel{nullptr};
|
||||
LogisticalTermsModel* m_logisticalTermsModel{nullptr};
|
||||
PhraseTableModel* m_phraseTableModel{nullptr};
|
||||
CodificationManagement::CodificationData m_lastDdsCodificationData;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+58
-74
@@ -1,107 +1,91 @@
|
||||
|
||||
|
||||
|
||||
#include "cod_csv_export.h"
|
||||
#include "cod_numeral_code_model.h"
|
||||
|
||||
#include "cod_authentication_code_model.h"
|
||||
#include "cod_logistical_terms_model.h"
|
||||
#include "cod_numeral_code_model.h"
|
||||
#include "cod_phrase_table_model.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
CSVExport::CSVExport(const NumeralCodeModel *numCodeModel,
|
||||
const AuthenticationCodeModel *authenticationCodeModel,
|
||||
const LogisticalTermsModel *logisticalTermsModel,
|
||||
const PhraseTableModel *phraseTableModel,
|
||||
const QString ¬e,
|
||||
QWidget *parent) : QWidget(parent)
|
||||
, m_numCodeModel(numCodeModel)
|
||||
, m_authenticationCodeModel(authenticationCodeModel)
|
||||
, m_logisticalTermsModel(logisticalTermsModel)
|
||||
, m_phraseTableModel(phraseTableModel)
|
||||
, m_note(note),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {
|
||||
}
|
||||
|
||||
CSVExport::CSVExport(const NumeralCodeModel* numCodeModel, const AuthenticationCodeModel* authenticationCodeModel,
|
||||
const LogisticalTermsModel* logisticalTermsModel, const PhraseTableModel* phraseTableModel,
|
||||
const QString& note, QWidget* parent)
|
||||
: QWidget(parent), m_numCodeModel(numCodeModel), m_authenticationCodeModel(authenticationCodeModel),
|
||||
m_logisticalTermsModel(logisticalTermsModel), m_phraseTableModel(phraseTableModel), m_note(note),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger())
|
||||
{
|
||||
}
|
||||
|
||||
QByteArray CSVExport::exportToByteArray() const
|
||||
{
|
||||
QByteArray byteArray;
|
||||
QByteArray byteArray;
|
||||
|
||||
|
||||
byteArray.append("<Numeral Code Horizontal Header>\n");
|
||||
byteArray.append(m_numCodeModel->getHorizontalHeaderCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
byteArray.append("<Numeral Code Vertical Header>\n");
|
||||
byteArray.append(m_numCodeModel->getVerticalHeaderCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
byteArray.append("<Numeral Code Horizontal Header>\n");
|
||||
byteArray.append(m_numCodeModel->getHorizontalHeaderCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
byteArray.append("<Numeral Code Vertical Header>\n");
|
||||
byteArray.append(m_numCodeModel->getVerticalHeaderCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
|
||||
|
||||
byteArray.append("<Authentication Code Matrix>\n");
|
||||
byteArray.append(m_authenticationCodeModel->getMatrixDataCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
byteArray.append("<Authentication Code Matrix>\n");
|
||||
byteArray.append(m_authenticationCodeModel->getMatrixDataCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
|
||||
|
||||
byteArray.append("<Logistical Terms Table Horizontal Header>\n");
|
||||
byteArray.append(m_logisticalTermsModel->getHorizontalHeaderCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
byteArray.append("<Logistical Terms Table Vertical Header>\n");
|
||||
byteArray.append(m_logisticalTermsModel->getVerticalHeaderCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
byteArray.append("<Logistical Terms Table Matrix>\n");
|
||||
byteArray.append(m_logisticalTermsModel->getMatrixDataCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
byteArray.append("<Logistical Terms Table Horizontal Header>\n");
|
||||
byteArray.append(m_logisticalTermsModel->getHorizontalHeaderCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
byteArray.append("<Logistical Terms Table Vertical Header>\n");
|
||||
byteArray.append(m_logisticalTermsModel->getVerticalHeaderCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
byteArray.append("<Logistical Terms Table Matrix>\n");
|
||||
byteArray.append(m_logisticalTermsModel->getMatrixDataCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
|
||||
|
||||
byteArray.append("<Phrase Table Matrix>\n");
|
||||
byteArray.append(m_phraseTableModel->getMatrixDataCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
byteArray.append("<Phrase Table Matrix>\n");
|
||||
byteArray.append(m_phraseTableModel->getMatrixDataCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
|
||||
|
||||
byteArray.append("<Note>\n");
|
||||
byteArray.append(m_note.toLocal8Bit());
|
||||
|
||||
return byteArray;
|
||||
byteArray.append("<Note>\n");
|
||||
byteArray.append(m_note.toLocal8Bit());
|
||||
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
bool CSVExport::writeCSVData()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "writeCSVData()";
|
||||
DEBUG_LOG(m_logger) << "writeCSVData()";
|
||||
|
||||
QFileDialog dialog;
|
||||
dialog.setNameFilter(tr("CSV File (*.csv)"));
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
dialog.setDirectory(QLatin1String("../TMP"));
|
||||
dialog.setDefaultSuffix(QLatin1String("csv"));
|
||||
QFileDialog dialog;
|
||||
dialog.setNameFilter(tr("CSV File (*.csv)"));
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
dialog.setDirectory(QLatin1String("../TMP"));
|
||||
dialog.setDefaultSuffix(QLatin1String("csv"));
|
||||
|
||||
if (!dialog.exec())
|
||||
return false;
|
||||
const QStringList fileNames = dialog.selectedFiles();
|
||||
if (fileNames.isEmpty())
|
||||
return false;
|
||||
if (!dialog.exec())
|
||||
return false;
|
||||
const QStringList fileNames = dialog.selectedFiles();
|
||||
if (fileNames.isEmpty())
|
||||
return false;
|
||||
|
||||
QFile file;
|
||||
file.setFileName(fileNames.first());
|
||||
QFile file;
|
||||
file.setFileName(fileNames.first());
|
||||
|
||||
if (!file.open(QFile::ReadWrite))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("File is not accessible!"), tr("CSV Export Error"));
|
||||
return false;
|
||||
}
|
||||
if (!file.open(QFile::ReadWrite))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("File is not accessible!"), tr("CSV Export Error"));
|
||||
return false;
|
||||
}
|
||||
|
||||
QByteArray byteArray = exportToByteArray();
|
||||
QByteArray byteArray = exportToByteArray();
|
||||
|
||||
file.write(byteArray);
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
|
||||
}
|
||||
file.write(byteArray);
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
Executable → Regular
+17
-27
@@ -1,12 +1,9 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <CodificationManagement/logger.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
@@ -18,32 +15,25 @@ class PhraseTableModel;
|
||||
|
||||
class CSVExport : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CSVExport(const NumeralCodeModel *numCodeModel,
|
||||
const AuthenticationCodeModel *authenticationCodeModel,
|
||||
const LogisticalTermsModel *logisticalTermsModel,
|
||||
const PhraseTableModel *phraseTableModel,
|
||||
const QString ¬e,
|
||||
QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit CSVExport(const NumeralCodeModel* numCodeModel, const AuthenticationCodeModel* authenticationCodeModel,
|
||||
const LogisticalTermsModel* logisticalTermsModel, const PhraseTableModel* phraseTableModel,
|
||||
const QString& note, QWidget* parent = nullptr);
|
||||
|
||||
bool writeCSVData();
|
||||
QByteArray exportToByteArray() const;
|
||||
bool writeCSVData();
|
||||
QByteArray exportToByteArray() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
private Q_SLOTS:
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
const NumeralCodeModel *m_numCodeModel;
|
||||
const AuthenticationCodeModel *m_authenticationCodeModel;
|
||||
const LogisticalTermsModel *m_logisticalTermsModel;
|
||||
const PhraseTableModel *m_phraseTableModel;
|
||||
QString m_note;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
const NumeralCodeModel* m_numCodeModel;
|
||||
const AuthenticationCodeModel* m_authenticationCodeModel;
|
||||
const LogisticalTermsModel* m_logisticalTermsModel;
|
||||
const PhraseTableModel* m_phraseTableModel;
|
||||
QString m_note;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+448
-477
File diff suppressed because it is too large.
Load diff
Executable → Regular
+28
-42
@@ -1,12 +1,9 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <CodificationManagement/logger.h>
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
@@ -16,51 +13,40 @@ class AuthenticationCodeModel;
|
||||
class LogisticalTermsModel;
|
||||
class PhraseTableModel;
|
||||
|
||||
|
||||
|
||||
class CSVImport : public QWidget
|
||||
{
|
||||
public:
|
||||
enum CSVImportResult
|
||||
{
|
||||
UserAbort,
|
||||
LoadOk,
|
||||
LoadFailed
|
||||
};
|
||||
public:
|
||||
enum CSVImportResult { UserAbort, LoadOk, LoadFailed };
|
||||
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CSVImport(NumeralCodeModel *numCodeModel,
|
||||
AuthenticationCodeModel *authenticationCodeModel,
|
||||
LogisticalTermsModel *logisticalTermsModel,
|
||||
PhraseTableModel *phraseTableModel,
|
||||
QString *note,
|
||||
QWidget *parent = nullptr);
|
||||
public:
|
||||
explicit CSVImport(NumeralCodeModel* numCodeModel, AuthenticationCodeModel* authenticationCodeModel,
|
||||
LogisticalTermsModel* logisticalTermsModel, PhraseTableModel* phraseTableModel, QString* note,
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
CSVImportResult loadCSVData();
|
||||
CSVImportResult loadCSVDataByteArray(QByteArray content);
|
||||
CSVImportResult loadCSVData();
|
||||
CSVImportResult loadCSVDataByteArray(QByteArray content);
|
||||
|
||||
private:
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
bool checkNumCodeHorizontalHeader(const QByteArray& qbaNumCodeHorizontalHeader);
|
||||
bool checkNumCodeVerticalHeader(const QByteArray& qbaNumCodeVerticalHeader);
|
||||
bool checkAuthenticationCodeMatrix(QByteArray& qbaAuthenticationCodeMatrix);
|
||||
bool checkLogTermsTableHorizontalHeader(const QByteArray& qbaLogTermsTableHorizontalHeader);
|
||||
bool checkLogTermsTableVerticalHeader(const QByteArray& qbaLogTermsTableVerticalHeader);
|
||||
bool checkLogTermsTableMatrix(const QByteArray& qbaLogTermsTableMatrix);
|
||||
bool checkPhraseTableMatrix(const QByteArray& qbaPhraseTableMatrix);
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
bool checkNumCodeHorizontalHeader(const QByteArray &qbaNumCodeHorizontalHeader);
|
||||
bool checkNumCodeVerticalHeader(const QByteArray &qbaNumCodeVerticalHeader);
|
||||
bool checkAuthenticationCodeMatrix(QByteArray &qbaAuthenticationCodeMatrix);
|
||||
bool checkLogTermsTableHorizontalHeader(const QByteArray &qbaLogTermsTableHorizontalHeader);
|
||||
bool checkLogTermsTableVerticalHeader(const QByteArray &qbaLogTermsTableVerticalHeader);
|
||||
bool checkLogTermsTableMatrix(const QByteArray &qbaLogTermsTableMatrix);
|
||||
bool checkPhraseTableMatrix(const QByteArray &qbaPhraseTableMatrix);
|
||||
static void removeQuotedCharInNote(QByteArray& qbaNote);
|
||||
bool removeRedundantCvsSeperators(QByteArray& qbaLine, int desiredValue) const;
|
||||
|
||||
static void removeQuotedCharInNote(QByteArray &qbaNote);
|
||||
bool removeRedundantCvsSeperators(QByteArray &qbaLine, int desiredValue) const;
|
||||
|
||||
private:
|
||||
NumeralCodeModel *m_numCodeModel;
|
||||
AuthenticationCodeModel *m_authenticationCodeModel;
|
||||
LogisticalTermsModel *m_logisticalTermsModel;
|
||||
PhraseTableModel *m_phraseTableModel;
|
||||
QString *m_note;
|
||||
private:
|
||||
NumeralCodeModel* m_numCodeModel;
|
||||
AuthenticationCodeModel* m_authenticationCodeModel;
|
||||
LogisticalTermsModel* m_logisticalTermsModel;
|
||||
PhraseTableModel* m_phraseTableModel;
|
||||
QString* m_note;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+345
-385
@@ -1,469 +1,429 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "cod_logistical_terms_model.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <QGuiApplication>
|
||||
#include <QPalette>
|
||||
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
static const int s_matrixCount = 5;
|
||||
|
||||
LogisticalTermsModel::LogisticalTermsModel(QWidget *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_codificationDataId(0)
|
||||
, m_isEditMode(false)
|
||||
LogisticalTermsModel::LogisticalTermsModel(QWidget* parent)
|
||||
: QAbstractTableModel(parent), m_dtc(nullptr), m_codificationDataId(0), m_isEditMode(false)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ctor LogisticalTermsModel";
|
||||
m_matrix.resize(s_matrixCount);
|
||||
for (int i = 0; i < s_matrixCount; ++i)
|
||||
m_matrix[i].resize(s_matrixCount);
|
||||
DEBUG_LOG(m_logger) << "ctor LogisticalTermsModel";
|
||||
m_matrix.resize(s_matrixCount);
|
||||
for (int i = 0; i < s_matrixCount; ++i)
|
||||
m_matrix[i].resize(s_matrixCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool LogisticalTermsModel::init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode)
|
||||
bool LogisticalTermsModel::init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc,
|
||||
int codificationDataId, bool isEditMode)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "LogisticalTerms::init()";
|
||||
if (!dtc)
|
||||
return false;
|
||||
DEBUG_LOG(m_logger) << "LogisticalTerms::init()";
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsModel::init()...";
|
||||
DEBUG_LOG(m_logger) << "LogisticalTermsModel::init()...";
|
||||
|
||||
m_dtc = dtc;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_isEditMode = isEditMode;
|
||||
m_dtc = dtc;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_isEditMode = isEditMode;
|
||||
|
||||
resetHeader();
|
||||
resetMatrix();
|
||||
|
||||
if (!isEditMode)
|
||||
{
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged,
|
||||
this, &LogisticalTermsModel::onCodificationDataChanged);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
resetHeader();
|
||||
resetMatrix();
|
||||
|
||||
if (!isEditMode)
|
||||
{
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged, this,
|
||||
&LogisticalTermsModel::onCodificationDataChanged);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void LogisticalTermsModel::resetHeader()
|
||||
{
|
||||
|
||||
m_ColumnSelectionValues = QVector<QChar>(s_matrixCount, QLatin1Char('?'));
|
||||
m_RowSelectionValues = QVector<QChar>(s_matrixCount, QLatin1Char('?'));
|
||||
}
|
||||
|
||||
m_ColumnSelectionValues = QVector<QChar>(s_matrixCount, QLatin1Char('?'));
|
||||
m_RowSelectionValues = QVector<QChar>(s_matrixCount, QLatin1Char('?'));
|
||||
}
|
||||
|
||||
void LogisticalTermsModel::resetMatrix()
|
||||
{
|
||||
beginResetModel();
|
||||
for (auto &colData : m_matrix)
|
||||
{
|
||||
for (auto &cell : colData)
|
||||
cell = QLatin1String("---");
|
||||
}
|
||||
endResetModel();
|
||||
beginResetModel();
|
||||
for (auto& colData : m_matrix)
|
||||
{
|
||||
for (auto& cell : colData)
|
||||
cell = QLatin1String("---");
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool LogisticalTermsModel::setColumnSelectionValuesCSV(const QString &csvData)
|
||||
bool LogisticalTermsModel::setColumnSelectionValuesCSV(const QString& csvData)
|
||||
{
|
||||
m_ColumnSelectionValues.clear();
|
||||
m_ColumnSelectionValues.resize(s_matrixCount);
|
||||
m_ColumnSelectionValues.clear();
|
||||
m_ColumnSelectionValues.resize(s_matrixCount);
|
||||
|
||||
const QVector<QStringRef> slColumns = csvData.splitRef(QLatin1Char(';'));
|
||||
const QVector<QStringRef> slColumns = csvData.splitRef(QLatin1Char(';'));
|
||||
|
||||
if (slColumns.size() != m_ColumnSelectionValues.size())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << m_ColumnSelectionValues.size() << "/" << slColumns.size();
|
||||
m_ColumnSelectionValues.fill(QLatin1Char(' '));
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_ColumnSelectionValues.size(); ++i)
|
||||
{
|
||||
const QStringRef &qs = slColumns.at(i);
|
||||
if (qs.size() != 1)
|
||||
if (slColumns.size() != m_ColumnSelectionValues.size())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data value at id: " << i
|
||||
<< " codificationDataId: " << m_codificationDataId;
|
||||
return false;
|
||||
}
|
||||
m_ColumnSelectionValues[i] = qs.at(0);
|
||||
}
|
||||
emit dataChanged(index(0, 0), index(0, m_ColumnSelectionValues.size() - 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool LogisticalTermsModel::setRowSelectionValuesCSV(const QString &csvData)
|
||||
{
|
||||
m_RowSelectionValues.clear();
|
||||
m_RowSelectionValues.resize(s_matrixCount);
|
||||
|
||||
const QVector<QStringRef> slRows = csvData.splitRef(QStringLiteral("\n"));
|
||||
|
||||
if (slRows.size() != m_RowSelectionValues.size())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid row data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << m_RowSelectionValues.size() << "/" << slRows.size()
|
||||
<< " Default values will be used. ";
|
||||
m_RowSelectionValues.fill(QLatin1Char(' '));
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_RowSelectionValues.size(); ++i)
|
||||
{
|
||||
const QStringRef &qs = slRows.at(i);
|
||||
if (qs.size() != 1)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid row data value at id: " << i
|
||||
<< " codificationDataId: " << m_codificationDataId;
|
||||
return false;
|
||||
}
|
||||
m_RowSelectionValues[i] = qs.at(0);
|
||||
}
|
||||
emit dataChanged(index(0, 0), index(0, m_RowSelectionValues.size() - 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool LogisticalTermsModel::setMatrixValuesCSV(const QString &csvData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setMatrixValuesCSV: " << csvData;
|
||||
|
||||
const QStringList slRows = splitQuotedStringToRows(csvData);
|
||||
|
||||
if (slRows.isEmpty())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "split quoted csv data failed! " << " codificationDataId: " << m_codificationDataId
|
||||
<< " csvData: " << csvData;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (slRows.size() != m_matrix.size())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid row data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << m_matrix.size() << "/" << slRows.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int row = 0; row < slRows.size(); ++row)
|
||||
{
|
||||
const QVector<QStringRef> slColumns = slRows[row].splitRef(QLatin1Char(';'));
|
||||
if (slColumns.size() != m_matrix.size())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << m_matrix.size() << "/" << slColumns.size();
|
||||
return false;
|
||||
ERROR_LOG(m_logger) << "Invalid column data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << m_ColumnSelectionValues.size() << "/" << slColumns.size();
|
||||
m_ColumnSelectionValues.fill(QLatin1Char(' '));
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int column = 0; column < m_matrix.size(); ++column)
|
||||
m_matrix[row][column] = slColumns.at(column).toString();
|
||||
for (int i = 0; i < m_ColumnSelectionValues.size(); ++i)
|
||||
{
|
||||
const QStringRef& qs = slColumns.at(i);
|
||||
if (qs.size() != 1)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data value at id: " << i
|
||||
<< " codificationDataId: " << m_codificationDataId;
|
||||
return false;
|
||||
}
|
||||
m_ColumnSelectionValues[i] = qs.at(0);
|
||||
}
|
||||
emit dataChanged(index(0, 0), index(0, m_ColumnSelectionValues.size() - 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool LogisticalTermsModel::setRowSelectionValuesCSV(const QString& csvData)
|
||||
{
|
||||
m_RowSelectionValues.clear();
|
||||
m_RowSelectionValues.resize(s_matrixCount);
|
||||
|
||||
const QVector<QStringRef> slRows = csvData.splitRef(QStringLiteral("\n"));
|
||||
|
||||
if (slRows.size() != m_RowSelectionValues.size())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid row data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << m_RowSelectionValues.size() << "/" << slRows.size()
|
||||
<< " Default values will be used. ";
|
||||
m_RowSelectionValues.fill(QLatin1Char(' '));
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_RowSelectionValues.size(); ++i)
|
||||
{
|
||||
const QStringRef& qs = slRows.at(i);
|
||||
if (qs.size() != 1)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid row data value at id: " << i
|
||||
<< " codificationDataId: " << m_codificationDataId;
|
||||
return false;
|
||||
}
|
||||
m_RowSelectionValues[i] = qs.at(0);
|
||||
}
|
||||
emit dataChanged(index(0, 0), index(0, m_RowSelectionValues.size() - 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LogisticalTermsModel::setMatrixValuesCSV(const QString& csvData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setMatrixValuesCSV: " << csvData;
|
||||
|
||||
const QStringList slRows = splitQuotedStringToRows(csvData);
|
||||
|
||||
if (slRows.isEmpty())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "split quoted csv data failed! " << " codificationDataId: " << m_codificationDataId
|
||||
<< " csvData: " << csvData;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (slRows.size() != m_matrix.size())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid row data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << m_matrix.size() << "/" << slRows.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int row = 0; row < slRows.size(); ++row)
|
||||
{
|
||||
const QVector<QStringRef> slColumns = slRows[row].splitRef(QLatin1Char(';'));
|
||||
if (slColumns.size() != m_matrix.size())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << m_matrix.size() << "/" << slColumns.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int column = 0; column < m_matrix.size(); ++column)
|
||||
m_matrix[row][column] = slColumns.at(column).toString();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString LogisticalTermsModel::getHorizontalHeaderCSVString() const
|
||||
{
|
||||
QStringList slColumns;
|
||||
slColumns.reserve(m_ColumnSelectionValues.size());
|
||||
for (const QChar &c : m_ColumnSelectionValues)
|
||||
slColumns += QString(c);
|
||||
|
||||
return slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
QStringList slColumns;
|
||||
slColumns.reserve(m_ColumnSelectionValues.size());
|
||||
for (const QChar& c : m_ColumnSelectionValues)
|
||||
slColumns += QString(c);
|
||||
|
||||
return slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
|
||||
QString LogisticalTermsModel::getVerticalHeaderCSVString() const
|
||||
{
|
||||
QStringList slRows;
|
||||
slRows.reserve(m_RowSelectionValues.size());
|
||||
for (const QChar &c : m_RowSelectionValues)
|
||||
slRows += QString(c);
|
||||
|
||||
return slRows.join(QLatin1Char('\n'));
|
||||
}
|
||||
QStringList slRows;
|
||||
slRows.reserve(m_RowSelectionValues.size());
|
||||
for (const QChar& c : m_RowSelectionValues)
|
||||
slRows += QString(c);
|
||||
|
||||
return slRows.join(QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
QString LogisticalTermsModel::getMatrixDataCSVString() const
|
||||
{
|
||||
QStringList slColumns;
|
||||
slColumns.reserve(m_matrix.size());
|
||||
QStringList slRows;
|
||||
slRows.reserve(m_matrix.size());
|
||||
QStringList slColumns;
|
||||
slColumns.reserve(m_matrix.size());
|
||||
QStringList slRows;
|
||||
slRows.reserve(m_matrix.size());
|
||||
|
||||
for (const auto &colData : m_matrix)
|
||||
{
|
||||
slColumns.clear();
|
||||
for (const auto &cell : colData)
|
||||
for (const auto& colData : m_matrix)
|
||||
{
|
||||
if (cell.contains(QLatin1Char('\n')))
|
||||
slColumns += QLatin1Char('\"') + cell + QLatin1Char('\"');
|
||||
else
|
||||
slColumns += cell;
|
||||
slColumns.clear();
|
||||
for (const auto& cell : colData)
|
||||
{
|
||||
if (cell.contains(QLatin1Char('\n')))
|
||||
slColumns += QLatin1Char('\"') + cell + QLatin1Char('\"');
|
||||
else
|
||||
slColumns += cell;
|
||||
}
|
||||
slRows += slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
slRows += slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
|
||||
const QString qs(slRows.join(QLatin1Char('\n')));
|
||||
DEBUG_LOG(m_logger) << "getMatrixDataCSVString() : " << qs;
|
||||
return qs;
|
||||
}
|
||||
|
||||
const QString qs(slRows.join(QLatin1Char('\n')));
|
||||
DEBUG_LOG(m_logger) << "getMatrixDataCSVString() : " << qs;
|
||||
return qs;
|
||||
}
|
||||
|
||||
void LogisticalTermsModel::setEditMode(bool isEditMode)
|
||||
{
|
||||
m_isEditMode = isEditMode;
|
||||
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||
}
|
||||
m_isEditMode = isEditMode;
|
||||
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||
}
|
||||
|
||||
bool LogisticalTermsModel::isEditMode() const
|
||||
{
|
||||
return m_isEditMode;
|
||||
}
|
||||
return m_isEditMode;
|
||||
}
|
||||
|
||||
|
||||
int LogisticalTermsModel::rowCount(const QModelIndex &parent) const
|
||||
int LogisticalTermsModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return s_matrixCount + (m_isEditMode ? 1 : 0);
|
||||
}
|
||||
Q_UNUSED(parent)
|
||||
return s_matrixCount + (m_isEditMode ? 1 : 0);
|
||||
}
|
||||
|
||||
|
||||
int LogisticalTermsModel::columnCount(const QModelIndex &parent) const
|
||||
int LogisticalTermsModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return s_matrixCount + (m_isEditMode ? 1 : 0);
|
||||
}
|
||||
|
||||
Q_UNUSED(parent)
|
||||
return s_matrixCount + (m_isEditMode ? 1 : 0);
|
||||
}
|
||||
|
||||
QVariant LogisticalTermsModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
if (role != Qt::DisplayRole)
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
|
||||
|
||||
if (isEditMode())
|
||||
return QVariant();
|
||||
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
if (section < m_ColumnSelectionValues.size())
|
||||
return m_ColumnSelectionValues.at(section);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
|
||||
if (orientation == Qt::Vertical)
|
||||
{
|
||||
if (section < m_RowSelectionValues.size())
|
||||
return m_RowSelectionValues.at(section);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
|
||||
QVariant LogisticalTermsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
{
|
||||
if (!m_isEditMode)
|
||||
{
|
||||
|
||||
|
||||
return m_matrix[index.row()][index.column()];
|
||||
}
|
||||
|
||||
if (index.column() == 0 && index.row() == 0)
|
||||
return QVariant();
|
||||
|
||||
|
||||
if (index.row() == 0 && index.column() <= m_ColumnSelectionValues.size())
|
||||
{
|
||||
|
||||
|
||||
return m_ColumnSelectionValues.at(index.column() - 1);
|
||||
}
|
||||
|
||||
|
||||
if (index.column() == 0 && index.row() <= m_RowSelectionValues.size())
|
||||
{
|
||||
|
||||
|
||||
return m_RowSelectionValues.at(index.row() - 1);
|
||||
}
|
||||
|
||||
|
||||
if (index.column() > 0 && index.row() > 0)
|
||||
{
|
||||
|
||||
|
||||
return m_matrix[index.row() - 1][index.column() - 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignCenter;
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (m_isEditMode)
|
||||
{
|
||||
if ((index.row() == 0) || (index.column() == 0))
|
||||
return QGuiApplication::palette().color(QPalette::Active, QPalette::Base);
|
||||
return QGuiApplication::palette().color(QPalette::Active, QPalette::Base);
|
||||
}
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
bool LogisticalTermsModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setData() row/col: " << index.row() << "/" << index.column()
|
||||
<< " value:" << value.toString();
|
||||
|
||||
const QString qs = value.toString();
|
||||
if (qs.isEmpty())
|
||||
return false;
|
||||
|
||||
if (value.toString().contains(QLatin1Char('\"')) || value.toString().contains(QLatin1Char(';')))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget *>(parent()), tr("Inputs with the characters ; \" are not possible."), tr("Input Error"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
|
||||
if (index.row() == 0)
|
||||
{
|
||||
m_ColumnSelectionValues[index.column() - 1] = qs.at(0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
else if (index.column() == 0 && (index.row() > 0))
|
||||
m_RowSelectionValues[index.row() - 1] = qs.at(0);
|
||||
|
||||
|
||||
else if ((index.column() > 0) && (index.row() > 0))
|
||||
m_matrix[index.row() - 1][index.column() - 1] = qs;
|
||||
emit dataModified();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Qt::ItemFlags LogisticalTermsModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Qt::ItemFlags flags = QAbstractTableModel::flags(index);
|
||||
|
||||
if (((index.row() <= rowCount() - 1) && (index.column() <= columnCount() - 1)) &&
|
||||
!((index.row() == 0) && (index.column() == 0)))
|
||||
{
|
||||
if (isEditMode())
|
||||
flags |= Qt::ItemIsEditable;
|
||||
else
|
||||
flags &= ~Qt::ItemIsEditable;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
return QVariant();
|
||||
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
if (section < m_ColumnSelectionValues.size())
|
||||
return m_ColumnSelectionValues.at(section);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
|
||||
void LogisticalTermsModel::onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
if (orientation == Qt::Vertical)
|
||||
{
|
||||
if (section < m_RowSelectionValues.size())
|
||||
return m_RowSelectionValues.at(section);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
}
|
||||
|
||||
QVariant LogisticalTermsModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
{
|
||||
if (!m_isEditMode)
|
||||
{
|
||||
|
||||
return m_matrix[index.row()][index.column()];
|
||||
}
|
||||
|
||||
if (index.column() == 0 && index.row() == 0)
|
||||
return QVariant();
|
||||
|
||||
if (index.row() == 0 && index.column() <= m_ColumnSelectionValues.size())
|
||||
{
|
||||
|
||||
return m_ColumnSelectionValues.at(index.column() - 1);
|
||||
}
|
||||
|
||||
if (index.column() == 0 && index.row() <= m_RowSelectionValues.size())
|
||||
{
|
||||
|
||||
return m_RowSelectionValues.at(index.row() - 1);
|
||||
}
|
||||
|
||||
if (index.column() > 0 && index.row() > 0)
|
||||
{
|
||||
|
||||
return m_matrix[index.row() - 1][index.column() - 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignCenter;
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (m_isEditMode)
|
||||
{
|
||||
if ((index.row() == 0) || (index.column() == 0))
|
||||
return QGuiApplication::palette().color(QPalette::Active, QPalette::Base);
|
||||
return QGuiApplication::palette().color(QPalette::Active, QPalette::Base);
|
||||
}
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
bool LogisticalTermsModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setData() row/col: " << index.row() << "/" << index.column()
|
||||
<< " value:" << value.toString();
|
||||
|
||||
const QString qs = value.toString();
|
||||
if (qs.isEmpty())
|
||||
return false;
|
||||
|
||||
if (value.toString().contains(QLatin1Char('\"')) || value.toString().contains(QLatin1Char(';')))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget*>(parent()),
|
||||
tr("Inputs with the characters ; \" are not possible."),
|
||||
tr("Input Error"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
|
||||
if (index.row() == 0)
|
||||
{
|
||||
m_ColumnSelectionValues[index.column() - 1] = qs.at(0);
|
||||
}
|
||||
|
||||
else if (index.column() == 0 && (index.row() > 0))
|
||||
m_RowSelectionValues[index.row() - 1] = qs.at(0);
|
||||
|
||||
else if ((index.column() > 0) && (index.row() > 0))
|
||||
m_matrix[index.row() - 1][index.column() - 1] = qs;
|
||||
emit dataModified();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Qt::ItemFlags LogisticalTermsModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
Qt::ItemFlags flags = QAbstractTableModel::flags(index);
|
||||
|
||||
if (((index.row() <= rowCount() - 1) && (index.column() <= columnCount() - 1)) &&
|
||||
!((index.row() == 0) && (index.column() == 0)))
|
||||
{
|
||||
if (isEditMode())
|
||||
flags |= Qt::ItemIsEditable;
|
||||
else
|
||||
flags &= ~Qt::ItemIsEditable;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
void LogisticalTermsModel::onCodificationDataChanged(const CodificationManagement::CodificationData& data,
|
||||
DataModification modType)
|
||||
{
|
||||
const int id = data.id();
|
||||
const int id = data.id();
|
||||
|
||||
DEBUG_LOG(m_logger) << "onCodificationDataChanged for CodificationData id: " << id
|
||||
<< " - NumCodeColumnIdx data: " << data.numeralCodeTableColumnIndex().c_str()
|
||||
<< " - NumCodeRowIdx data: " << data.numeralCodeTableRowIndex().c_str()
|
||||
<< " - modType: " << modType;
|
||||
DEBUG_LOG(m_logger) << "onCodificationDataChanged for CodificationData id: " << id
|
||||
<< " - NumCodeColumnIdx data: " << data.numeralCodeTableColumnIndex().c_str()
|
||||
<< " - NumCodeRowIdx data: " << data.numeralCodeTableRowIndex().c_str()
|
||||
<< " - modType: " << modType;
|
||||
|
||||
if (m_codificationDataId != data.id())
|
||||
return;
|
||||
if (m_codificationDataId != data.id())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "CodificationData was removed. id: " << id << " ToDo: 'ShowCodificationData' Tab loeschen !?";
|
||||
|
||||
resetMatrix();
|
||||
setColumnSelectionValuesCSV(QString());
|
||||
setRowSelectionValuesCSV(QString());
|
||||
return;
|
||||
}
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "CodificationData was removed. id: " << id
|
||||
<< " ToDo: 'ShowCodificationData' Tab loeschen !?";
|
||||
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationData was modifed. id: " << id << " - " << data.note();
|
||||
resetMatrix();
|
||||
setColumnSelectionValuesCSV(QString());
|
||||
setRowSelectionValuesCSV(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
QString qs = QString::fromStdString(data.logisticalTermTableColumnIndex());
|
||||
setColumnSelectionValuesCSV(qs);
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationData was modifed. id: " << id << " - " << data.note();
|
||||
|
||||
qs = QString::fromStdString(data.logisticalTermTableRowIndex());
|
||||
setRowSelectionValuesCSV(qs);
|
||||
QString qs = QString::fromStdString(data.logisticalTermTableColumnIndex());
|
||||
setColumnSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(data.logisticalTermTableMatrix());
|
||||
setMatrixValuesCSV(qs);
|
||||
}
|
||||
}
|
||||
qs = QString::fromStdString(data.logisticalTermTableRowIndex());
|
||||
setRowSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(data.logisticalTermTableMatrix());
|
||||
setMatrixValuesCSV(qs);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList LogisticalTermsModel::splitQuotedStringToRows(const QString &str)
|
||||
QStringList LogisticalTermsModel::splitQuotedStringToRows(const QString& str)
|
||||
{
|
||||
QStringList slRows;
|
||||
QString row;
|
||||
row.reserve(str.size());
|
||||
QStringList slRows;
|
||||
QString row;
|
||||
row.reserve(str.size());
|
||||
|
||||
for (int i = 0; i < str.size(); ++i)
|
||||
{
|
||||
if (str.at(i) != QLatin1Char('\"') && str.at(i) != QLatin1Char('\n'))
|
||||
for (int i = 0; i < str.size(); ++i)
|
||||
{
|
||||
row.append(str.at(i));
|
||||
continue;
|
||||
if (str.at(i) != QLatin1Char('\"') && str.at(i) != QLatin1Char('\n'))
|
||||
{
|
||||
row.append(str.at(i));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str.at(i) == QLatin1Char('\"'))
|
||||
{
|
||||
++i;
|
||||
while (str.at(i) != QLatin1Char('\"'))
|
||||
{
|
||||
row.append(str.at(i));
|
||||
++i;
|
||||
if (i > str.size())
|
||||
return QStringList();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str.at(i) == QLatin1Char('\n'))
|
||||
{
|
||||
slRows += row;
|
||||
row.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (str.at(i) == QLatin1Char('\"'))
|
||||
{
|
||||
++i;
|
||||
while (str.at(i) != QLatin1Char('\"'))
|
||||
{
|
||||
row.append(str.at(i));
|
||||
++i;
|
||||
if (i > str.size())
|
||||
return QStringList();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str.at(i) == QLatin1Char('\n'))
|
||||
{
|
||||
slRows += row;
|
||||
row.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (!row.isEmpty())
|
||||
slRows += row;
|
||||
return slRows;
|
||||
|
||||
}
|
||||
|
||||
if (!row.isEmpty())
|
||||
slRows += row;
|
||||
return slRows;
|
||||
}
|
||||
Executable → Regular
+37
-99
@@ -1,136 +1,74 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <CodificationManagement/cod_dtc.h>
|
||||
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class LogisticalTermsModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LogisticalTermsModel(QWidget *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LogisticalTermsModel(QWidget* parent);
|
||||
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc, int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
void resetHeader();
|
||||
|
||||
|
||||
void resetMatrix();
|
||||
|
||||
void resetHeader();
|
||||
bool setColumnSelectionValuesCSV(const QString& csvData);
|
||||
|
||||
|
||||
bool setRowSelectionValuesCSV(const QString& csvData);
|
||||
|
||||
void resetMatrix();
|
||||
bool setMatrixValuesCSV(const QString& csvData);
|
||||
|
||||
|
||||
QString getHorizontalHeaderCSVString() const;
|
||||
|
||||
bool setColumnSelectionValuesCSV(const QString &csvData);
|
||||
QString getVerticalHeaderCSVString() const;
|
||||
|
||||
|
||||
QString getMatrixDataCSVString() const;
|
||||
|
||||
bool setRowSelectionValuesCSV(const QString &csvData);
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
|
||||
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
bool setMatrixValuesCSV(const QString &csvData);
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
QString getHorizontalHeaderCSVString() const;
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
|
||||
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role) override;
|
||||
|
||||
QString getVerticalHeaderCSVString() const;
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
|
||||
QStringList splitQuotedStringToRows(const QString& str);
|
||||
|
||||
QString getMatrixDataCSVString() const;
|
||||
Q_SIGNALS:
|
||||
|
||||
|
||||
void dataModified();
|
||||
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData& data, DataModification modType);
|
||||
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
QVector<QVector<QString>> m_matrix;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVector<QChar> m_RowSelectionValues;
|
||||
QVector<QChar> m_ColumnSelectionValues;
|
||||
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
|
||||
|
||||
QStringList splitQuotedStringToRows(const QString &str);
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
|
||||
|
||||
void dataModified();
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
QVector<QVector<QString>> m_matrix;
|
||||
|
||||
QVector <QChar> m_RowSelectionValues;
|
||||
QVector <QChar> m_ColumnSelectionValues;
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
int m_codificationDataId;
|
||||
bool m_isEditMode;
|
||||
int m_codificationDataId;
|
||||
bool m_isEditMode;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+286
-333
@@ -1,430 +1,383 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "cod_numeral_code_model.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <QGuiApplication>
|
||||
#include <QPalette>
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
NumeralCodeModel::NumeralCodeModel(QWidget *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_codificationDataId(0)
|
||||
, m_isEditMode(false)
|
||||
NumeralCodeModel::NumeralCodeModel(QWidget* parent)
|
||||
: QAbstractTableModel(parent), m_dtc(nullptr), m_codificationDataId(0), m_isEditMode(false)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool NumeralCodeModel::init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool NumeralCodeModel::init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc, int codificationDataId,
|
||||
bool isEditMode)
|
||||
{
|
||||
if (!dtc)
|
||||
return false;
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_isEditMode = isEditMode;
|
||||
m_dtc = dtc;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_isEditMode = isEditMode;
|
||||
|
||||
m_MatrixNumeralSet.resize(10);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
m_MatrixNumeralSet[i] = QLatin1Char('0' + i);
|
||||
|
||||
m_MatrixNumeralSet.resize(10);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
m_MatrixNumeralSet[i] = QLatin1Char('0' + i);
|
||||
m_MatrixCharacterSet1.resize(26);
|
||||
for (int i = 0; i < 26; ++i)
|
||||
m_MatrixCharacterSet1[i] = QLatin1Char('A' + i);
|
||||
|
||||
m_MatrixCharacterSet1.resize(26);
|
||||
for (int i = 0; i < 26; ++i)
|
||||
m_MatrixCharacterSet1[i] = QLatin1Char('A' + i);
|
||||
m_MatrixCharacterSet2 << QLatin1Char('D') << QLatin1Char('E') << QLatin1Char('G') << QLatin1Char('H')
|
||||
<< QLatin1Char('I') << QLatin1Char('L') << QLatin1Char('N') << QLatin1Char('O')
|
||||
<< QLatin1Char('R') << QLatin1Char('S') << QLatin1Char('T') << QLatin1Char('U');
|
||||
|
||||
m_MatrixCharacterSet2 << QLatin1Char('D') << QLatin1Char('E') << QLatin1Char('G') << QLatin1Char('H') << QLatin1Char('I') << QLatin1Char('L')
|
||||
<< QLatin1Char('N') << QLatin1Char('O') << QLatin1Char('R') << QLatin1Char('S') << QLatin1Char('T') << QLatin1Char('U');
|
||||
|
||||
resetHeader();
|
||||
initMatrix();
|
||||
|
||||
if (!isEditMode)
|
||||
{
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged,
|
||||
this, &NumeralCodeModel::onCodificationDataChanged);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
resetHeader();
|
||||
initMatrix();
|
||||
|
||||
if (!isEditMode)
|
||||
{
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged, this,
|
||||
&NumeralCodeModel::onCodificationDataChanged);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void NumeralCodeModel::resetHeader()
|
||||
{
|
||||
|
||||
m_ColumnSelectionValues = QVector<QChar>(columnCount() - 1, QLatin1Char('?'));
|
||||
m_RowSelectionValues = QVector<QChar>(rowCount() - 1, QLatin1Char('?'));
|
||||
}
|
||||
|
||||
m_ColumnSelectionValues = QVector<QChar>(columnCount() - 1, QLatin1Char('?'));
|
||||
m_RowSelectionValues = QVector<QChar>(rowCount() - 1, QLatin1Char('?'));
|
||||
}
|
||||
|
||||
bool NumeralCodeModel::setColumnSelectionValuesCSV(const QString &csvData)
|
||||
bool NumeralCodeModel::setColumnSelectionValuesCSV(const QString& csvData)
|
||||
{
|
||||
m_ColumnSelectionValues = QVector<QChar>(columnCount() - 1, QLatin1Char(' '));
|
||||
m_ColumnSelectionValues = QVector<QChar>(columnCount() - 1, QLatin1Char(' '));
|
||||
|
||||
const QVector<QStringRef> slColumns = csvData.splitRef(QLatin1Char(';'));
|
||||
const QVector<QStringRef> slColumns = csvData.splitRef(QLatin1Char(';'));
|
||||
|
||||
if (slColumns.size() != columnCount() - 1)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << columnCount() - 1 << "/" << slColumns.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < columnCount() - 1; ++i)
|
||||
{
|
||||
const QStringRef &qs = slColumns.at(i);
|
||||
if (qs.size() != 1)
|
||||
if (slColumns.size() != columnCount() - 1)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data value at id: " << i
|
||||
<< " codificationDataId: " << m_codificationDataId;
|
||||
return false;
|
||||
ERROR_LOG(m_logger) << "Invalid column data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << columnCount() - 1 << "/" << slColumns.size();
|
||||
return false;
|
||||
}
|
||||
m_ColumnSelectionValues[i] = qs.at(0);
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(0, columnCount() - 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < columnCount() - 1; ++i)
|
||||
{
|
||||
const QStringRef& qs = slColumns.at(i);
|
||||
if (qs.size() != 1)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data value at id: " << i
|
||||
<< " codificationDataId: " << m_codificationDataId;
|
||||
return false;
|
||||
}
|
||||
m_ColumnSelectionValues[i] = qs.at(0);
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(0, columnCount() - 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NumeralCodeModel::setRowSelectionValuesCSV(const QString &csvData)
|
||||
bool NumeralCodeModel::setRowSelectionValuesCSV(const QString& csvData)
|
||||
{
|
||||
m_RowSelectionValues = QVector<QChar>(rowCount() - 1, QLatin1Char(' '));
|
||||
const QVector<QStringRef> slRows = csvData.splitRef(QStringLiteral("\n"));
|
||||
m_RowSelectionValues = QVector<QChar>(rowCount() - 1, QLatin1Char(' '));
|
||||
const QVector<QStringRef> slRows = csvData.splitRef(QStringLiteral("\n"));
|
||||
|
||||
if (slRows.size() != rowCount() - 1)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid row data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << rowCount() - 1 << "/" << slRows.size()
|
||||
<< " Default values will be used. ";
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rowCount() - 1; ++i)
|
||||
{
|
||||
const QStringRef &qs = slRows.at(i);
|
||||
if (qs.size() != 1)
|
||||
if (slRows.size() != rowCount() - 1)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid row data value at id: " << i
|
||||
<< " codificationDataId: " << m_codificationDataId;
|
||||
return false;
|
||||
ERROR_LOG(m_logger) << "Invalid row data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << rowCount() - 1 << "/" << slRows.size()
|
||||
<< " Default values will be used. ";
|
||||
return false;
|
||||
}
|
||||
m_RowSelectionValues[i] = qs.at(0);
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(0, columnCount() - 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rowCount() - 1; ++i)
|
||||
{
|
||||
const QStringRef& qs = slRows.at(i);
|
||||
if (qs.size() != 1)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid row data value at id: " << i
|
||||
<< " codificationDataId: " << m_codificationDataId;
|
||||
return false;
|
||||
}
|
||||
m_RowSelectionValues[i] = qs.at(0);
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(0, columnCount() - 1));
|
||||
return true;
|
||||
}
|
||||
|
||||
QString NumeralCodeModel::getHorizontalHeaderCSVString() const
|
||||
{
|
||||
QStringList slColumns;
|
||||
slColumns.reserve(columnCount() - 1);
|
||||
for (int i = 0; i < columnCount() -1; ++i)
|
||||
{
|
||||
slColumns << QStringLiteral("%1").arg(m_ColumnSelectionValues.at(i));
|
||||
}
|
||||
return slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
|
||||
QStringList slColumns;
|
||||
slColumns.reserve(columnCount() - 1);
|
||||
for (int i = 0; i < columnCount() - 1; ++i)
|
||||
{
|
||||
slColumns << QStringLiteral("%1").arg(m_ColumnSelectionValues.at(i));
|
||||
}
|
||||
return slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
|
||||
QString NumeralCodeModel::getVerticalHeaderCSVString() const
|
||||
{
|
||||
QStringList slRows;
|
||||
slRows.reserve(rowCount() - 1);
|
||||
for (int i = 0; i < rowCount() - 1; ++i)
|
||||
{
|
||||
slRows << QStringLiteral("%1").arg(m_RowSelectionValues.at(i));
|
||||
}
|
||||
return slRows.join(QStringLiteral("\n"));
|
||||
}
|
||||
|
||||
QStringList slRows;
|
||||
slRows.reserve(rowCount() - 1);
|
||||
for (int i = 0; i < rowCount() - 1; ++i)
|
||||
{
|
||||
slRows << QStringLiteral("%1").arg(m_RowSelectionValues.at(i));
|
||||
}
|
||||
return slRows.join(QStringLiteral("\n"));
|
||||
}
|
||||
|
||||
void NumeralCodeModel::setEditMode(bool isEditMode)
|
||||
{
|
||||
m_isEditMode = isEditMode;
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
}
|
||||
|
||||
m_isEditMode = isEditMode;
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
}
|
||||
|
||||
bool NumeralCodeModel::isEditMode() const
|
||||
{
|
||||
return m_isEditMode;
|
||||
}
|
||||
return m_isEditMode;
|
||||
}
|
||||
|
||||
|
||||
int NumeralCodeModel::rowCount(const QModelIndex &parent) const
|
||||
int NumeralCodeModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 14;
|
||||
}
|
||||
Q_UNUSED(parent)
|
||||
return 14;
|
||||
}
|
||||
|
||||
|
||||
int NumeralCodeModel::columnCount(const QModelIndex &parent) const
|
||||
int NumeralCodeModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 14;
|
||||
}
|
||||
|
||||
Q_UNUSED(parent)
|
||||
return 14;
|
||||
}
|
||||
|
||||
QVariant NumeralCodeModel::headerData(int column, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole )
|
||||
{
|
||||
if (isEditMode())
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
|
||||
return QVariant();
|
||||
if (isEditMode())
|
||||
{
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (column == 0)
|
||||
return QVariant();
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
if (!m_ColumnSelectionValues.isEmpty())
|
||||
return m_ColumnSelectionValues.at(column - 1);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
if (orientation == Qt::Vertical)
|
||||
{
|
||||
if (!m_RowSelectionValues.isEmpty())
|
||||
return m_RowSelectionValues.at(column - 1);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (column == 0)
|
||||
return QVariant();
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
if (!m_ColumnSelectionValues.isEmpty())
|
||||
return m_ColumnSelectionValues.at(column - 1);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
if (orientation == Qt::Vertical)
|
||||
{
|
||||
if (!m_RowSelectionValues.isEmpty())
|
||||
return m_RowSelectionValues.at(column - 1);
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
if (isEditMode())
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
else
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (isEditMode())
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
else
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
}
|
||||
return QAbstractTableModel::headerData(column, orientation, role);
|
||||
}
|
||||
|
||||
return QAbstractTableModel::headerData(column, orientation, role);
|
||||
}
|
||||
|
||||
|
||||
QVariant NumeralCodeModel::data(const QModelIndex &index, int role) const
|
||||
QVariant NumeralCodeModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if ((role == Qt::DisplayRole || role == Qt::EditRole))
|
||||
{
|
||||
|
||||
if ((index.column() == 0) && (index.row() == 0))
|
||||
return QVariant();
|
||||
|
||||
|
||||
if (index.row() == 0)
|
||||
if ((role == Qt::DisplayRole || role == Qt::EditRole))
|
||||
{
|
||||
if (!m_ColumnSelectionValues.isEmpty())
|
||||
return m_ColumnSelectionValues[index.column() - 1];
|
||||
return QChar::fromLatin1('?');
|
||||
|
||||
if ((index.column() == 0) && (index.row() == 0))
|
||||
return QVariant();
|
||||
|
||||
if (index.row() == 0)
|
||||
{
|
||||
if (!m_ColumnSelectionValues.isEmpty())
|
||||
return m_ColumnSelectionValues[index.column() - 1];
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
|
||||
if ((index.column() == 0))
|
||||
{
|
||||
if (!m_RowSelectionValues.isEmpty())
|
||||
return m_RowSelectionValues[index.row() - 1];
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
|
||||
if ((index.column() > 0) && (index.row() > 0))
|
||||
{
|
||||
return m_matrix[index.row() - 1][index.column() - 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((index.column() == 0))
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignCenter;
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (!m_RowSelectionValues.isEmpty())
|
||||
return m_RowSelectionValues[index.row() - 1];
|
||||
return QChar::fromLatin1('?');
|
||||
if ((index.row() > 0) && (index.column() > 0))
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
else
|
||||
{
|
||||
if (isEditMode())
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
else
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((index.column() > 0) && (index.row() > 0))
|
||||
if (role == Qt::ForegroundRole)
|
||||
{
|
||||
return m_matrix[index.row() - 1][index.column() - 1];
|
||||
if ((index.row() == 0) && (index.column() == 0))
|
||||
return QColor(Qt::red);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignCenter;
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if ((index.row() > 0) && (index.column() > 0))
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
else
|
||||
{
|
||||
if (isEditMode())
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
else
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::ForegroundRole)
|
||||
{
|
||||
if ((index.row() == 0) && (index.column() == 0))
|
||||
return QColor(Qt::red);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool NumeralCodeModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
bool NumeralCodeModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setData() row/col: " << index.row() << "/" << index.column()
|
||||
<< " char:" << value.toString();
|
||||
DEBUG_LOG(m_logger) << "setData() row/col: " << index.row() << "/" << index.column()
|
||||
<< " char:" << value.toString();
|
||||
|
||||
if (value.toString().contains(QLatin1Char('\"')) || value.toString().contains(QLatin1Char(';')))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget *>(parent()), tr("Inputs with the characters ; \" are not possible."), tr("Input Error"));
|
||||
return false;
|
||||
}
|
||||
if (value.toString().contains(QLatin1Char('\"')) || value.toString().contains(QLatin1Char(';')))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget*>(parent()),
|
||||
tr("Inputs with the characters ; \" are not possible."),
|
||||
tr("Input Error"));
|
||||
return false;
|
||||
}
|
||||
|
||||
QString tmp = value.toString();
|
||||
if (tmp.isEmpty())
|
||||
return false;
|
||||
QString tmp = value.toString();
|
||||
if (tmp.isEmpty())
|
||||
return false;
|
||||
|
||||
const QChar c = tmp.at(0);
|
||||
const QChar c = tmp.at(0);
|
||||
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
|
||||
if (index.row() == 0)
|
||||
m_ColumnSelectionValues[index.column() - 1] = c;
|
||||
|
||||
if (index.column() == 0 && (index.row() > 0))
|
||||
m_RowSelectionValues[index.row() - 1] = c;
|
||||
emit dataModified();
|
||||
}
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
if (index.row() == 0)
|
||||
m_ColumnSelectionValues[index.column() - 1] = c;
|
||||
|
||||
if (index.column() == 0 && (index.row() > 0))
|
||||
m_RowSelectionValues[index.row() - 1] = c;
|
||||
emit dataModified();
|
||||
}
|
||||
|
||||
Qt::ItemFlags NumeralCodeModel::flags(const QModelIndex &index) const
|
||||
return true;
|
||||
}
|
||||
|
||||
Qt::ItemFlags NumeralCodeModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
Qt::ItemFlags flags = QAbstractTableModel::flags(index);
|
||||
if (((index.row() == 0) && (index.column() > 0)) ||
|
||||
((index.row() > 0) && (index.column() == 0)))
|
||||
{
|
||||
if (isEditMode())
|
||||
flags |= Qt::ItemIsEditable;
|
||||
else
|
||||
flags &= ~Qt::ItemIsEditable;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
Qt::ItemFlags flags = QAbstractTableModel::flags(index);
|
||||
if (((index.row() == 0) && (index.column() > 0)) || ((index.row() > 0) && (index.column() == 0)))
|
||||
{
|
||||
if (isEditMode())
|
||||
flags |= Qt::ItemIsEditable;
|
||||
else
|
||||
flags &= ~Qt::ItemIsEditable;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
void NumeralCodeModel::initMatrix()
|
||||
{
|
||||
int lastMatrixValueCnt = 0;
|
||||
int lastMatrixCharacterCnt = 0;
|
||||
int lastMatrixCharacterIndex = 0;
|
||||
int numOfCharacter = 4;
|
||||
int lastMatrixValueCnt = 0;
|
||||
int lastMatrixCharacterCnt = 0;
|
||||
int lastMatrixCharacterIndex = 0;
|
||||
int numOfCharacter = 4;
|
||||
|
||||
for (int row = 0; row < 13; ++row)
|
||||
{
|
||||
|
||||
if (row > 3)
|
||||
for (int row = 0; row < 13; ++row)
|
||||
{
|
||||
numOfCharacter = 3;
|
||||
lastMatrixValueCnt -= 1;
|
||||
|
||||
if (row > 3)
|
||||
{
|
||||
numOfCharacter = 3;
|
||||
lastMatrixValueCnt -= 1;
|
||||
}
|
||||
|
||||
if (row == 9)
|
||||
lastMatrixCharacterIndex = 0;
|
||||
|
||||
for (int col = 0; col < 13; ++col)
|
||||
{
|
||||
if (lastMatrixValueCnt < 10)
|
||||
{
|
||||
m_matrix[row][col] = m_MatrixNumeralSet.at(lastMatrixValueCnt);
|
||||
lastMatrixValueCnt += 1;
|
||||
|
||||
if (lastMatrixValueCnt == 10)
|
||||
lastMatrixCharacterCnt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (row < 9)
|
||||
m_matrix[row][col] = m_MatrixCharacterSet1.at(lastMatrixCharacterIndex);
|
||||
else
|
||||
m_matrix[row][col] = m_MatrixCharacterSet2.at(lastMatrixCharacterIndex);
|
||||
lastMatrixCharacterCnt += 1;
|
||||
lastMatrixCharacterIndex += 1;
|
||||
|
||||
if (lastMatrixCharacterCnt == numOfCharacter)
|
||||
lastMatrixValueCnt = 0;
|
||||
}
|
||||
|
||||
if ((row < 9) && (lastMatrixCharacterIndex == 26))
|
||||
lastMatrixCharacterIndex = 0;
|
||||
|
||||
if ((row >= 9) && (lastMatrixCharacterIndex == 12))
|
||||
lastMatrixCharacterIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (row == 9)
|
||||
lastMatrixCharacterIndex = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int col = 0; col < 13; ++col)
|
||||
{
|
||||
if (lastMatrixValueCnt < 10)
|
||||
{
|
||||
m_matrix[row][col] = m_MatrixNumeralSet.at(lastMatrixValueCnt);
|
||||
lastMatrixValueCnt += 1;
|
||||
|
||||
if (lastMatrixValueCnt == 10)
|
||||
lastMatrixCharacterCnt = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (row < 9)
|
||||
m_matrix[row][col] = m_MatrixCharacterSet1.at(lastMatrixCharacterIndex);
|
||||
else
|
||||
m_matrix[row][col] = m_MatrixCharacterSet2.at(lastMatrixCharacterIndex);
|
||||
lastMatrixCharacterCnt += 1;
|
||||
lastMatrixCharacterIndex += 1;
|
||||
|
||||
if (lastMatrixCharacterCnt == numOfCharacter)
|
||||
lastMatrixValueCnt = 0;
|
||||
}
|
||||
|
||||
|
||||
if ((row < 9) && (lastMatrixCharacterIndex == 26))
|
||||
lastMatrixCharacterIndex = 0;
|
||||
|
||||
|
||||
if ((row >= 9) && (lastMatrixCharacterIndex == 12))
|
||||
lastMatrixCharacterIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void NumeralCodeModel::onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
void NumeralCodeModel::onCodificationDataChanged(const CodificationManagement::CodificationData& data,
|
||||
DataModification modType)
|
||||
{
|
||||
const int id = data.id();
|
||||
const int id = data.id();
|
||||
|
||||
DEBUG_LOG(m_logger) << "onCodificationDataChanged for CodificationData id: " << id
|
||||
<< " - NumCodeColumnIdx data: " << data.numeralCodeTableColumnIndex().c_str()
|
||||
<< " - NumCodeRowIdx data: " << data.numeralCodeTableRowIndex().c_str()
|
||||
<< " - modType: " << (int)modType;
|
||||
DEBUG_LOG(m_logger) << "onCodificationDataChanged for CodificationData id: " << id
|
||||
<< " - NumCodeColumnIdx data: " << data.numeralCodeTableColumnIndex().c_str()
|
||||
<< " - NumCodeRowIdx data: " << data.numeralCodeTableRowIndex().c_str()
|
||||
<< " - modType: " << (int)modType;
|
||||
|
||||
if (m_codificationDataId != data.id())
|
||||
return;
|
||||
if (m_codificationDataId != data.id())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "CodificationData was removed. id: " << id << " ToDo: 'ShowCodificationData' Tab loeschen !?";
|
||||
setColumnSelectionValuesCSV(QString());
|
||||
setRowSelectionValuesCSV(QString());
|
||||
return;
|
||||
}
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "CodificationData was removed. id: " << id
|
||||
<< " ToDo: 'ShowCodificationData' Tab loeschen !?";
|
||||
setColumnSelectionValuesCSV(QString());
|
||||
setRowSelectionValuesCSV(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationData was modifed. id: " << id << " - " << data.note();
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationData was modifed. id: " << id << " - " << data.note();
|
||||
|
||||
QString qs = QString::fromStdString(data.numeralCodeTableColumnIndex());
|
||||
setColumnSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(data.numeralCodeTableRowIndex());
|
||||
setRowSelectionValuesCSV(qs);
|
||||
}
|
||||
}
|
||||
QString qs = QString::fromStdString(data.numeralCodeTableColumnIndex());
|
||||
setColumnSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(data.numeralCodeTableRowIndex());
|
||||
setRowSelectionValuesCSV(qs);
|
||||
}
|
||||
}
|
||||
Executable → Regular
+38
-75
@@ -1,111 +1,74 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <CodificationManagement/cod_dtc.h>
|
||||
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class NumeralCodeModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NumeralCodeModel(QWidget *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NumeralCodeModel(QWidget* parent);
|
||||
|
||||
~NumeralCodeModel() = default;
|
||||
~NumeralCodeModel() = default;
|
||||
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc, int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
void resetHeader();
|
||||
|
||||
|
||||
bool setColumnSelectionValuesCSV(const QString& csvData);
|
||||
|
||||
void resetHeader();
|
||||
bool setRowSelectionValuesCSV(const QString& csvData);
|
||||
|
||||
|
||||
QString getHorizontalHeaderCSVString() const;
|
||||
|
||||
bool setColumnSelectionValuesCSV(const QString &csvData);
|
||||
QString getVerticalHeaderCSVString() const;
|
||||
|
||||
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
|
||||
bool setRowSelectionValuesCSV(const QString &csvData);
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
QString getHorizontalHeaderCSVString() const;
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
|
||||
QString getVerticalHeaderCSVString() const;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role) override;
|
||||
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
Q_SIGNALS:
|
||||
|
||||
|
||||
void dataModified();
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData& data, DataModification modType);
|
||||
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
void initMatrix();
|
||||
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
QVector<QChar> m_MatrixNumeralSet;
|
||||
QVector<QChar> m_MatrixCharacterSet1;
|
||||
QVector<QChar> m_MatrixCharacterSet2;
|
||||
|
||||
|
||||
QChar m_matrix[13][13];
|
||||
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
QVector<QChar> m_RowSelectionValues;
|
||||
QVector<QChar> m_ColumnSelectionValues;
|
||||
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
|
||||
|
||||
void dataModified();
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
void initMatrix();
|
||||
|
||||
QVector <QChar> m_MatrixNumeralSet;
|
||||
QVector <QChar> m_MatrixCharacterSet1;
|
||||
QVector <QChar> m_MatrixCharacterSet2;
|
||||
|
||||
QChar m_matrix[13][13];
|
||||
|
||||
QVector <QChar> m_RowSelectionValues;
|
||||
QVector <QChar> m_ColumnSelectionValues;
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
int m_codificationDataId;
|
||||
bool m_isEditMode;
|
||||
int m_codificationDataId;
|
||||
bool m_isEditMode;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace CodificationManagement
|
||||
Executable → Regular
+199
-224
@@ -1,301 +1,276 @@
|
||||
|
||||
|
||||
|
||||
|
||||
#include "cod_phrase_table_model.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.h>
|
||||
#include <QGuiApplication>
|
||||
#include <QPalette>
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
PhraseTableModel::PhraseTableModel(QWidget *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
, m_dtc(nullptr)
|
||||
, m_codificationDataId(0)
|
||||
, m_isEditMode(false)
|
||||
PhraseTableModel::PhraseTableModel(QWidget* parent)
|
||||
: QAbstractTableModel(parent), m_dtc(nullptr), m_codificationDataId(0), m_isEditMode(false)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ctor PhraseTableModel";
|
||||
DEBUG_LOG(m_logger) << "ctor PhraseTableModel";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool PhraseTableModel::init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode)
|
||||
bool PhraseTableModel::init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc, int codificationDataId,
|
||||
bool isEditMode)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "PhraseTableModel::init()";
|
||||
if (!dtc)
|
||||
return false;
|
||||
DEBUG_LOG(m_logger) << "PhraseTableModel::init()";
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_isEditMode = isEditMode;
|
||||
m_dtc = dtc;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_isEditMode = isEditMode;
|
||||
|
||||
|
||||
resetMatrix();
|
||||
|
||||
if (!isEditMode)
|
||||
{
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged,
|
||||
this, &PhraseTableModel::onCodificationDataChanged);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
resetMatrix();
|
||||
|
||||
if (!isEditMode)
|
||||
{
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged, this,
|
||||
&PhraseTableModel::onCodificationDataChanged);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PhraseTableModel::resetMatrix()
|
||||
{
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
if ((row == 0) && (column == 0))
|
||||
{
|
||||
m_matrix[row][column] = QLatin1String("A-Warnung ");
|
||||
}
|
||||
if ((row == 1) && (column == 0))
|
||||
{
|
||||
m_matrix[row][column] = QLatin1String("B-Warnung ");
|
||||
}
|
||||
if ((row == 2) && (column == 0))
|
||||
{
|
||||
m_matrix[row][column] = QLatin1String("C-Warnung ");
|
||||
}
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
{
|
||||
if ((row == 0) && (column == 0))
|
||||
{
|
||||
m_matrix[row][column] = QLatin1String("A-Warnung ");
|
||||
}
|
||||
if ((row == 1) && (column == 0))
|
||||
{
|
||||
m_matrix[row][column] = QLatin1String("B-Warnung ");
|
||||
}
|
||||
if ((row == 2) && (column == 0))
|
||||
{
|
||||
m_matrix[row][column] = QLatin1String("C-Warnung ");
|
||||
}
|
||||
|
||||
if ((row <= 2 && column > 0) || (row > 2))
|
||||
m_matrix[row][column] = QLatin1String("--- ");
|
||||
if ((row <= 2 && column > 0) || (row > 2))
|
||||
m_matrix[row][column] = QLatin1String("--- ");
|
||||
}
|
||||
}
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
return ;
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool PhraseTableModel::setMatrixValuesCSV(const QString &csvData)
|
||||
bool PhraseTableModel::setMatrixValuesCSV(const QString& csvData)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setMatrixValuesCSV() data: " << csvData;
|
||||
DEBUG_LOG(m_logger) << "setMatrixValuesCSV() data: " << csvData;
|
||||
|
||||
const QVector<QStringRef> slRows = csvData.splitRef(QLatin1Char('\n'));
|
||||
if (slRows.count() != rowCount())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid row data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << rowCount() << "/" << slRows.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
const QStringList slColumns = splitQuotedString(QLatin1Char(';'), slRows[row].toString());
|
||||
if (slColumns.count() != columnCount())
|
||||
const QVector<QStringRef> slRows = csvData.splitRef(QLatin1Char('\n'));
|
||||
if (slRows.count() != rowCount())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << columnCount() << "/" << slColumns.size();
|
||||
return false;
|
||||
ERROR_LOG(m_logger) << "Invalid row data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << rowCount() << "/" << slRows.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
m_matrix[row][column] = slColumns[column];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const QStringList slColumns = splitQuotedString(QLatin1Char(';'), slRows[row].toString());
|
||||
if (slColumns.count() != columnCount())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Invalid column data count." << " codificationDataId: " << m_codificationDataId
|
||||
<< " Soll/Ist: " << columnCount() << "/" << slColumns.size();
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
{
|
||||
m_matrix[row][column] = slColumns[column];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
QString PhraseTableModel::getMatrixDataCSVString() const
|
||||
{
|
||||
QStringList slColumns;
|
||||
slColumns.reserve(columnCount());
|
||||
QStringList slRows;
|
||||
slRows.reserve(rowCount() * columnCount());
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
slColumns.clear();
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
QStringList slColumns;
|
||||
slColumns.reserve(columnCount());
|
||||
QStringList slRows;
|
||||
slRows.reserve(rowCount() * columnCount());
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
const QString &cell = m_matrix[row][column];
|
||||
if (cell.contains(QLatin1Char(';')))
|
||||
slColumns += QLatin1Char('\"') + cell + QLatin1Char('\"');
|
||||
else
|
||||
slColumns += cell;
|
||||
slColumns.clear();
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
{
|
||||
const QString& cell = m_matrix[row][column];
|
||||
if (cell.contains(QLatin1Char(';')))
|
||||
slColumns += QLatin1Char('\"') + cell + QLatin1Char('\"');
|
||||
else
|
||||
slColumns += cell;
|
||||
}
|
||||
slRows << slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
slRows << slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
return slRows.join(QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
return slRows.join(QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
void PhraseTableModel::setEditMode(bool isEditMode)
|
||||
{
|
||||
m_isEditMode = isEditMode;
|
||||
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
}
|
||||
m_isEditMode = isEditMode;
|
||||
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
}
|
||||
|
||||
bool PhraseTableModel::isEditMode() const
|
||||
{
|
||||
return m_isEditMode;
|
||||
}
|
||||
return m_isEditMode;
|
||||
}
|
||||
|
||||
|
||||
int PhraseTableModel::rowCount(const QModelIndex &parent) const
|
||||
int PhraseTableModel::rowCount(const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 13;
|
||||
}
|
||||
Q_UNUSED(parent)
|
||||
return 13;
|
||||
}
|
||||
|
||||
|
||||
int PhraseTableModel::columnCount(const QModelIndex &parent) const
|
||||
int PhraseTableModel::columnCount(const QModelIndex& parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 2;
|
||||
}
|
||||
|
||||
Q_UNUSED(parent)
|
||||
return 2;
|
||||
}
|
||||
|
||||
QVariant PhraseTableModel::headerData(int column, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QAbstractTableModel::headerData(column, orientation, role);
|
||||
if (role != Qt::DisplayRole)
|
||||
return QAbstractTableModel::headerData(column, orientation, role);
|
||||
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
QVariant PhraseTableModel::data(const QModelIndex &index, int role) const
|
||||
QVariant PhraseTableModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
if ((role == Qt::DisplayRole || role == Qt::EditRole))
|
||||
{
|
||||
|
||||
|
||||
return m_matrix[index.row()][index.column()];
|
||||
}
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignCenter;
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if ((index.row() <= rowCount()-1) && (index.column() <= columnCount() - 1))
|
||||
if ((role == Qt::DisplayRole || role == Qt::EditRole))
|
||||
{
|
||||
if (m_isEditMode)
|
||||
{
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
}
|
||||
else
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
return m_matrix[index.row()][index.column()];
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignCenter;
|
||||
|
||||
bool PhraseTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "setData() row/col: " << index.row() << "/" << index.column()
|
||||
<< " value:" << value.toString();
|
||||
|
||||
|
||||
if (value.toString().contains(QLatin1Char('\"')) || value.toString().contains(QLatin1Char(';')))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget *>(parent()), tr("Inputs with the characters ; \" are not possible."), tr("Input Error"));
|
||||
return false;
|
||||
}
|
||||
|
||||
QString qs = value.toString();
|
||||
if (qs.isEmpty())
|
||||
return false;
|
||||
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
if ((index.row() <= rowCount()-1) && (index.column() <= columnCount() - 1))
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
m_matrix[index.row()][index.column()] = qs;
|
||||
emit dataModified();
|
||||
if ((index.row() <= rowCount() - 1) && (index.column() <= columnCount() - 1))
|
||||
{
|
||||
if (m_isEditMode)
|
||||
{
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase);
|
||||
}
|
||||
else
|
||||
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
Qt::ItemFlags PhraseTableModel::flags(const QModelIndex &index) const
|
||||
bool PhraseTableModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
Qt::ItemFlags flags = QAbstractTableModel::flags(index);
|
||||
DEBUG_LOG(m_logger) << "setData() row/col: " << index.row() << "/" << index.column()
|
||||
<< " value:" << value.toString();
|
||||
|
||||
if (isEditMode())
|
||||
{
|
||||
if ((index.row() <= rowCount()-1) && (index.column() <= columnCount() - 1))
|
||||
flags |= Qt::ItemIsEditable;
|
||||
if (value.toString().contains(QLatin1Char('\"')) || value.toString().contains(QLatin1Char(';')))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(qobject_cast<QWidget*>(parent()),
|
||||
tr("Inputs with the characters ; \" are not possible."),
|
||||
tr("Input Error"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if ((index.column() == 0) && (index.row() <= 2))
|
||||
flags &= ~Qt::ItemIsEditable;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((index.row() <= rowCount()-1) && (index.column() <= columnCount() - 1))
|
||||
flags &= ~Qt::ItemIsEditable;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
QString qs = value.toString();
|
||||
if (qs.isEmpty())
|
||||
return false;
|
||||
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
if ((index.row() <= rowCount() - 1) && (index.column() <= columnCount() - 1))
|
||||
{
|
||||
m_matrix[index.row()][index.column()] = qs;
|
||||
emit dataModified();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void PhraseTableModel::onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType)
|
||||
Qt::ItemFlags PhraseTableModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
const int id = data.id();
|
||||
Qt::ItemFlags flags = QAbstractTableModel::flags(index);
|
||||
|
||||
DEBUG_LOG(m_logger) << "onCodificationDataChanged for CodificationData id: " << id
|
||||
<< " - PhraseTableModel data: " << data.phraseTable().c_str()
|
||||
<< " - modType: " << (int)modType;
|
||||
if (isEditMode())
|
||||
{
|
||||
if ((index.row() <= rowCount() - 1) && (index.column() <= columnCount() - 1))
|
||||
flags |= Qt::ItemIsEditable;
|
||||
|
||||
if (m_codificationDataId != data.id())
|
||||
return;
|
||||
if ((index.column() == 0) && (index.row() <= 2))
|
||||
flags &= ~Qt::ItemIsEditable;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((index.row() <= rowCount() - 1) && (index.column() <= columnCount() - 1))
|
||||
flags &= ~Qt::ItemIsEditable;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "CodificationData was removed. id: " << id << " ToDo: 'ShowCodificationData' Tab loeschen !?";
|
||||
|
||||
resetMatrix();
|
||||
return;
|
||||
}
|
||||
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationData was modifed. id: " << id << " - " << data.note();
|
||||
|
||||
QString qs = QString::fromStdString(data.phraseTable());
|
||||
setMatrixValuesCSV(qs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QStringList PhraseTableModel::splitQuotedString(const QChar &sep, const QString &inString)
|
||||
void PhraseTableModel::onCodificationDataChanged(const CodificationManagement::CodificationData& data,
|
||||
DataModification modType)
|
||||
{
|
||||
QString str = inString;
|
||||
QStringList result;
|
||||
const int id = data.id();
|
||||
|
||||
while (str.contains(QLatin1Char('\"')))
|
||||
{
|
||||
int i = str.indexOf(QLatin1Char('\"'));
|
||||
QString part = str.left(i);
|
||||
DEBUG_LOG(m_logger) << "onCodificationDataChanged for CodificationData id: " << id
|
||||
<< " - PhraseTableModel data: " << data.phraseTable().c_str() << " - modType: " << (int)modType;
|
||||
|
||||
result += part.split(sep, QString::SkipEmptyParts);
|
||||
if (m_codificationDataId != data.id())
|
||||
return;
|
||||
|
||||
str.remove(0, i + 1);
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "CodificationData was removed. id: " << id
|
||||
<< " ToDo: 'ShowCodificationData' Tab loeschen !?";
|
||||
|
||||
i = str.indexOf(QLatin1Char('\"'));
|
||||
resetMatrix();
|
||||
return;
|
||||
}
|
||||
|
||||
result += str.left(i);
|
||||
str.remove(0,i + 1);
|
||||
}
|
||||
result += str.split(sep, QString::SkipEmptyParts);
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationData was modifed. id: " << id << " - " << data.note();
|
||||
|
||||
return result;
|
||||
}
|
||||
QString qs = QString::fromStdString(data.phraseTable());
|
||||
setMatrixValuesCSV(qs);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList PhraseTableModel::splitQuotedString(const QChar& sep, const QString& inString)
|
||||
{
|
||||
QString str = inString;
|
||||
QStringList result;
|
||||
|
||||
while (str.contains(QLatin1Char('\"')))
|
||||
{
|
||||
int i = str.indexOf(QLatin1Char('\"'));
|
||||
QString part = str.left(i);
|
||||
|
||||
result += part.split(sep, QString::SkipEmptyParts);
|
||||
|
||||
str.remove(0, i + 1);
|
||||
|
||||
i = str.indexOf(QLatin1Char('\"'));
|
||||
|
||||
result += str.left(i);
|
||||
str.remove(0, i + 1);
|
||||
}
|
||||
result += str.split(sep, QString::SkipEmptyParts);
|
||||
|
||||
return result;
|
||||
}
|
||||
Executable → Regular
+32
-72
@@ -1,104 +1,64 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <CodificationManagement/cod_dtc.h>
|
||||
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class PhraseTableModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PhraseTableModel(QWidget *parent);
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PhraseTableModel(QWidget* parent);
|
||||
|
||||
~PhraseTableModel() = default;
|
||||
~PhraseTableModel() = default;
|
||||
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc>& dtc, int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
void resetMatrix();
|
||||
|
||||
|
||||
bool setMatrixValuesCSV(const QString& csvData);
|
||||
|
||||
void resetMatrix();
|
||||
QString getMatrixDataCSVString() const;
|
||||
|
||||
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
|
||||
bool setMatrixValuesCSV(const QString &csvData);
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
|
||||
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
|
||||
QString getMatrixDataCSVString() const;
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
|
||||
QVariant data(const QModelIndex& index, int role) const override;
|
||||
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
bool setData(const QModelIndex& index, const QVariant& value, int role) override;
|
||||
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
Q_SIGNALS:
|
||||
|
||||
|
||||
void dataModified();
|
||||
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData& data, DataModification modType);
|
||||
|
||||
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
QStringList splitQuotedString(const QChar& sep, const QString& inString);
|
||||
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
private:
|
||||
QString m_matrix[13][2];
|
||||
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
|
||||
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
|
||||
|
||||
void dataModified();
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
QStringList splitQuotedString(const QChar &sep, const QString &inString);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QString m_matrix[13][2];
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
int m_codificationDataId;
|
||||
bool m_isEditMode;
|
||||
int m_codificationDataId;
|
||||
bool m_isEditMode;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Reference in new issue
Block a user