Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+29
@@ -0,0 +1,29 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by hjl, SLSE, 2016-12-01
|
||||
#
|
||||
|
||||
|
||||
ADD_SUBDIRECTORY(Data)
|
||||
ADD_SUBDIRECTORY(Gui)
|
||||
|
||||
#
|
||||
# Data Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(CodDataPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cod_data_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
DataPluginInterface
|
||||
svcCodCommon
|
||||
)
|
||||
|
||||
#
|
||||
# Gui Plugin Interface
|
||||
#
|
||||
ADD_INTERFACE_LIBRARY(CodGuiPluginInterface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cod_gui_plugin_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/..
|
||||
GuiPluginInterface
|
||||
)
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by hjl, SLSE, 2016-12-01
|
||||
#
|
||||
|
||||
#
|
||||
# Data Plugin
|
||||
#
|
||||
NGL_ADD_LIBRARY2(WS CodDataPlugin MODULE cod_data_plugin.cpp cod_data_plugin.h)
|
||||
NGL_TARGET_LINK_LIBRARIES(CodDataPlugin
|
||||
Qt5::Core
|
||||
CodDataPluginInterface
|
||||
svcCodClient
|
||||
NGLLogger
|
||||
LtsSessionDataDds
|
||||
)
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for CodificationManangement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-01
|
||||
*/
|
||||
|
||||
#include "cod_data_plugin.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <LtsSession/lts_session_data_dds.h>
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
std::shared_ptr<DataPluginBase::Interface> DataPlugin::createDataInterface(LtsSession::LtsSessionDataDds *session)
|
||||
{
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> dtc;
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> ftc;
|
||||
|
||||
if (!session->createTopicClient(dtc, ftc))
|
||||
return std::shared_ptr<DataPluginBase::Interface>();
|
||||
|
||||
return std::make_shared<DataInterfaceImpl>(dtc, ftc);
|
||||
}
|
||||
|
||||
DataInterfaceImpl::DataInterfaceImpl(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc> &ftc)
|
||||
: DataInterface()
|
||||
, m_dtc(dtc)
|
||||
, m_ftc(ftc)
|
||||
{}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Data Plugin for CodificationManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-01
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <Plugins/CodificationManagement/cod_data_plugin_interface.h>
|
||||
|
||||
#include <CodificationManagement/cod_dtc.h>
|
||||
#include <CodificationManagement/cod_ftc.h>
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class DataPlugin final : public QObject, public DataPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "data:3:cod")
|
||||
Q_INTERFACES(DataPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
DataPlugin() = default;
|
||||
~DataPlugin() = default;
|
||||
|
||||
QString pluginName() const override { return QStringLiteral("CodificationManagement"); }
|
||||
std::shared_ptr<DataPluginBase::Interface> createDataInterface(LtsSession::LtsSessionDataDds *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise; }
|
||||
};
|
||||
|
||||
|
||||
class DataInterfaceImpl final : public DataInterface
|
||||
{
|
||||
public:
|
||||
DataInterfaceImpl(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc> &ftc);
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> getDtc() override { return m_dtc; }
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> getFtc() override { return m_ftc; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> m_ftc;
|
||||
};
|
||||
|
||||
} // namespace CodificationManagement
|
||||
@@ -0,0 +1,7 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(CodificationData)
|
||||
@@ -0,0 +1,67 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by hjl, SLSE, 2016-12-01
|
||||
#
|
||||
|
||||
FIND_PACKAGE(KDReports REQUIRED)
|
||||
|
||||
SET(cod_codification_data_gui_SRCS
|
||||
cod_codification_data_gui_plugin.h
|
||||
cod_codification_data_gui_plugin.cpp
|
||||
cod_codification_data_overview_view.h
|
||||
cod_codification_data_overview_view.cpp
|
||||
cod_codification_data_overview_model.h
|
||||
cod_codification_data_overview_model.cpp
|
||||
cod_codification_data_table_view.h
|
||||
cod_codification_data_table_view.cpp
|
||||
cod_codification_data_table_edit_view.h
|
||||
cod_codification_data_table_edit_view.cpp
|
||||
cod_codification_data_report.h
|
||||
cod_codification_data_report.cpp
|
||||
cod_csv_export.h
|
||||
cod_csv_export.cpp
|
||||
cod_csv_import.h
|
||||
cod_csv_import.cpp
|
||||
cod_code_table_edit_delegate.h
|
||||
cod_code_table_edit_delegate.cpp
|
||||
cod_numeral_code_model.h
|
||||
cod_numeral_code_model.cpp
|
||||
cod_authentication_code_model.h
|
||||
cod_authentication_code_model.cpp
|
||||
cod_logistical_terms_model.h
|
||||
cod_logistical_terms_model.cpp
|
||||
cod_phrase_table_model.h
|
||||
cod_phrase_table_model.cpp
|
||||
cod_assign_codification_data_table.h
|
||||
cod_assign_codification_data_table.cpp
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(cod_codification_data_gui_SRCS
|
||||
cod_codification_data_overview_view.ui
|
||||
cod_codification_data_table_view.ui
|
||||
cod_assign_codification_data_table.ui
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(WS CodCodificationDataGuiPlugin MODULE ${cod_codification_data_gui_SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(CodCodificationDataGuiPlugin
|
||||
LtsPrinting
|
||||
NGLLogger
|
||||
LtsSession
|
||||
LtsSessionData
|
||||
LtsPrinting
|
||||
CodGuiPluginInterface
|
||||
CodDataPluginInterface
|
||||
PpmDataPluginInterface
|
||||
Qt5::Widgets
|
||||
KDReports::KDReports
|
||||
LtsWidgets
|
||||
LtsDataView
|
||||
LtsUtilsGuiDds
|
||||
FlmDataPluginInterface
|
||||
ngltools
|
||||
LtsUtilsSettings
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(CodCodificationDataGuiPlugin)
|
||||
Executable
+213
@@ -0,0 +1,213 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Codification data table assign dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, NLSE, 2018-05-14
|
||||
*/
|
||||
|
||||
#include "cod_assign_codification_data_table.h"
|
||||
#include "cod_codification_data_overview_model.h"
|
||||
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <LtsSession/lts_session_data.h>
|
||||
#include <QLabel>
|
||||
|
||||
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))
|
||||
, m_logger(getLogger("AssignCodificationDataTable"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Assign_Codification_Data"));
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
AssignCodificationDataTable::~AssignCodificationDataTable()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_requestHelper;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AssignCodificationDataTable::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Assign Codification Data"));
|
||||
} // end of retranslate()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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()";
|
||||
|
||||
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; // alle fuer den User sichtbaren Truppen in der akt. Uebung
|
||||
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 : qAsConst(userVisibleParties)) // alle Truppen der akt. Uebung
|
||||
{
|
||||
// Es werden nur die Truppen ROT (OPFOR / Leitungstruppe) mit der id:2 und BLAU (BLUFOR / Uebungstruppe) mit der id:3 genutzt.
|
||||
if (party.id() != 2 && party.id() != 3)
|
||||
continue;
|
||||
|
||||
// Truppennamen speziell fuer GUEZ anpassen
|
||||
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);
|
||||
|
||||
// Akt. Zuordnung ermitteln
|
||||
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;
|
||||
}
|
||||
m_ui->partyLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Preferred, QSizePolicy::Expanding),
|
||||
i, 1);
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AssignCodificationDataTable::apply()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "AssignCodificationDataTable::apply()";
|
||||
|
||||
removeAllAssignments();
|
||||
|
||||
bool bStartRequests = false;
|
||||
for (LtsWidgets::LtsComboBox *cb : qAsConst(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)
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("All parties must be assigned to a valid coding table."));
|
||||
return false;
|
||||
}
|
||||
// Es kann immer nur eine Sprechtafel fuer eine PartyId gueltig sein.
|
||||
// Da in CodificationData z.Zt. nur eine PartyId gespeichert werden kann.
|
||||
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);
|
||||
// does not work due to removeAllAssignments() above
|
||||
//if (codDdsData.partyId() == partyId)
|
||||
// continue;
|
||||
|
||||
bStartRequests = true;
|
||||
codDdsData.partyId(partyId);
|
||||
m_requestHelper->addRequest([this, codDdsData]()
|
||||
{
|
||||
return m_ftc->codificationDataModifyRequest(codDdsData, this);
|
||||
});
|
||||
|
||||
}
|
||||
if (!bStartRequests)
|
||||
return true;
|
||||
return m_requestHelper->startRequests();
|
||||
} // end of apply()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AssignCodificationDataTable::removeAllAssignments()
|
||||
{
|
||||
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]()
|
||||
{
|
||||
return m_ftc->codificationDataModifyRequest(codData, this);
|
||||
});
|
||||
}
|
||||
if (!bStartRequests)
|
||||
return true;
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
} // end of removeAllAssignments()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AssignCodificationDataTable::isTableAlreadyAssigned(int codTableId) const
|
||||
{
|
||||
const CodificationManagement::CodificationData &codData = m_dtc->codificationData(codTableId);
|
||||
return codData.partyId() > 0;
|
||||
} // end of isTableAlreadyAssigned()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
Executable
+80
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Codification data table assign dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, NLSE, 2018-05-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "ui_cod_assign_codification_data_table.h"
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsWidgets/lts_combo_box.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <Services/CodificationManagement/cod_dtc.h>
|
||||
#include <Services/CodificationManagement/cod_ftc.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class AssignCodificationDataTable;
|
||||
}
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
class CodificationDataOverviewModel;
|
||||
|
||||
class AssignCodificationDataTable : public LtsWidgets::LtsDialog,
|
||||
protected CodificationManagement::Interface::Ftc::CodificationDataModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AssignCodificationDataTable(QWidget *parent = nullptr);
|
||||
|
||||
~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);
|
||||
|
||||
//virtual functions from CodificationManagement::Interface::Ftc
|
||||
void onCodificationDataModifyReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* Override the accept function from LtsDialog to save a modified edit dialog when the widget is closed.
|
||||
*/
|
||||
bool apply() override;
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
|
||||
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;
|
||||
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AssignCodificationDataTable</class>
|
||||
<widget class="QWidget" name="AssignCodificationDataTable">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>553</width>
|
||||
<height>396</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Assign Codification Data Table</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="partyLayout"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Executable
+268
@@ -0,0 +1,268 @@
|
||||
/**
|
||||
* Model for authentication code table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-01-05
|
||||
*/
|
||||
|
||||
|
||||
#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)
|
||||
, m_logger(getLogger("AuthenticationCodeTableModel"))
|
||||
{
|
||||
memset(m_matrix, 0, sizeof m_matrix);
|
||||
DEBUG_LOG(m_logger) << "ctor AuthenticationCodeModel";
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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()...";
|
||||
|
||||
m_dtc = dtc;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_isEditMode = isEditMode;
|
||||
|
||||
// constant Header values...
|
||||
m_ColumnSelectionValues.resize(5);
|
||||
for (char i = 0; i < 5; ++i)
|
||||
m_ColumnSelectionValues[i] = QLatin1Char('V' + i);
|
||||
|
||||
// constant Header values...
|
||||
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;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AuthenticationCodeModel::resetMatrix()
|
||||
{
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
for (int column = 0; column < columnCount(); ++column)
|
||||
{
|
||||
m_matrix[row][column] = 0;
|
||||
}
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
return ;
|
||||
} // end of resetMatrix()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AuthenticationCodeModel::setMatrixValuesCSV(const QString &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())
|
||||
{
|
||||
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;
|
||||
} // end of setMatrixValuesCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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)
|
||||
{
|
||||
slColumns << QStringLiteral("%1").arg(m_matrix[row][column], 2, 10, QLatin1Char('0'));
|
||||
}
|
||||
slRows << slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
return slRows.join(QLatin1Char('\n'));
|
||||
} // end of getMatrixDataCSVString()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AuthenticationCodeModel::setEditMode(bool isEditMode)
|
||||
{
|
||||
m_isEditMode = isEditMode;
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
} // end of setEditMode()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool AuthenticationCodeModel::isEditMode() const
|
||||
{
|
||||
return m_isEditMode;
|
||||
} // end of isEditMode();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int AuthenticationCodeModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 13; // Matrixgroesse
|
||||
} // end of rowCount()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int AuthenticationCodeModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 5; // Matrixgroesse
|
||||
} // end of columnCount()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant AuthenticationCodeModel::headerData(int column, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
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);
|
||||
} // end of headerData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant AuthenticationCodeModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if ((role == Qt::DisplayRole || role == Qt::EditRole))
|
||||
{
|
||||
// DEBUG_LOG(m_logger) << "data() display role row: " <<index.row() << " col: " << index.column();
|
||||
return QStringLiteral("%1").arg(m_matrix[index.row()][index.column()], 2, 10, QLatin1Char('0'));
|
||||
}
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignCenter;
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (m_isEditMode)
|
||||
// group ist hier egal, liefert immer die selbe Farbe
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase); // RDE_LIGHTER_GRAY
|
||||
else
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base); // RDE_GRAY
|
||||
}
|
||||
return QVariant();
|
||||
} // end of data()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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();
|
||||
|
||||
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 (role == Qt::EditRole)
|
||||
{
|
||||
m_matrix[index.row()][index.column()] = val;
|
||||
emit dataModified();
|
||||
}
|
||||
return true;
|
||||
} // end of setData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Qt::ItemFlags AuthenticationCodeModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
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;
|
||||
} // end of flags()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AuthenticationCodeModel::onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType)
|
||||
{
|
||||
const int id = data.id();
|
||||
|
||||
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 (modType == DataModification::eRemoved)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "CodificationData was removed. id: " << id << " ToDo: 'ShowCodificationData' Tab loeschen !?";
|
||||
// set matrix to default values
|
||||
resetMatrix();
|
||||
return;
|
||||
}
|
||||
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationData was modifed. id: " << id << " - " << data.note();
|
||||
|
||||
QString qs = QString::fromStdString(data.authenticationTableMatirx());
|
||||
setMatrixValuesCSV(qs);
|
||||
}
|
||||
} // end of onCodificationDataChanged()
|
||||
//-----------------------------------------------------------------------------
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* Model for authentication code table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-01-05
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <CodificationManagement/cod_dtc.h>
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class AuthenticationCodeModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AuthenticationCodeModel(QObject *parent);
|
||||
|
||||
/**
|
||||
* init model internal data matrix
|
||||
* @param dtc access to Data Topic Client
|
||||
* @param codificationDataId id of the used codification data set
|
||||
* @param isEditMode true means model used for edit, otherwise used for show only
|
||||
* in edit mode non update will be done by external data change
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
|
||||
/**
|
||||
* set the 13x5 code matrix to zero
|
||||
*/
|
||||
void resetMatrix();
|
||||
|
||||
/**
|
||||
* set matrix values
|
||||
* The formatting of the data must correspond to the appearance of the table!
|
||||
* @param data reference to int data set of matrix values
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool setMatrixValuesCSV(const QString &csvData);
|
||||
|
||||
/**
|
||||
* get matrix data in csv format.
|
||||
* The formatting of the data corresponds to the appearance of the table
|
||||
* @param -
|
||||
* @return Returns matrix data in csv format;
|
||||
*/
|
||||
QString getMatrixDataCSVString() const;
|
||||
|
||||
/**
|
||||
* set/get edit mode flag used for internal data handling
|
||||
* @param isEditMode true means set edit mode
|
||||
* @return Returns true if edit mode is set, otherwise false
|
||||
*/
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
|
||||
/**
|
||||
* get the row count (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return int Returns the count
|
||||
*/
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
/**
|
||||
* get the row column (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return int Returns the count
|
||||
*/
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
/**
|
||||
* get the header data (MVC-model)
|
||||
* @param section (column)
|
||||
* @param Qt::Orientation
|
||||
* @param role
|
||||
* @return QVariant
|
||||
*/
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
/**
|
||||
* get the data (MVC-model)
|
||||
* @param QModelIndex
|
||||
* @return QVariant
|
||||
*/
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
/**
|
||||
* set the data (MVC-model)
|
||||
* @param QModelIndex
|
||||
* @return bool Returns true if successfull, otherwise returns false
|
||||
*/
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
/**
|
||||
* get flags for the given QModelIndex (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return flags Returns the flags
|
||||
*/
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
/**
|
||||
* emits when data was changed (used to enable add/okay button)
|
||||
*/
|
||||
void dataModified();
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* set the 13x5 code matrix to
|
||||
* @param data reference to character set of row selection values
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
void setMatrix(const QVector <int> &data);
|
||||
|
||||
int m_matrix[13][5]; ///< Hold the authentication code table (without row/column selcet index fields)
|
||||
|
||||
QVector <QChar> m_RowSelectionValues; ///< Hold the row selection index field character
|
||||
QVector <QChar> m_ColumnSelectionValues; ///< Hold the column selection index field character
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
int m_codificationDataId; ///< Id of the used codification data set
|
||||
bool m_isEditMode; ///< Hold the dialog mode setting; if true the indices in row 0 and column 0 can be modified
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* manages edit inputs from code models
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-01-12
|
||||
*/
|
||||
|
||||
#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(getLogger("CodeTableEditDelegate"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodeTableEditDelegate::ctor()";
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QWidget *CodeTableEditDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodeTableEditDelegate::createEditor() TableType: " << m_tableType
|
||||
<< " rox/column: " << index.row() << "/" << index.column() ;
|
||||
|
||||
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:
|
||||
// Input for ColumnSelectionValues & RowSelectionValues
|
||||
if ((index.row() == 0) ||
|
||||
((index.column() == 0) && (index.row() > 0)))
|
||||
{
|
||||
le->setMaxLength(1);
|
||||
break;
|
||||
}
|
||||
|
||||
// Matrix
|
||||
if ((index.column() > 0) && (index.row() > 0))
|
||||
{
|
||||
// TODO: use (custom) QTextEdit ?
|
||||
le->setMaxLength(20);
|
||||
break;
|
||||
}
|
||||
le->setMaxLength(15);
|
||||
break;
|
||||
case PhraseTable:
|
||||
le->setMaxLength(15);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return le;
|
||||
} // end of createEditor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodeTableEditDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
|
||||
{
|
||||
QLineEdit *le = qobject_cast<QLineEdit *>(editor);
|
||||
if (!le)
|
||||
return;
|
||||
|
||||
QVariant v = index.data(Qt::EditRole);
|
||||
le->setText(v.toString());
|
||||
|
||||
DEBUG_LOG(m_logger) << "CodeTableEditDelegate::setEditorData() TableType: " << m_tableType
|
||||
<< " rox/column: " << index.row() << "/" << index.column()
|
||||
<< " Input: " << v.toString();
|
||||
|
||||
} // end of setEditorData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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)
|
||||
{
|
||||
case NumeralCode:
|
||||
case AuthenticationCode:
|
||||
case PhraseTable:
|
||||
{
|
||||
model->setData(index, le->text(), Qt::EditRole);
|
||||
break;
|
||||
}
|
||||
case LogisticalTerms:
|
||||
{
|
||||
// Input for ColumnSelectionValues & RowSelectionValues
|
||||
if ((index.row() == 0) ||
|
||||
((index.column() == 0) && (index.row() > 0)))
|
||||
{
|
||||
model->setData(index, le->text(), Qt::EditRole);
|
||||
break;
|
||||
}
|
||||
|
||||
// Matrix nach 10 Zeichen neue Zeile beginnen
|
||||
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;
|
||||
}
|
||||
|
||||
} // end of setModelData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* manages edit inputs from code models
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-01-12
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QItemDelegate>
|
||||
#include <CodificationManagement/logger.h>
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class CodeTableEditDelegate : public QItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum TableType
|
||||
{
|
||||
Undefined,
|
||||
NumeralCode,
|
||||
AuthenticationCode,
|
||||
LogisticalTerms,
|
||||
PhraseTable
|
||||
};
|
||||
|
||||
explicit CodeTableEditDelegate(QWidget *parent = nullptr, TableType tableType = Undefined);
|
||||
|
||||
/**
|
||||
* create editor
|
||||
* @param QWidget*
|
||||
* @param const QStyleOptionViewItem&
|
||||
* @param const QModelIndex&
|
||||
* @return QWidget
|
||||
*/
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override ;
|
||||
|
||||
/**
|
||||
* set editor data
|
||||
* @param QWidget*
|
||||
* @param const QModelIndex&
|
||||
*/
|
||||
void setEditorData(QWidget *editor, const QModelIndex &index) const override;
|
||||
|
||||
/**
|
||||
* set model data
|
||||
* @param QWidget*
|
||||
* @param QAbstractItemModel*
|
||||
* @param const QModelIndex&
|
||||
*/
|
||||
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
TableType m_tableType;
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
Executable
+199
@@ -0,0 +1,199 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for CodificationDataManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-01
|
||||
*/
|
||||
|
||||
#include "cod_codification_data_gui_plugin.h"
|
||||
#include "cod_codification_data_overview_view.h"
|
||||
#include "cod_codification_data_table_edit_view.h"
|
||||
#include "cod_assign_codification_data_table.h"
|
||||
#include "cod_codification_data_table_view.h"
|
||||
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <Services/CodificationManagement/cod_operator_rights.h>
|
||||
#include <LtsUtilsSettings/settings.h>
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
std::shared_ptr<GuiPluginBase::Interface> GuiPlugin::createGuiInterface(LtsSession::LtsSession *session)
|
||||
{
|
||||
return std::make_shared<InterfaceImpl>(session);
|
||||
} // end of createGuiInterface()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
InterfaceImpl::InterfaceImpl(LtsSession::LtsSession *session)
|
||||
: GuiPluginBase::Interface(session, getLogger("Plugins.Gui.CodificationDataImpl"))
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
{} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool InterfaceImpl::fetchInterfaces()
|
||||
{
|
||||
if (!m_session->getDtc<CodificationManagement::DataInterface>(m_dtc))
|
||||
return false;
|
||||
if (!m_session->getFtc<CodificationManagement::DataInterface>(m_ftc))
|
||||
return false;
|
||||
if (!m_session->getDtc<ParticipantManagement::DataInterface>(m_ppmDtc))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
} // end of fetchInterfaces()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void InterfaceImpl::clearInterfaces()
|
||||
{
|
||||
m_ftc = nullptr;
|
||||
m_dtc = nullptr;
|
||||
m_ppmDtc = nullptr;
|
||||
} // end of clearInterfaces()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QString InterfaceImpl::menuGroup() const
|
||||
{
|
||||
return tr("Audio / Video");
|
||||
} // end of menuGroup()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVector<LtsWidgets::PluginData> InterfaceImpl::getActions()
|
||||
{
|
||||
QVector<LtsWidgets::PluginData> ret;
|
||||
|
||||
LtsUtils::ProjectSettings *ps = LtsUtils::ProjectSettings::getInstance();
|
||||
const bool enableCodificationTables = ps->value(QStringLiteral("cod"),
|
||||
QStringLiteral("enableCodificationTables")).toBool();
|
||||
const bool enableShowCodificationTableBLUFOR = ps->value(QStringLiteral("cod"),
|
||||
QStringLiteral("enableShowCodificationTableBLUFOR")).toBool();
|
||||
const bool enableShowCodificationTableOPFOR = ps->value(QStringLiteral("cod"),
|
||||
QStringLiteral("enableShowCodificationTableOPFOR")).toBool();
|
||||
LtsWidgets::PluginData plData;
|
||||
if (enableCodificationTables)
|
||||
{
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Codification Data");
|
||||
plData.identifier = QLatin1String("codCodificatioData");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:table.svg"));
|
||||
plData.operatorRight = OperatorRights::CodificationDataEdit;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::ePlanning;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return onShowCodificationDataOverview(parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
// Action 'Set Codification Data' anlegen
|
||||
plData.menuGroup = menuGroup();
|
||||
plData.menuText = tr("Add Codification Data");
|
||||
plData.identifier = QLatin1String("codSetCodificationData");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:table_add.svg"));
|
||||
plData.operatorRight = OperatorRights::CodificationDataEdit;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::ePlanning;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return onSetCodificationData(parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
|
||||
|
||||
// Action 'Assign Codification Data Table'
|
||||
plData.menuGroup = tr("Exercises");
|
||||
plData.menuText = tr("Assign Codification Data");
|
||||
plData.identifier = QLatin1String("codAssignCodificationDataTable");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:table_add.svg"));
|
||||
plData.operatorRight = OperatorRights::CodificationDataEdit; // wer editieren kann kann auch zuordnen.?
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eExecution;
|
||||
plData.createWidgetFunc = [this](QWidget * parent)
|
||||
{
|
||||
return onAssignCodificationDataTable(parent);
|
||||
};
|
||||
ret.append(plData);
|
||||
}
|
||||
|
||||
if (enableShowCodificationTableOPFOR)
|
||||
{
|
||||
// Action 'Show Codification Data Table assigned to OPFOR (partyId=2) ROT'
|
||||
int partyId = 2;
|
||||
plData.menuGroup = tr("Exercises");
|
||||
plData.menuText = tr("Show OPFOR Codification Data");
|
||||
plData.identifier = QLatin1String("codAssignCodificationDataTableOPFOR"); // UniqueName, so koennen beide Tafeln in einem eigenen Widget parallel angezeigt verwendet.
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:table_add.svg"));
|
||||
plData.operatorRight = OperatorRights::CodificationDataShowOPFOR;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eExecution;
|
||||
plData.createWidgetFunc = [this, partyId](QWidget * parent)
|
||||
{
|
||||
return onShowAssignedDataTable(parent, partyId);
|
||||
};
|
||||
ret.append(plData);
|
||||
}
|
||||
|
||||
if (enableShowCodificationTableBLUFOR)
|
||||
{
|
||||
// Action 'Show Codification Data Table assigned to BLUFOR (partyId=3) BLAU'
|
||||
int partyId = 3;
|
||||
plData.menuGroup = tr("Exercises");
|
||||
plData.menuText = tr("Show BLUFOR Codification Data");
|
||||
plData.identifier = QLatin1String("codAssignCodificationDataTableBLUFOR");
|
||||
plData.menuIcon = QIcon(QLatin1String("icon:table_add.svg"));
|
||||
plData.operatorRight = OperatorRights::CodificationDataShowBLUFOR;
|
||||
plData.exercisePart = LtsWidgets::ExercisePart::eExecution;
|
||||
plData.createWidgetFunc = [this, partyId](QWidget * parent )
|
||||
{
|
||||
return onShowAssignedDataTable(parent, partyId);
|
||||
};
|
||||
ret.append(plData);
|
||||
}
|
||||
return ret;
|
||||
} // end of getActions()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowCodificationDataOverview(QWidget *parent)
|
||||
{
|
||||
CodificationDataOverviewView *dialog = new CodificationDataOverviewView(menuGroup(), m_session, parent);
|
||||
dialog->init(m_dtc, m_ftc, m_ppmDtc);
|
||||
return dialog;
|
||||
} // end of onShowCodificationDataOverview()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onSetCodificationData(QWidget *parent)
|
||||
{
|
||||
CodificationDataTableEditView *dialog = new CodificationDataTableEditView(parent);
|
||||
dialog->init(m_dtc, m_ftc, m_session, 0);
|
||||
return dialog;
|
||||
} // end of onSetCodificationData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onAssignCodificationDataTable(QWidget *parent)
|
||||
{
|
||||
AssignCodificationDataTable *dialog = new AssignCodificationDataTable(parent);
|
||||
dialog->init(m_dtc, m_ftc, m_ppmDtc, m_session);
|
||||
return dialog;
|
||||
} // end of onAssignCodificationDataTable()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
LtsWidgets::LtsDialog *InterfaceImpl::onShowAssignedDataTable(QWidget *parent, int partyId)
|
||||
{
|
||||
// CodTableId der zugeordneten partyId ermitteln....
|
||||
CodificationDataOverviewModel *model = new CodificationDataOverviewModel(this);
|
||||
model->initModel(m_dtc, m_ppmDtc);
|
||||
int codDataTableId = model->getCodTableId(partyId);
|
||||
delete model;
|
||||
|
||||
CodificationDataTableView *dialog = new CodificationDataTableView(parent);
|
||||
if (!dialog->init(m_dtc, m_ftc, m_session, partyId, codDataTableId))
|
||||
{
|
||||
delete dialog;
|
||||
return nullptr;
|
||||
}
|
||||
dialog->setUnchangeable(true);
|
||||
return dialog;
|
||||
} // end of onShowAssignedDataTable()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Gui Plugin for CodificationDataManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-01
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <CodificationManagement/cod_dtc.h>
|
||||
#include <CodificationManagement/cod_ftc.h>
|
||||
#include <ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
#include <Plugins/CodificationManagement/cod_data_plugin_interface.h>
|
||||
#include <Plugins/CodificationManagement/cod_gui_plugin_interface.h>
|
||||
|
||||
#include <PluginInterfaces/gui_plugin_interface.h>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class GuiPlugin final : public QObject, public GuiPluginBase::Plugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "gui:3:cod")
|
||||
Q_INTERFACES(GuiPluginBase::Plugin)
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
GuiPlugin() = default;
|
||||
~GuiPlugin() = default;
|
||||
|
||||
QString pluginName() override { return QLatin1String("CodificationManagementGuiPlugin"); }
|
||||
std::shared_ptr<GuiPluginBase::Interface> createGuiInterface(LtsSession::LtsSession *session) override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise; }
|
||||
};
|
||||
|
||||
class InterfaceImpl final : public QObject, public GuiPluginBase::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit InterfaceImpl(LtsSession::LtsSession *session);
|
||||
|
||||
bool fetchInterfaces() override;
|
||||
void clearInterfaces() override;
|
||||
QString menuGroup() const override;
|
||||
QVector<LtsWidgets::PluginData> getActions() override;
|
||||
bool availableInPartition(IDL::PartitionType partition) const override { return partition == IDL::PartitionType::Exercise; }
|
||||
|
||||
private:
|
||||
LtsWidgets::LtsDialog *onShowCodificationDataOverview(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onSetCodificationData(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onAssignCodificationDataTable(QWidget *parent);
|
||||
LtsWidgets::LtsDialog *onShowAssignedDataTable(QWidget *parent, int partyId);
|
||||
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
std::shared_ptr<CodificationManagement::Interface::Ftc> m_ftc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
};
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Executable
+186
@@ -0,0 +1,186 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for CodificationDataManagement - Codification Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-01
|
||||
*/
|
||||
|
||||
#include "cod_codification_data_overview_model.h"
|
||||
#include <ngltools/ngltools_dtg.h>
|
||||
#include <ParticipantManagement/ppm_translation.h>
|
||||
#include <QColor>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
//---------------------------------
|
||||
// CodificationDataOverviewModel
|
||||
//---------------------------------
|
||||
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)
|
||||
, m_logger(getLogger("CodificationDataOverviewModel"))
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
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()";
|
||||
|
||||
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;
|
||||
} // end of initModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant CodificationDataOverviewModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole &&
|
||||
role != Qt::BackgroundRole )
|
||||
return QVariant();
|
||||
|
||||
if (!indexIsValid(index))
|
||||
return QVariant();
|
||||
|
||||
const CodificationManagement::CodificationData &codificationData = m_vecData.at(index.row());
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
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("---");
|
||||
// Truppennamen speziell fuer GUEZ anpassen
|
||||
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: // Da die 'PartyId' in AssignCodificationDataTable als Zahl verwendet wird,
|
||||
// darf dafuer hier NICHT der Name als String zurueckgegeben werden!
|
||||
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)
|
||||
{
|
||||
switch (index.column())
|
||||
{
|
||||
case PartyId:
|
||||
if (codificationData.partyId() >= 0)
|
||||
return QColor::fromRgb(QRgb(m_ppmDtc->party(codificationData.partyId()).color()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
} // end of data()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int CodificationDataOverviewModel::getCodTableId(int partyId) const
|
||||
{
|
||||
for (const CodificationManagement::CodificationData &codificationData : m_vecData)
|
||||
{
|
||||
if (codificationData.partyId() == partyId)
|
||||
return codificationData.id();
|
||||
}
|
||||
return -1;
|
||||
} // end of getCodTableId()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataOverviewProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for CodificationDataManagement - Codification Overview Dialog Model
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-01
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Services/CodificationManagement/logger.h>
|
||||
#include <Services/CodificationManagement/cod_dtc.h>
|
||||
#include <Plugins/ParticipantManagement/ppm_data_plugin_interface.h>
|
||||
|
||||
#include <LtsWidgets/lts_abstract_table_model.h>
|
||||
#include <LtsWidgets/lts_column_filter_proxy_model.h>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
// --------------------------------------------------------
|
||||
// CodificationDataOverviewModel
|
||||
// --------------------------------------------------------
|
||||
class CodificationDataOverviewModel : public LtsWidgets::LtsAbstractTableModel<CodificationManagement::CodificationData>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Columns
|
||||
{
|
||||
Id,
|
||||
Identifier,
|
||||
ValidityTime,
|
||||
PartyId,
|
||||
PartyIdHiddenColumn, // uesd for AssignCodificationDataTable
|
||||
NumeralCodeTableColumnIndex,
|
||||
NumeralCodeTableRowIndex,
|
||||
AuthenticationTableColumnIndex,
|
||||
AuthenticationTableRowIndex,
|
||||
AuthenticationTableMatrix,
|
||||
LogisticalTermTableColumnIndex,
|
||||
LogisticalTermTableRowIndex,
|
||||
LogisticalTermTableMatrix,
|
||||
PhraseTable,
|
||||
Note
|
||||
};
|
||||
|
||||
|
||||
explicit CodificationDataOverviewModel(QObject *parent = nullptr);
|
||||
|
||||
bool initModel(const std::shared_ptr<CodificationManagement::Interface::Dtc> &codDtc,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc);
|
||||
|
||||
int getCodTableId(int partyId) const;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override final;
|
||||
|
||||
friend class CodificationDataOverviewProxyModel;
|
||||
|
||||
private:
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_codDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
Executable
+210
@@ -0,0 +1,210 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for CodificationManagement - Codification Data Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-01
|
||||
*/
|
||||
|
||||
#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 <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)
|
||||
, m_logger(getLogger("CodificationDataOverviewDialog"))
|
||||
{
|
||||
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::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::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::Remove, this, &CodificationDataOverviewView::onRemoveCodificationData);
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, false);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CodificationDataOverviewView::onPrint);
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CodificationDataOverviewView::~CodificationDataOverviewView()
|
||||
{
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataOverviewView::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Codification Data"));
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Codification_Data"));
|
||||
} // end of retranslate()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->hideColumn(CodificationDataOverviewModel::Id);
|
||||
#endif
|
||||
// m_ui->widget->hideColumn(CodificationDataOverviewModel::PartyId);
|
||||
|
||||
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::Note);
|
||||
|
||||
m_ui->widget->setSortIndicator(CodificationDataOverviewModel::Note, Qt::AscendingOrder);
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataOverviewView::onSelectionChanged()
|
||||
{
|
||||
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);
|
||||
|
||||
// CodificationData::CodificationData codData = m_model->codificationData(row);
|
||||
|
||||
} // end of onSelectionChanged()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataOverviewView::onShowCodificationData()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
CodificationManagement::CodificationData codificationData = m_model->getRowData(row);
|
||||
|
||||
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);
|
||||
|
||||
} // end of onShowCodificationData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataOverviewView::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);
|
||||
|
||||
} // end of onAddCodificationData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataOverviewView::onEditCodificationData()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
|
||||
int row = idx.row();
|
||||
if (row < 0)
|
||||
return;
|
||||
|
||||
CodificationManagement::CodificationData codificationData = m_model->getRowData(row);
|
||||
|
||||
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);
|
||||
|
||||
} // end of onEditCodificationData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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);
|
||||
});
|
||||
} // end of onRemoveCodificationData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataOverviewView::onPrint()
|
||||
{
|
||||
LtsPrinting::printView(m_session, this, m_ui->widget->treeView() );
|
||||
} // end of onPrint()
|
||||
|
||||
void CodificationDataOverviewView::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Executable
+75
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for CodificationDataManagement - Codification Data Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-01
|
||||
*/
|
||||
|
||||
#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 <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CodificationDataOverviewView;
|
||||
}
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
|
||||
class CodificationDataOverviewView : public LtsWidgets::LtsDialog,
|
||||
protected CodificationManagement::Interface::Ftc::CodificationDataRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
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);
|
||||
|
||||
//virtual functions from CodificationManagement::Interface::Ftc
|
||||
void onCodificationDataRemoveReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
|
||||
|
||||
|
||||
private:
|
||||
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;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
};
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CodificationDataOverviewView</class>
|
||||
<widget class="QWidget" name="CodificationDataOverviewView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>435</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Codification Data Overview</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="LtsDataView::LtsDataView" name="widget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>250</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsDataView::LtsDataView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsDataView/lts_data_view.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Codification data table show dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-06
|
||||
*/
|
||||
|
||||
#include "cod_codification_data_report.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 <QWidget>
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
#include <KDReports/KDReportsAutoTableElement>
|
||||
#include <KDReports/KDReportsCell>
|
||||
#include <KDReports/KDReportsReport>
|
||||
#include <KDReports/KDReportsTableElement>
|
||||
#include <KDReports/KDReportsTextElement>
|
||||
|
||||
#include <LtsPrinting/printing.h>
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
CodificationDataReport::CodificationDataReport( QWidget *parent,
|
||||
LtsSession::LtsSession *session,
|
||||
Ui::CodificationDataTableView *ui,
|
||||
NumeralCodeModel *numCodeModel,
|
||||
AuthenticationCodeModel *authenticationCodeModel,
|
||||
LogisticalTermsModel *logisticalTermsModel,
|
||||
PhraseTableModel *phraseTableModel)
|
||||
: m_parent(parent)
|
||||
, m_session(session)
|
||||
, m_ui(ui)
|
||||
, m_numCodeModel(numCodeModel)
|
||||
, m_authenticationCodeModel(authenticationCodeModel)
|
||||
, m_logisticalTermsModel(logisticalTermsModel)
|
||||
, m_phraseTableModel(phraseTableModel)
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataReport::print(bool fromShowMode)
|
||||
{
|
||||
KDReports::Report report;
|
||||
|
||||
KDReports::TableElement tabElem;
|
||||
tabElem.setHeaderColumnCount(2);
|
||||
tabElem.setWidth(100, KDReports::Percent);
|
||||
|
||||
// Numeral-Code table
|
||||
KDReports::TextElement textElem;
|
||||
textElem.setText(m_ui->gbNumeralCode->title());
|
||||
tabElem.cell(0,0).addElement(textElem);
|
||||
displayReportAsTableCell(m_numCodeModel, tabElem.cell(0, 0), false, false);
|
||||
|
||||
// Authentication-Code table
|
||||
textElem.setText(m_ui->gbAuthenticationTable->title());
|
||||
tabElem.cell(0,1).addElement(textElem);
|
||||
displayReportAsTableCell(m_authenticationCodeModel, tabElem.cell(0, 1), true, true);
|
||||
|
||||
KDReports::TableElement tabElem_1;
|
||||
tabElem_1.setHeaderColumnCount(2);
|
||||
tabElem_1.setWidth(100, KDReports::Percent);
|
||||
|
||||
// Phrase-Table
|
||||
textElem.setText(m_ui->groupBox_2->title());
|
||||
tabElem_1.cell(0,0).addElement(textElem);
|
||||
displayReportAsTableCell(m_phraseTableModel, tabElem_1.cell(0, 0), false, false);
|
||||
|
||||
// Logistical-Terms table
|
||||
textElem.setText(m_ui->groupBox->title());
|
||||
tabElem_1.cell(0,1).addElement(textElem);
|
||||
displayReportAsTableCell(m_logisticalTermsModel, tabElem_1.cell(0, 1), fromShowMode, fromShowMode);
|
||||
|
||||
// Name text
|
||||
KDReports::TableElement tabElem_2;
|
||||
tabElem_2.setHeaderColumnCount(1);
|
||||
tabElem_2.setWidth(100, KDReports::Percent);
|
||||
textElem.setText(m_ui->groupBox_3->title());
|
||||
tabElem_2.cell(0,0).addElement(textElem);
|
||||
KDReports::TableElement tabElem_2_1;
|
||||
tabElem_2_1.setHeaderColumnCount(1);
|
||||
tabElem_2_1.setWidth(100, KDReports::Percent);
|
||||
textElem.setText(m_ui->pteNote->toPlainText());
|
||||
tabElem_2_1.cell(0,0).addElement(textElem);
|
||||
tabElem_2.cell(0,0).addElement(tabElem_2_1);
|
||||
|
||||
report.addElement(tabElem);
|
||||
report.addElement(tabElem_1);
|
||||
report.addElement(tabElem_2);
|
||||
|
||||
// final report
|
||||
report.setWidthForEndlessPrinter(0);
|
||||
report.setMargins(5,5,5,5); // default 20
|
||||
|
||||
// print report
|
||||
LtsPrinting::printReport(m_session, m_parent, report );
|
||||
|
||||
} // end of displayReport()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataReport::displayReportAsTableCell(QAbstractTableModel *tableModel, KDReports::Cell &cell,
|
||||
bool horizontalHeaderVisbile, bool verticalHeaderVisible)
|
||||
{
|
||||
int rowCount = tableModel->rowCount(QModelIndex());
|
||||
if (rowCount > 0)
|
||||
{
|
||||
KDReports::AutoTableElement autoTable(tableModel);
|
||||
autoTable.setWidth(100, KDReports::Percent);
|
||||
autoTable.setVerticalHeaderVisible(verticalHeaderVisible);
|
||||
autoTable.setHorizontalHeaderVisible(horizontalHeaderVisbile);
|
||||
cell.addElement(autoTable);
|
||||
}
|
||||
else
|
||||
{
|
||||
KDReports::TextElement textElement;
|
||||
textElement.setText(QObject::tr("No data available"));
|
||||
textElement.setBold(false);
|
||||
cell.addElement(textElement);
|
||||
}
|
||||
} // end of displayReportAsTable()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Codification data table show dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-06
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
class QWidget;
|
||||
namespace LtsSession
|
||||
{
|
||||
class LtsSession;
|
||||
}
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CodificationDataTableView;
|
||||
}
|
||||
|
||||
namespace KDReports
|
||||
{
|
||||
class Cell;
|
||||
}
|
||||
class QAbstractTableModel;
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class NumeralCodeModel;
|
||||
class AuthenticationCodeModel;
|
||||
class LogisticalTermsModel;
|
||||
class PhraseTableModel;
|
||||
|
||||
class CodificationDataReport
|
||||
{
|
||||
|
||||
public:
|
||||
explicit CodificationDataReport( QWidget *parent,
|
||||
LtsSession::LtsSession *session,
|
||||
Ui::CodificationDataTableView *ui,
|
||||
NumeralCodeModel *numCodeModel,
|
||||
AuthenticationCodeModel *authenticationCodeModel,
|
||||
LogisticalTermsModel *logisticalTermsModel,
|
||||
PhraseTableModel *phraseTableModel);
|
||||
|
||||
/**
|
||||
* Print the report
|
||||
* @param fromShowMode (true)Print activated within show mode view; (false) Print activated within create/edit mode
|
||||
*/
|
||||
void print( bool fromShowMode );
|
||||
|
||||
private:
|
||||
/**
|
||||
* creates a report as table in a table cell
|
||||
* @param tableModel Abstract table model
|
||||
* @param cell The table cell for the table to be inserted
|
||||
* @param horizontalHeaderVisible Horizontal header visible (true/false)
|
||||
* @param verticalHeaderVisible Vertical header visible (true/false)
|
||||
*/
|
||||
static void displayReportAsTableCell(QAbstractTableModel *tableModel, KDReports::Cell &cell,
|
||||
bool horizontalHeaderVisbile, bool verticalHeaderVisible);
|
||||
|
||||
QWidget *m_parent;
|
||||
LtsSession::LtsSession *m_session;
|
||||
Ui::CodificationDataTableView *m_ui;
|
||||
NumeralCodeModel *m_numCodeModel;
|
||||
AuthenticationCodeModel *m_authenticationCodeModel;
|
||||
LogisticalTermsModel *m_logisticalTermsModel;
|
||||
PhraseTableModel *m_phraseTableModel;
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
|
||||
Executable
+504
@@ -0,0 +1,504 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Codification data table create/edit dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-07
|
||||
*/
|
||||
|
||||
#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_csv_export.h"
|
||||
#include "cod_csv_import.h"
|
||||
|
||||
#include <LtsWidgets/lts_message_dialog.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))
|
||||
, m_logger(getLogger("CodificationDataTableEditView"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CodificationDataTableEditView::onPrint);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Add_Codification_Data"));
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CodificationDataTableEditView::~CodificationDataTableEditView()
|
||||
{
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataTableEditView::retranslate()
|
||||
{
|
||||
translate(m_ui, m_dtc->codificationData(m_codificationDataId), tr("Codification Data"));
|
||||
} // end of retranslate()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
|
||||
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_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();
|
||||
|
||||
initNumeralModel();
|
||||
initAuthenticationModel();
|
||||
initLogisticalTermsModel();
|
||||
initPhraseTableModel();
|
||||
|
||||
// Init TextEditWidget 'note'
|
||||
m_ui->pteNote->setPlainText(QString::fromStdString(m_lastDdsCodificationData.note()));
|
||||
|
||||
// Init Identifier an validity time
|
||||
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::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());
|
||||
}
|
||||
|
||||
// connects used to enable ok button in case of modified data
|
||||
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);
|
||||
|
||||
// Save/Load from Library Button
|
||||
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;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataTableEditView::onLoadCodificationData()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::onLoadCodificationData()";
|
||||
|
||||
QString note;
|
||||
CSVImport csvImport(m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel,
|
||||
m_phraseTableModel, ¬e, this);
|
||||
|
||||
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);
|
||||
|
||||
// Enable Okay + Apply Button
|
||||
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();
|
||||
|
||||
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"));
|
||||
}
|
||||
} // end of onLoadCodificationData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void 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;
|
||||
} // end of onSaveCodificationData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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();
|
||||
|
||||
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) << "PhraseTable :" << m_lastDdsCodificationData.phraseTable();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Note: " << m_lastDdsCodificationData.note();
|
||||
|
||||
return;
|
||||
} // end of loadCodificationDataFromDatabase()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CodificationDataTableEditView::initNumeralModel()
|
||||
{
|
||||
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));
|
||||
|
||||
QFontMetricsF fm(font());
|
||||
const QRectF rect = fm.boundingRect(QLatin1String("W"));
|
||||
|
||||
QHeaderView *header = m_ui->tvNumeralCode->horizontalHeader();
|
||||
header->setSectionResizeMode(QHeaderView::Fixed);
|
||||
// Quasi Header
|
||||
header->resizeSection(0, rect.width() * 1.3);
|
||||
// Matrix
|
||||
for (int i = 1; i <= 13; ++i)
|
||||
header->resizeSection(i, rect.width() * 1.5);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvNumeralCode->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
vheader->resizeSection(0, rect.height() * 1.3);
|
||||
for (int i = 1; i <= 13; ++i)
|
||||
vheader->resizeSection(i, rect.height() * 1.5);
|
||||
|
||||
m_ui->tvNumeralCode->setShowGrid(true);
|
||||
m_ui->tvNumeralCode->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
// set to create/edit mode
|
||||
header->setVisible(false);
|
||||
vheader->setVisible(false);
|
||||
m_ui->tvNumeralCode->setColumnHidden(0, false);
|
||||
m_ui->tvNumeralCode->setRowHidden(0, false);
|
||||
|
||||
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);
|
||||
|
||||
// load column and row index character from database
|
||||
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;
|
||||
} // end of initNumeralModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CodificationDataTableEditView::initAuthenticationModel()
|
||||
{
|
||||
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));
|
||||
|
||||
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);
|
||||
// The width of the header is determined indirectly by the width of the cells
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 2.1);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvAuthenticationTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
// affects only the header
|
||||
vheader->setMinimumWidth(rectHeader.width() * 1.3);
|
||||
// affects only the Matrix
|
||||
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);
|
||||
|
||||
// use loaded data from database and init model
|
||||
if (m_codificationDataId > 0)
|
||||
m_authenticationCodeModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.authenticationTableMatirx()));
|
||||
return true;
|
||||
} // end of initAuthenticationModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CodificationDataTableEditView::initLogisticalTermsModel()
|
||||
{
|
||||
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));
|
||||
|
||||
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);
|
||||
// Quasi Header
|
||||
header->resizeSection(0, rectHeader.width() * 1.3);
|
||||
// Matrix
|
||||
for (int i = 1; i <= 5; ++i)
|
||||
header->resizeSection(i, rectMatrix.width() * 1.08);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvLogisticalTermsTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
|
||||
// Hight in first row for one character only
|
||||
vheader->resizeSection(0, rectHeader.height() * 1.3);
|
||||
for (int i = 1; i <= 5; ++i)
|
||||
vheader->resizeSection(i, rectMatrix.height() * 2.3);
|
||||
|
||||
m_ui->tvLogisticalTermsTable->setShowGrid(true);
|
||||
m_ui->tvLogisticalTermsTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
// set to create/edit mode
|
||||
header->setVisible(false);
|
||||
vheader->setVisible(false);
|
||||
m_ui->tvLogisticalTermsTable->setColumnHidden(0, false);
|
||||
m_ui->tvLogisticalTermsTable->setRowHidden(0, false);
|
||||
|
||||
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);
|
||||
|
||||
// use loaded data from database and init model
|
||||
// load column and row index character from database
|
||||
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);
|
||||
|
||||
// load matrix data from database
|
||||
m_logisticalTermsModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableMatrix()));
|
||||
}
|
||||
return true;
|
||||
} // end of initLogisticalTermsModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CodificationDataTableEditView::initPhraseTableModel()
|
||||
{
|
||||
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));
|
||||
|
||||
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);
|
||||
|
||||
// the header will be never displayed in this table
|
||||
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));
|
||||
|
||||
// use loaded data from database and init model
|
||||
if (m_codificationDataId > 0)
|
||||
m_phraseTableModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.phraseTable()));
|
||||
return true;
|
||||
} // end of initPhraseTableModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataTableEditView::onDataModified()
|
||||
{
|
||||
slotChangesMade();
|
||||
} // end of onDataModified()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataTableEditView::onPrint()
|
||||
{
|
||||
CodificationDataReport report(this, m_session, m_ui, m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel, m_phraseTableModel);
|
||||
report.print(false);
|
||||
} // end of onPrint()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CodificationDataTableEditView::apply()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationDataTableEditView::onOkayCodificationData()";
|
||||
|
||||
// ToDos:
|
||||
// 1. Aktuelle Daten aller Tabellen in modifiedCodificationData (dds Typ) eintragen.
|
||||
// 2. Daten aus m_modifiedCodificationData in Create-/ModifyRequest Datentyp umsetzen
|
||||
// 3. FTC Create-/Modify Request aufrufen
|
||||
|
||||
CodificationManagement::CodificationData modifiedCodificationData(m_lastDdsCodificationData);
|
||||
|
||||
// Bezeichner der Tafel (noetig fuer Tab Anzeige aus DDS Core::name)
|
||||
modifiedCodificationData.name(m_ui->leIdentifier->text().toStdString());
|
||||
|
||||
// NumeralCode Table
|
||||
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();
|
||||
|
||||
// Authentication Table
|
||||
modifiedCodificationData.authenticationTableMatirx(m_authenticationCodeModel->getMatrixDataCSVString().toStdString());
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() authMatrix: " << m_authenticationCodeModel->getMatrixDataCSVString();
|
||||
|
||||
// LogicalTerms Table
|
||||
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();
|
||||
|
||||
// Phrase Table
|
||||
modifiedCodificationData.phraseTable(m_phraseTableModel->getMatrixDataCSVString().toStdString());
|
||||
DEBUG_LOG(m_logger) << "onOkayCodificationData() phraseTable: " << m_phraseTableModel->getMatrixDataCSVString();
|
||||
|
||||
// Note
|
||||
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());
|
||||
|
||||
if (m_codificationDataId < 1)
|
||||
modifiedCodificationData.partyId(-1);
|
||||
|
||||
m_requestHelper->addRequest([this, modifiedCodificationData]()
|
||||
{
|
||||
return m_ftc->codificationDataModifyRequest(modifiedCodificationData, this);
|
||||
});
|
||||
|
||||
return m_requestHelper->startRequests();
|
||||
} // end of apply()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataTableEditView::onExportButtonClicked()
|
||||
{
|
||||
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 ";
|
||||
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataTableEditView::onImportButtonClicked()
|
||||
{
|
||||
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())
|
||||
{
|
||||
//SimulatedMovementModifyRequest req = jsonToSimulatedMovement(content);
|
||||
|
||||
INFO_LOG(m_logger) << "--- onImportButtonClicked() ";
|
||||
csvImport.loadCSVDataByteArray(content);
|
||||
m_ui->pteNote->setPlainText(note);
|
||||
}
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
} // namespace CodificationManagement
|
||||
Executable
+127
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Codification data table create/edit dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-07
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <Services/CodificationManagement/cod_dtc.h>
|
||||
#include <Services/CodificationManagement/cod_ftc.h>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
#include <Plugins/FileManagement/flm_explorer_gui_plugin_interface.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CodificationDataTableView;
|
||||
}
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class NumeralCodeModel;
|
||||
class AuthenticationCodeModel;
|
||||
class LogisticalTermsModel;
|
||||
class PhraseTableModel;
|
||||
class CSVExport;
|
||||
|
||||
class CodificationDataTableEditView : public LtsWidgets::LtsDialog,
|
||||
protected CodificationManagement::Interface::Ftc::CodificationDataModifyReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CodificationDataTableEditView(QWidget *parent = nullptr);
|
||||
|
||||
~CodificationDataTableEditView();
|
||||
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<CodificationManagement::Interface::Ftc> &ftc,
|
||||
LtsSession::LtsSession *session,
|
||||
int codificationDataId);
|
||||
|
||||
|
||||
//virtual functions from CodificationManagement::Interface::Ftc
|
||||
void onCodificationDataModifyReply(const Core::FunctionReplyObject &replyObject) override { m_requestHelper->requestReply(replyObject); }
|
||||
QByteArray exportToByteArray();
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* received when data was changed (used to enable add/okay button)
|
||||
*/
|
||||
void onDataModified();
|
||||
void onPrint();
|
||||
void onExportButtonClicked();
|
||||
void onImportButtonClicked();
|
||||
|
||||
//
|
||||
/**
|
||||
* Override the accept function from LtsDialog to save a modified edit dialog when the widget is closed.
|
||||
*/
|
||||
bool apply() override;
|
||||
|
||||
void onLoadCodificationData();
|
||||
void onSaveCodificationData();
|
||||
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void loadCodificationDataFromDatabase();
|
||||
|
||||
/**
|
||||
* initialize the numeral code table
|
||||
* @param -
|
||||
* @return Returns always true
|
||||
*/
|
||||
bool initNumeralModel();
|
||||
|
||||
/**
|
||||
* initialize the authentication code table
|
||||
* @param -
|
||||
* @return Returns always true
|
||||
*/
|
||||
bool initAuthenticationModel();
|
||||
|
||||
/**
|
||||
* initialize the logistical terms table
|
||||
* @param -
|
||||
* @return Returns always true
|
||||
*/
|
||||
bool initLogisticalTermsModel();
|
||||
|
||||
/**
|
||||
* initialize the phrase table
|
||||
* @param -
|
||||
* @return Returns always true
|
||||
*/
|
||||
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};
|
||||
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
|
||||
CodificationManagement::CodificationData m_lastDdsCodificationData; ///< last dds codification data
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
|
||||
|
||||
Executable
+346
@@ -0,0 +1,346 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Codification data table show dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-06
|
||||
*/
|
||||
|
||||
#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 <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))
|
||||
, m_logger(getLogger("CodificationDataTableView"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Print, this, &CodificationDataTableView::onPrint);
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
CodificationDataTableView::~CodificationDataTableView()
|
||||
{
|
||||
delete m_ui;
|
||||
delete m_numCodeModel;
|
||||
delete m_authenticationCodeModel;
|
||||
delete m_logisticalTermsModel;
|
||||
delete m_phraseTableModel;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataTableView::retranslate()
|
||||
{
|
||||
// translate(m_ui, m_dtc->codificationData(m_codificationDataId), tr("Table"));
|
||||
|
||||
if (m_partyId == 2) // Party ROT
|
||||
translate(m_ui, tr("Codification Data Table OPFOR"));
|
||||
|
||||
if (m_partyId == 3) // Party Blue
|
||||
translate(m_ui, tr("Codification Data Table BLUFOR"));
|
||||
} // end of retranslate()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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()";
|
||||
|
||||
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 (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();
|
||||
|
||||
initNumeralModel();
|
||||
initAuthenticationModel();
|
||||
initLogicalTermsModel();
|
||||
initPhraseTableModel();
|
||||
|
||||
|
||||
// m_ui->leIdentifier->setText(QString::fromStdString(m_lastDdsCodificationData.identifier()));
|
||||
// m_ui->dteValidityTime->setMsecsSinceEpoch(m_lastDdsCodificationData.validityTime());
|
||||
// Im Anzeigemode Identifier und Zeit nicht anzeigen
|
||||
m_ui->lbIdentifier->hide();
|
||||
m_ui->leIdentifier->hide();
|
||||
m_ui->lbDteValidityTime->hide();
|
||||
m_ui->dteValidityTime->hide();
|
||||
|
||||
// Init TextEditWidget 'note'
|
||||
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) // Party ROT
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Show_OPFOR_Codification_Data"));
|
||||
|
||||
if (m_partyId == 3) // Party Blue
|
||||
setOnlineHelpFilename(QStringLiteral("Situation-Show_BLUFOR_Codification_Data"));
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void 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();
|
||||
|
||||
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) << "PhraseTable: " << m_lastDdsCodificationData.phraseTable();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Note: " << m_lastDdsCodificationData.note();
|
||||
|
||||
return;
|
||||
} // end of loadCodificationDataFromDatabase()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CodificationDataTableView::onPrint()
|
||||
{
|
||||
CodificationDataReport report( this, m_session, m_ui, m_numCodeModel, m_authenticationCodeModel, m_logisticalTermsModel, m_phraseTableModel );
|
||||
report.print(true);
|
||||
|
||||
} // end of onPrint()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CodificationDataTableView::initNumeralModel()
|
||||
{
|
||||
bool bOk = 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);
|
||||
// The width of the header is determined indirectly by the width of the cells
|
||||
header->setDefaultSectionSize(rect.width() * 1.5);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvNumeralCode->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
// affects only the header
|
||||
vheader->setMinimumWidth(rect.width() * 1.3);
|
||||
// affects only the Matrix
|
||||
vheader->setDefaultSectionSize(rect.height() * 1.5);
|
||||
|
||||
m_ui->tvNumeralCode->setShowGrid(true);
|
||||
m_ui->tvNumeralCode->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
// set to show mode
|
||||
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);
|
||||
|
||||
// load column and row index character from database
|
||||
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;
|
||||
} // end of initNumeralModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CodificationDataTableView::initAuthenticationModel()
|
||||
{
|
||||
bool bOk = 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);
|
||||
// The width of the header is determined indirectly by the width of the cells
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 2.1); // Workaround: 2.1 to fill the widget
|
||||
|
||||
QHeaderView *vheader = m_ui->tvAuthenticationTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
// affects only the header
|
||||
vheader->setMinimumWidth(rectHeader.width() * 1.3);
|
||||
// affects only the Matrix
|
||||
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);
|
||||
|
||||
// use loaded data from database and init model
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
m_authenticationCodeModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.authenticationTableMatirx()));
|
||||
}
|
||||
return bOk;
|
||||
} // end of initAuthenticationModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CodificationDataTableView::initLogicalTermsModel()
|
||||
{
|
||||
bool bOk = 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);
|
||||
// The width of the header is determined indirectly by the width of the cells
|
||||
header->setDefaultSectionSize(rectMatrix.width() * 1.08);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvLogisticalTermsTable->verticalHeader();
|
||||
vheader->setSectionResizeMode(QHeaderView::Fixed);
|
||||
// affects only the header
|
||||
vheader->setMinimumWidth(rectHeader.width() * 1.08);
|
||||
// affects only the Matrix
|
||||
vheader->setDefaultSectionSize(rectMatrix.height() * 2.3);
|
||||
|
||||
m_ui->tvLogisticalTermsTable->setShowGrid(true);
|
||||
m_ui->tvLogisticalTermsTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
// set to show mode
|
||||
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);
|
||||
|
||||
// use loaded data from database and init model
|
||||
// load column and row index character from database
|
||||
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);
|
||||
|
||||
// load matrix data from database
|
||||
m_logisticalTermsModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.logisticalTermTableMatrix()));
|
||||
}
|
||||
return bOk;
|
||||
} // end of initLogicalTermsModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CodificationDataTableView::initPhraseTableModel()
|
||||
{
|
||||
bool bOk = 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);
|
||||
|
||||
// the header will be never displayed in this table
|
||||
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);
|
||||
|
||||
// use loaded data from database and init model
|
||||
if (m_codificationDataId > 0)
|
||||
{
|
||||
// load matrix data from database
|
||||
m_phraseTableModel->setMatrixValuesCSV(QString::fromStdString(m_lastDdsCodificationData.phraseTable()));
|
||||
}
|
||||
return bOk;
|
||||
} // end of initPhraseTableModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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()));
|
||||
|
||||
} // end of onCodificationDataChanged()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Executable
+110
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Codification data table show dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-06
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LtsWidgets/lts_dialog.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
|
||||
#include <Services/CodificationManagement/cod_dtc.h>
|
||||
#include <Services/CodificationManagement/cod_ftc.h>
|
||||
#include <CodificationManagement/logger.h>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CodificationDataTableView;
|
||||
}
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class NumeralCodeModel;
|
||||
class AuthenticationCodeModel;
|
||||
class LogisticalTermsModel;
|
||||
class PhraseTableModel;
|
||||
|
||||
class CodificationDataTableView : public LtsWidgets::LtsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CodificationDataTableView(QWidget *parent = nullptr);
|
||||
|
||||
~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);
|
||||
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* codification data was changed external (used here to update 'note' only)
|
||||
* @param codificationData
|
||||
* @param modType
|
||||
* @return -
|
||||
*/
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType);
|
||||
|
||||
private:
|
||||
void retranslate() override;
|
||||
void loadCodificationDataFromDatabase();
|
||||
void onPrint();
|
||||
|
||||
/**
|
||||
* initialize the numeral code table
|
||||
* @param -
|
||||
* @return Returns always true
|
||||
*/
|
||||
bool initNumeralModel();
|
||||
|
||||
/**
|
||||
* initialize the authentication code table
|
||||
* @param -
|
||||
* @return Returns always true
|
||||
*/
|
||||
bool initAuthenticationModel();
|
||||
|
||||
/**
|
||||
* initialize the logical terms table
|
||||
* @param -
|
||||
* @return Returns always true
|
||||
*/
|
||||
bool initLogicalTermsModel();
|
||||
|
||||
/**
|
||||
* initialize the phrase table
|
||||
* @param -
|
||||
* @return Returns always true
|
||||
*/
|
||||
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};
|
||||
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
|
||||
CodificationManagement::CodificationData m_lastDdsCodificationData; ///< last dds codification data
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
|
||||
Executable
+209
@@ -0,0 +1,209 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CodificationDataTableView</class>
|
||||
<widget class="QWidget" name="CodificationDataTableView">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>851</width>
|
||||
<height>768</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Codification Data Table</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbIdentifier">
|
||||
<property name="text">
|
||||
<string>Identifier:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="leIdentifier"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbDteValidityTime">
|
||||
<property name="text">
|
||||
<string>Validity Time:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LtsWidgets::LtsDateTimeEdit" name="dteValidityTime">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>255</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="gbNumeralCode">
|
||||
<property name="title">
|
||||
<string>Numeral-Code</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="tvNumeralCode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QGroupBox" name="gbAuthenticationTable">
|
||||
<property name="title">
|
||||
<string>Authentication-Code</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QTableView" name="tvAuthenticationTable">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Phrase-Table</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QTableView" name="tvPhraseTable">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Logistical-Terms</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QTableView" name="tvLogisticalTermsTable">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Note</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="pteNote"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LtsWidgets::LtsDateTimeEdit</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>LtsWidgets/lts_date_time_edit.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Export codification table csv data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-01-23
|
||||
*/
|
||||
|
||||
#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_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(getLogger("CodificationCSVExport"))
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QByteArray CSVExport::exportToByteArray() const
|
||||
{
|
||||
QByteArray byteArray;
|
||||
|
||||
// Numeral Code table
|
||||
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");
|
||||
|
||||
// Authentication table
|
||||
byteArray.append("<Authentication Code Matrix>\n");
|
||||
byteArray.append(m_authenticationCodeModel->getMatrixDataCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
|
||||
// Logistical Terms table
|
||||
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");
|
||||
|
||||
// Phrase table
|
||||
byteArray.append("<Phrase Table Matrix>\n");
|
||||
byteArray.append(m_phraseTableModel->getMatrixDataCSVString().toUtf8());
|
||||
byteArray.append("\n");
|
||||
|
||||
// Note
|
||||
byteArray.append("<Note>\n");
|
||||
byteArray.append(m_note.toLocal8Bit());
|
||||
|
||||
return byteArray;
|
||||
|
||||
}
|
||||
|
||||
bool CSVExport::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"));
|
||||
|
||||
if (!dialog.exec())
|
||||
return false;
|
||||
const QStringList fileNames = dialog.selectedFiles();
|
||||
if (fileNames.isEmpty())
|
||||
return false;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
QByteArray byteArray = exportToByteArray();
|
||||
|
||||
file.write(byteArray);
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
|
||||
} // end of writeCSVData()
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Export codification table csv data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-01-23
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <CodificationManagement/logger.h>
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class NumeralCodeModel;
|
||||
class AuthenticationCodeModel;
|
||||
class LogisticalTermsModel;
|
||||
class PhraseTableModel;
|
||||
|
||||
class CSVExport : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CSVExport(const NumeralCodeModel *numCodeModel,
|
||||
const AuthenticationCodeModel *authenticationCodeModel,
|
||||
const LogisticalTermsModel *logisticalTermsModel,
|
||||
const PhraseTableModel *phraseTableModel,
|
||||
const QString ¬e,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
bool writeCSVData();
|
||||
QByteArray exportToByteArray() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
|
||||
private:
|
||||
const NumeralCodeModel *m_numCodeModel;
|
||||
const AuthenticationCodeModel *m_authenticationCodeModel;
|
||||
const LogisticalTermsModel *m_logisticalTermsModel;
|
||||
const PhraseTableModel *m_phraseTableModel;
|
||||
QString m_note;
|
||||
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
|
||||
+580
@@ -0,0 +1,580 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Import codification table csv data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-03-02
|
||||
*/
|
||||
|
||||
#include "cod_csv_import.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 <LtsWidgets/lts_message_dialog.h>
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QBuffer>
|
||||
|
||||
using namespace CodificationManagement;
|
||||
|
||||
|
||||
CSVImport::CSVImport(NumeralCodeModel *numCodeModel,
|
||||
AuthenticationCodeModel *authenticationCodeModel,
|
||||
LogisticalTermsModel *logisticalTermsModel,
|
||||
PhraseTableModel *phraseTableModel,
|
||||
QString *note,
|
||||
QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_numCodeModel(numCodeModel)
|
||||
, m_authenticationCodeModel(authenticationCodeModel)
|
||||
, m_logisticalTermsModel(logisticalTermsModel)
|
||||
, m_phraseTableModel(phraseTableModel)
|
||||
, m_note(note)
|
||||
, m_logger(getLogger("CodificationCSVImport"))
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
CSVImport::CSVImportResult CSVImport::loadCSVDataByteArray(QByteArray content)
|
||||
{
|
||||
QBuffer buffer;
|
||||
buffer.setBuffer(&content);
|
||||
buffer.open(QIODevice::ReadOnly);
|
||||
|
||||
QByteArray qbaNumCodeHorizontalHeader; // <Numeral Code Horizontal Header>
|
||||
QByteArray qbaNumCodeVerticalHeader; // <Numeral Code Vertical Header>
|
||||
QByteArray qbaAuthenticationCodeMatrix; // <Authentication Code Matrix>
|
||||
QByteArray qbaLogTermsTableHorizontalHeader; // <Logistical Terms Table Horizontal Header>
|
||||
QByteArray qbaLogTermsTableVerticalHeader; // <Logistical Terms Table Vertical Header>
|
||||
QByteArray qbaLogTermsTableMatrix; // <Logistical Terms Table Matrix>
|
||||
QByteArray qbaPhraseTableMatrix; // <Phrase Table Matrix>
|
||||
QByteArray qbaNote; // <Note>
|
||||
QByteArray *qba;
|
||||
|
||||
qba = nullptr;
|
||||
|
||||
int desiredCvsSeperatorsPerLine = 0;
|
||||
int csvKeywordCount = 0;
|
||||
|
||||
QByteArray qbaMergeQuotedEntriesPerLine;
|
||||
|
||||
bool isMergedLine = false;
|
||||
|
||||
while (!buffer.atEnd())
|
||||
{
|
||||
QByteArray qbaLine = buffer.readLine(); // '\n' in quoted Eintraegen wird hier als Line Ende interpretiert!!
|
||||
|
||||
// DEBUG_LOG(m_logger) << "qbaLine (raw): \"" << qbaLine << "\"";
|
||||
|
||||
// WindowsEnd -> UnixEnd
|
||||
if (qbaLine.endsWith("\r\n"))
|
||||
qbaLine.remove(qbaLine.lastIndexOf('\r'), 1);
|
||||
|
||||
if (qbaLine.startsWith("<"))
|
||||
{
|
||||
// alle ; Zeichen nach > abschneiden
|
||||
int index = qbaLine.indexOf('>');
|
||||
qbaLine.truncate(index + 1);
|
||||
qbaLine.append('\n');
|
||||
|
||||
if (qbaLine == "<Numeral Code Horizontal Header>\n")
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "found " << qbaLine;
|
||||
qba = &qbaNumCodeHorizontalHeader;
|
||||
desiredCvsSeperatorsPerLine = 12;
|
||||
++csvKeywordCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qbaLine == "<Numeral Code Vertical Header>\n")
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "found " << qbaLine;
|
||||
qba = &qbaNumCodeVerticalHeader;
|
||||
desiredCvsSeperatorsPerLine = 0;
|
||||
++csvKeywordCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qbaLine == "<Authentication Code Matrix>\n")
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "found " << qbaLine;
|
||||
qba = &qbaAuthenticationCodeMatrix;
|
||||
desiredCvsSeperatorsPerLine = 4;
|
||||
++csvKeywordCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qbaLine == "<Logistical Terms Table Horizontal Header>\n")
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "found " << qbaLine;
|
||||
qba = &qbaLogTermsTableHorizontalHeader;
|
||||
desiredCvsSeperatorsPerLine = 4;
|
||||
++csvKeywordCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qbaLine == "<Logistical Terms Table Vertical Header>\n")
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "found " << qbaLine;
|
||||
qba = &qbaLogTermsTableVerticalHeader;
|
||||
desiredCvsSeperatorsPerLine = 0;
|
||||
++csvKeywordCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qbaLine == "<Logistical Terms Table Matrix>\n")
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "found " << qbaLine;
|
||||
qba = &qbaLogTermsTableMatrix;
|
||||
desiredCvsSeperatorsPerLine = 4;
|
||||
++csvKeywordCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qbaLine == "<Phrase Table Matrix>\n")
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "found " << qbaLine;
|
||||
qba = &qbaPhraseTableMatrix;
|
||||
desiredCvsSeperatorsPerLine = 1;
|
||||
++csvKeywordCount;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (qbaLine == "<Note>\n")
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "found " << qbaLine;
|
||||
qba = &qbaNote;
|
||||
desiredCvsSeperatorsPerLine = 0;
|
||||
++csvKeywordCount;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (qba)
|
||||
{
|
||||
if (! qbaLine.contains('"') && ! isMergedLine)
|
||||
{
|
||||
// Zeile komplett uebernehmen ...
|
||||
removeRedundantCvsSeperators(qbaLine, desiredCvsSeperatorsPerLine);
|
||||
qba->append(qbaLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
// moegliche Varianten (Betrachtung speziell fuer LogTermsTable) :
|
||||
// a.) Zeile enthaelt (oeffnendes) " =>> isMergedLine = true setzen -> Zeile in Buf zwischenspeichern -> continue
|
||||
// ... kann hier nur ein " enthalten, da der quoted Anteil mit \n endet !
|
||||
// b.) naechste zeile enthaelt kein " =>> da isMergedLine == true, sind es quoted Daten -> Daten an Buf anhaengen -> continue
|
||||
// c.) oder Zeile enthaelt (schliessendes) " =>> Daten bis " an Buf anhaengen
|
||||
// ... und ggf weiteres (oeffnendes) " =>> Pruefen ob weiteres (oeffnendes) " vorhanden (das kann sein, wenn die Excelzeile weitere quoted Eintraege enthaelt)
|
||||
// - wenn ja, restliche Zeichen an Buf anhaengen -> continue
|
||||
// - wenn nein, restliche Zeichen an Buf anhaengen -> Zeile komplett...
|
||||
// Gesammelte Zeile in qbaLine uebernehmen
|
||||
// qbaLine = qbaMergeQuotedEntriesPerLine;
|
||||
// qbaMergeQuotedEntriesPerLine.clear();
|
||||
// isMergedLine = false setzen
|
||||
// removeRedundantCvsSeperators(qbaLine, desiredCvsSeperatorsPerLine);
|
||||
// qba->append(qbaLine);
|
||||
|
||||
// a.)
|
||||
if (qbaLine.contains('"') && ! isMergedLine)
|
||||
{
|
||||
isMergedLine = true;
|
||||
qbaMergeQuotedEntriesPerLine.append(qbaLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
// b.) mehrzeiliges Quote...
|
||||
if (! qbaLine.contains('"') && isMergedLine)
|
||||
{
|
||||
qbaMergeQuotedEntriesPerLine.append(qbaLine);
|
||||
continue;
|
||||
}
|
||||
|
||||
// c.)
|
||||
if (qbaLine.contains('"') && isMergedLine)
|
||||
{
|
||||
// Daten bis incl. " an Buf anhaengen
|
||||
int idx = qbaLine.indexOf('\"');
|
||||
QByteArray qbaQuotedPart = qbaLine.left(idx + 1); // incl. "
|
||||
qbaMergeQuotedEntriesPerLine.append(qbaQuotedPart);
|
||||
|
||||
// Rest der Zeile nach schliessenden "
|
||||
QByteArray qbaRestLine = qbaLine.mid(idx + 1);
|
||||
|
||||
// Pruefen ob im Rest noch weiteres (oeffnendes) " vorhanden
|
||||
if (! qbaRestLine.contains('"'))
|
||||
{
|
||||
// Gesamte CSV-Zeile fertig
|
||||
qbaMergeQuotedEntriesPerLine.append(qbaRestLine);
|
||||
// Gesammelte Zeile in qbaLine uebernehmen
|
||||
qbaLine = qbaMergeQuotedEntriesPerLine;
|
||||
|
||||
// Merge Modus beenden und fuer naechsten vorbereiten
|
||||
qbaMergeQuotedEntriesPerLine.clear();
|
||||
isMergedLine = false;
|
||||
|
||||
// Zeile komplett uebernehmen ...
|
||||
removeRedundantCvsSeperators(qbaLine, desiredCvsSeperatorsPerLine);
|
||||
qba->append(qbaLine);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rest enthaelt noch ein oeffnendes ". Rest der Zeile an Buf anhaengen
|
||||
qbaMergeQuotedEntriesPerLine.append(qbaRestLine);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} // if (qba)
|
||||
} // while (!buffer.atEnd())
|
||||
|
||||
|
||||
if (csvKeywordCount != 8)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Load csv data failed! Invalid csvKeywordCount. Soll/Ist: 8/" << csvKeywordCount;
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data failed! Invalid number of cvs keywords."), tr("CSV Load Error"));
|
||||
return CSVImportResult::LoadFailed;
|
||||
}
|
||||
|
||||
// show load csv data blocks
|
||||
DEBUG_LOG(m_logger) << "Load csv ready... ";
|
||||
DEBUG_LOG(m_logger) << "\n-----------start show load csv data blocks -------------------------\n";
|
||||
DEBUG_LOG(m_logger) << "\n<Block ... <Numeral Code Horizontal Header>: \"" << qbaNumCodeHorizontalHeader << "\"\n";
|
||||
DEBUG_LOG(m_logger) << "\n<Block ... <Numeral Code Vertical Header>: \"" << qbaNumCodeVerticalHeader << "\"\n";
|
||||
DEBUG_LOG(m_logger) << "\n<Block ... <Authentication Code Matrix>: \"" << qbaAuthenticationCodeMatrix << "\"\n";
|
||||
DEBUG_LOG(m_logger) << "\n<Block ... <Logistical Terms Table Horizontal Header>: \"" << qbaLogTermsTableHorizontalHeader << "\"\n";
|
||||
DEBUG_LOG(m_logger) << "\n<Block ... <Logistical Terms Table Vertical Header>: \"" << qbaLogTermsTableVerticalHeader << "\"\n";
|
||||
DEBUG_LOG(m_logger) << "\n<Block ... <Logistical Terms Table Matrix>: \"" << qbaLogTermsTableMatrix << "\"\n";
|
||||
DEBUG_LOG(m_logger) << "\n<Block ... <Phrase Table Matrix>: \"" << qbaPhraseTableMatrix << "\"\n";
|
||||
DEBUG_LOG(m_logger) << "\n<Block ... <Note>: \"" << qbaNote << "\"\n";
|
||||
DEBUG_LOG(m_logger) << "\n-----------end of show load csv data blocks -------------------------\n";
|
||||
|
||||
// Numeral Code table
|
||||
qbaNumCodeHorizontalHeader = qbaNumCodeHorizontalHeader.trimmed(); // remove last `\n`
|
||||
if (checkNumCodeHorizontalHeader(qbaNumCodeHorizontalHeader))
|
||||
m_numCodeModel->setColumnSelectionValuesCSV(QString::fromUtf8(qbaNumCodeHorizontalHeader));
|
||||
else
|
||||
return CSVImportResult::LoadFailed;
|
||||
|
||||
qbaNumCodeVerticalHeader = qbaNumCodeVerticalHeader.trimmed(); // remove last `\n`
|
||||
if (checkNumCodeVerticalHeader(qbaNumCodeVerticalHeader))
|
||||
m_numCodeModel->setRowSelectionValuesCSV(QString::fromUtf8(qbaNumCodeVerticalHeader));
|
||||
else
|
||||
return CSVImportResult::LoadFailed;
|
||||
|
||||
// Authentication table
|
||||
qbaAuthenticationCodeMatrix = qbaAuthenticationCodeMatrix.trimmed(); // remove last `\n`
|
||||
if (checkAuthenticationCodeMatrix(qbaAuthenticationCodeMatrix))
|
||||
m_authenticationCodeModel->setMatrixValuesCSV(QString::fromUtf8(qbaAuthenticationCodeMatrix));
|
||||
else
|
||||
return CSVImportResult::LoadFailed;
|
||||
|
||||
// Logistical Terms table
|
||||
qbaLogTermsTableHorizontalHeader = qbaLogTermsTableHorizontalHeader.trimmed(); // remove last `\n`
|
||||
if (checkLogTermsTableHorizontalHeader(qbaLogTermsTableHorizontalHeader))
|
||||
m_logisticalTermsModel->setColumnSelectionValuesCSV(QString::fromUtf8(qbaLogTermsTableHorizontalHeader));
|
||||
else
|
||||
return CSVImportResult::LoadFailed;
|
||||
|
||||
qbaLogTermsTableVerticalHeader = qbaLogTermsTableVerticalHeader.trimmed(); // remove last `\n`
|
||||
if (checkLogTermsTableVerticalHeader(qbaLogTermsTableVerticalHeader))
|
||||
m_logisticalTermsModel->setRowSelectionValuesCSV(QString::fromUtf8(qbaLogTermsTableVerticalHeader));
|
||||
else
|
||||
return CSVImportResult::LoadFailed;
|
||||
|
||||
qbaLogTermsTableMatrix = qbaLogTermsTableMatrix.trimmed(); // remove last `\n`
|
||||
if (checkLogTermsTableMatrix(qbaLogTermsTableMatrix))
|
||||
m_logisticalTermsModel->setMatrixValuesCSV(QString::fromUtf8(qbaLogTermsTableMatrix));
|
||||
else
|
||||
return CSVImportResult::LoadFailed;
|
||||
|
||||
// Phrase table
|
||||
qbaPhraseTableMatrix = qbaPhraseTableMatrix.trimmed(); // remove last `\n`
|
||||
if (checkPhraseTableMatrix(qbaPhraseTableMatrix))
|
||||
m_phraseTableModel->setMatrixValuesCSV(QString::fromUtf8(qbaPhraseTableMatrix));
|
||||
else
|
||||
return CSVImportResult::LoadFailed;
|
||||
|
||||
// Note
|
||||
qbaNote = qbaNote.trimmed(); // remove last `\n`
|
||||
removeQuotedCharInNote(qbaNote);
|
||||
m_note->clear();
|
||||
m_note->append(QString::fromUtf8(qbaNote));
|
||||
return CSVImportResult::LoadOk;
|
||||
}
|
||||
|
||||
|
||||
CSVImport::CSVImportResult CSVImport::loadCSVData()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "loadCSVData()";
|
||||
|
||||
QFileDialog dialog;
|
||||
dialog.setNameFilter(tr("CSV File (*.csv)"));
|
||||
dialog.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
dialog.setDirectory(QLatin1String("../TMP"));
|
||||
|
||||
if (dialog.exec() == QDialog::Rejected)
|
||||
return CSVImportResult::UserAbort;
|
||||
|
||||
const QStringList fileNames = dialog.selectedFiles();
|
||||
if (fileNames.isEmpty())
|
||||
return CSVImportResult::LoadFailed;
|
||||
|
||||
QFile file;
|
||||
file.setFileName(fileNames.first());
|
||||
|
||||
if (!file.open(QFile::ReadOnly))
|
||||
{
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("File is not accessible!"), tr("CSV Import Error"));
|
||||
return CSVImportResult::LoadFailed;
|
||||
}
|
||||
QByteArray byteArray = file.readAll();
|
||||
file.close();
|
||||
//////////////////////
|
||||
loadCSVDataByteArray(byteArray);
|
||||
|
||||
return CSVImportResult::LoadOk;
|
||||
|
||||
} // end of loadCSVData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CSVImport::checkNumCodeHorizontalHeader(const QByteArray &qbaNumCodeHorizontalHeader)
|
||||
{
|
||||
// Soll: 13 Zeichen in einer Zeile getrennt durch `;`
|
||||
DEBUG_LOG(m_logger) << "Data: \"" << qbaNumCodeHorizontalHeader << "\"";
|
||||
DEBUG_LOG(m_logger) << "Data.size: Soll/Ist: 13 + 12 = 25/" << qbaNumCodeHorizontalHeader.size();
|
||||
|
||||
if (qbaNumCodeHorizontalHeader.size() == 25)
|
||||
return true;
|
||||
ERROR_LOG(m_logger) << "Load csv data 'Numeral Code Horizontal Header' failed!";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data 'Numeral Code Horizontal Header' failed!"), tr("CSV Load Error"));
|
||||
return false;
|
||||
} // end of checkNumCodeHorizontalHeader()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CSVImport::checkNumCodeVerticalHeader(const QByteArray &qbaNumCodeVerticalHeader)
|
||||
{
|
||||
// Soll: 13 Zeichen jeweils abgeschlossen mit `\n` (last `\n` removed)
|
||||
DEBUG_LOG(m_logger) << "Data: \"" << qbaNumCodeVerticalHeader << "\"";
|
||||
DEBUG_LOG(m_logger) << "Data.size: Soll/Ist: 13 + 12 = 25/" << qbaNumCodeVerticalHeader.size();
|
||||
|
||||
if (qbaNumCodeVerticalHeader.size() == 25)
|
||||
return true;
|
||||
ERROR_LOG(m_logger) << "Load csv data 'Numeral Code Vertical Header' failed!";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data 'Numeral Code Vertical Header' failed!"), tr("CSV Load Error"));
|
||||
return false;
|
||||
} // end of checkNumCodeVerticalHeader()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CSVImport::checkAuthenticationCodeMatrix(QByteArray &qbaAuthenticationCodeMatrix)
|
||||
{
|
||||
// Soll: 13 Zeilen mit je 5x2 Zeichen getrennt durch `;` Zeile mit `\n` abgeschlossen (last `\n` removed)
|
||||
DEBUG_LOG(m_logger) << "Data: \"" << qbaAuthenticationCodeMatrix << "\"";
|
||||
|
||||
QByteArray qbaOutMatrix;
|
||||
|
||||
QList<QByteArray> qbaLinesList = qbaAuthenticationCodeMatrix.split('\n');
|
||||
|
||||
for (QByteArray &line : qbaLinesList)
|
||||
{
|
||||
QList<QByteArray> qbaLineList = line.split(';');
|
||||
|
||||
for (QByteArray &segment : qbaLineList)
|
||||
{
|
||||
if (segment.size() == 1) // fuehrende Null hinzufuegen
|
||||
segment = segment.rightJustified(2, '0');
|
||||
}
|
||||
line = qbaLineList.join(';');
|
||||
}
|
||||
qbaOutMatrix = qbaLinesList.join('\n');
|
||||
|
||||
qbaAuthenticationCodeMatrix = qbaOutMatrix;
|
||||
|
||||
DEBUG_LOG(m_logger) << "Data.size: Soll/Ist: 13 * (5*2 + 4 + 1) -1 = 194 /" << qbaAuthenticationCodeMatrix.size();
|
||||
|
||||
if (qbaAuthenticationCodeMatrix.size() == 194)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Load csv data 'Authentication Code Matrix' failed!";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data 'Authentication Code Matrix' failed!"), tr("CSV Load Error"));
|
||||
return false;
|
||||
}
|
||||
} // end of checkAuthenticationCodeMatrix()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CSVImport::checkLogTermsTableHorizontalHeader(const QByteArray &qbaLogTermsTableHorizontalHeader)
|
||||
{
|
||||
// Soll: 5 Zeichen in einer Zeile getrennt durch `;`
|
||||
DEBUG_LOG(m_logger) << "Data: \"" << qbaLogTermsTableHorizontalHeader << "\"";
|
||||
DEBUG_LOG(m_logger) << "Data.size: Soll/Ist: 5 + 4 = 9/" << qbaLogTermsTableHorizontalHeader.size();
|
||||
|
||||
if (qbaLogTermsTableHorizontalHeader.size() == 9)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Load csv data 'Logistical Terms Table Horizontal Header' failed!";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data 'Logistical Terms Table Horizontal Header' failed!"), tr("CSV Load Error"));
|
||||
return false;
|
||||
}
|
||||
} // end of checkLogTermsTableHorizontalHeader()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CSVImport::checkLogTermsTableVerticalHeader(const QByteArray &qbaLogTermsTableVerticalHeader)
|
||||
{
|
||||
// Soll: 5 Zeichen jeweils mit `\n` (last `\n` removed)
|
||||
DEBUG_LOG(m_logger) << "Data: \"" << qbaLogTermsTableVerticalHeader << "\"";
|
||||
DEBUG_LOG(m_logger) << "Data.size: Soll/Ist: 5 + 4 = 9/" << qbaLogTermsTableVerticalHeader.size();
|
||||
|
||||
if (qbaLogTermsTableVerticalHeader.size() == 9)
|
||||
return true;
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Load csv data 'Logistical Terms Table Vertical Header' failed!";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data 'Logistical Terms Table Vertical Header' failed!"), tr("CSV Load Error"));
|
||||
return false;
|
||||
}
|
||||
} // end of checkLogTermsTableVerticalHeader()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CSVImport::checkLogTermsTableMatrix(const QByteArray &qbaLogTermsTableMatrix)
|
||||
{
|
||||
// Soll: 5 Zeilen mit jeweils 5 Eintraegen (jeweils max. 2 Zeilen je max 10 Zeichen) getrennt durch `;` jeweils abgeschlossen mit `\n` (last `\n` removed)
|
||||
DEBUG_LOG(m_logger) << "Data: \"" << qbaLogTermsTableMatrix << "\"";
|
||||
|
||||
// split funktioniert hier nicht wenn in einem quoted Eintrag '\n' vorkommt. -> eigene split Funktion verwenden
|
||||
QStringList qsl = m_logisticalTermsModel->splitQuotedStringToRows(QString::fromLatin1(qbaLogTermsTableMatrix));
|
||||
|
||||
DEBUG_LOG(m_logger) << "Line entry size: Soll/Ist: 5/" << qsl.size();
|
||||
|
||||
// check number of seperators
|
||||
if (qsl.size() == 5)
|
||||
{
|
||||
// Begrenzung auf 10 Zeichen per Zeile pruefen...
|
||||
|
||||
// QStringList aus den 25 Matrix Eintraegen erstellen
|
||||
QString qsMatrix = qsl.join(QLatin1Char(';'));
|
||||
QStringList qsl2 = qsMatrix.split(QLatin1Char(';'));
|
||||
|
||||
for (int i = 0; i < qsl2.size(); ++i)
|
||||
{
|
||||
const QString &qsEntry = qsl2.at(i);
|
||||
|
||||
if (! qsEntry.contains(QLatin1Char('\n')))
|
||||
{
|
||||
// non quoted
|
||||
if (qsEntry.size() > 10)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Load csv data 'Logistical Terms Table Matrix' failed! Maximum number of 10 characters per entry line exceeded in cell " << i + 1;
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data 'Logistical Terms Table Matrix' failed! Maximum number of 10 characters per entry line exceeded."), tr("CSV Load Error"));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// quoted
|
||||
if ((qsEntry.size() > 21) || (qsEntry.indexOf(QLatin1Char('\n')) > 10))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Load csv data 'Logistical Terms Table Matrix' failed! Maximum number of 10 characters per entry line exceeded in cell " << i + 1;
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data 'Logistical Terms Table Matrix' failed! Maximum number of 10 characters per entry line exceeded."), tr("CSV Load Error"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Load csv data 'Logistical Terms Table Matrix' failed!";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data 'Logistical Terms Table Matrix' failed!"), tr("CSV Load Error"));
|
||||
return false;
|
||||
}
|
||||
} // end of checkLogTermsTableMatrix()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CSVImport::checkPhraseTableMatrix(const QByteArray &qbaPhraseTableMatrix)
|
||||
{
|
||||
// Soll: 13 Zeilen mit jeweils 2 Eintraegen (jeweils max. 15 Zeichen) getrennt durch `;` jeweils mit `\n` (last `\n` removed)
|
||||
DEBUG_LOG(m_logger) << "Data: \"" << qbaPhraseTableMatrix << "\"";
|
||||
|
||||
const QList<QByteArray> qbaLinesList = qbaPhraseTableMatrix.split('\n');
|
||||
|
||||
// check number of seperators
|
||||
if (qbaLinesList.size() != 13)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Load csv data 'Phrase Table Matrix' failed! Invalid Line entry size: Soll/Ist: 13/" << qbaLinesList.size();
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data 'Phrase Table Matrix' failed! Invalid Line entry size."), tr("CSV Load Error"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Inhalt darf nicht leer sein da das Speichern im Model indiziert auf Basis von 'split()' erfolgt. Bei leeren Eintraegen stimmt dann die Anzahl nicht!!
|
||||
for (const QByteArray &line : qbaLinesList)
|
||||
{
|
||||
const QList<QByteArray> qbaLine = line.split(';');
|
||||
if (qbaLine.size() == 2)
|
||||
{
|
||||
if (qbaLine.at(0).isEmpty() || qbaLine.at(1).isEmpty() || qbaLine.at(0).size() > 15 || qbaLine.at(1).size() > 15)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Load csv data 'Phrase Table Matrix' failed! Invalid number of entrys or entry size is < 1 or >> 15. ";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data 'Phrase Table Matrix' failed! Invalid number of entrys or entry size is less than 1 or greater 15."), tr("CSV Load Error"));
|
||||
return false;
|
||||
}
|
||||
else
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Load csv data 'Phrase Table Matrix' failed! Invalid number of entrys or empty entry per line. ";
|
||||
LtsWidgets::LtsMessageDialog::showMessage(this, tr("Load csv data 'Phrase Table Matrix' failed! Invalid number of entrys or empty entry per line."), tr("CSV Load Error"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} // end of checkPhraseTableMatrix()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CSVImport::removeQuotedCharInNote(QByteArray &qbaNote)
|
||||
{
|
||||
if (qbaNote.startsWith('"'))
|
||||
qbaNote.remove(0, 1);
|
||||
|
||||
if (qbaNote.endsWith('"'))
|
||||
qbaNote.remove(qbaNote.lastIndexOf('"'), 1);
|
||||
|
||||
} // end of removeQuotedCharInNote()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool CSVImport::removeRedundantCvsSeperators(QByteArray &qbaLine, int desiredValue) const
|
||||
{
|
||||
int seperatorCnt = 0;
|
||||
|
||||
// check for csv seperators
|
||||
for (const char c : qAsConst(qbaLine))
|
||||
{
|
||||
if (c == ';')
|
||||
++seperatorCnt;
|
||||
}
|
||||
|
||||
if (seperatorCnt < desiredValue)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Seperator values less than desired values.";
|
||||
return false;
|
||||
}
|
||||
|
||||
while (seperatorCnt > desiredValue)
|
||||
{
|
||||
qbaLine.remove(qbaLine.lastIndexOf(';'), 1);
|
||||
--seperatorCnt;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "+++Data: \"" << qbaLine << "\"" << " Soll/Ist:: " << desiredValue << "/" << seperatorCnt;
|
||||
return true;
|
||||
} // end of removeRedundantCvsSeperators()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationDataManagement - Import codification table csv data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-03-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <CodificationManagement/logger.h>
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class NumeralCodeModel;
|
||||
class AuthenticationCodeModel;
|
||||
class LogisticalTermsModel;
|
||||
class PhraseTableModel;
|
||||
|
||||
|
||||
|
||||
class CSVImport : public QWidget
|
||||
{
|
||||
public:
|
||||
enum CSVImportResult
|
||||
{
|
||||
UserAbort,
|
||||
LoadOk,
|
||||
LoadFailed
|
||||
};
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CSVImport(NumeralCodeModel *numCodeModel,
|
||||
AuthenticationCodeModel *authenticationCodeModel,
|
||||
LogisticalTermsModel *logisticalTermsModel,
|
||||
PhraseTableModel *phraseTableModel,
|
||||
QString *note,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
CSVImportResult loadCSVData();
|
||||
CSVImportResult loadCSVDataByteArray(QByteArray content);
|
||||
|
||||
private:
|
||||
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;
|
||||
|
||||
private:
|
||||
NumeralCodeModel *m_numCodeModel;
|
||||
AuthenticationCodeModel *m_authenticationCodeModel;
|
||||
LogisticalTermsModel *m_logisticalTermsModel;
|
||||
PhraseTableModel *m_phraseTableModel;
|
||||
QString *m_note;
|
||||
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
+475
@@ -0,0 +1,475 @@
|
||||
/**
|
||||
* Model for logistical terms table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-01-13
|
||||
*/
|
||||
|
||||
|
||||
#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)
|
||||
, m_logger(getLogger("LogisticalTermsModel"))
|
||||
{
|
||||
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);
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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) << "LogisticalTermsModel::init()...";
|
||||
|
||||
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;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void LogisticalTermsModel::resetHeader()
|
||||
{
|
||||
// non constant Header values available... werden spaeter mit den Werten aus csv-Datei oder DB gesetzt.
|
||||
m_ColumnSelectionValues = QVector<QChar>(s_matrixCount, QLatin1Char('?'));
|
||||
m_RowSelectionValues = QVector<QChar>(s_matrixCount, QLatin1Char('?'));
|
||||
} // end of resetHeader()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void LogisticalTermsModel::resetMatrix()
|
||||
{
|
||||
beginResetModel();
|
||||
for (auto &colData : m_matrix)
|
||||
{
|
||||
for (auto &cell : colData)
|
||||
cell = QLatin1String("---");
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
// end of resetMatrix()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool LogisticalTermsModel::setColumnSelectionValuesCSV(const QString &csvData)
|
||||
{
|
||||
m_ColumnSelectionValues.clear();
|
||||
m_ColumnSelectionValues.resize(s_matrixCount);
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
} // end of setColumnSelectionValuesCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
} // end of setRowSelectionValuesCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
} // end of setMatrixValuesCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QString LogisticalTermsModel::getHorizontalHeaderCSVString() const
|
||||
{
|
||||
QStringList slColumns;
|
||||
slColumns.reserve(m_ColumnSelectionValues.size());
|
||||
for (const QChar &c : m_ColumnSelectionValues)
|
||||
slColumns += QString(c);
|
||||
|
||||
return slColumns.join(QLatin1Char(';'));
|
||||
} // end of getHorizontalHeaderCSVString()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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'));
|
||||
} // end of getVerticalHeaderCSVString()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QString LogisticalTermsModel::getMatrixDataCSVString() const
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (cell.contains(QLatin1Char('\n')))
|
||||
slColumns += QLatin1Char('\"') + cell + QLatin1Char('\"');
|
||||
else
|
||||
slColumns += cell;
|
||||
}
|
||||
slRows += slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
|
||||
const QString qs(slRows.join(QLatin1Char('\n')));
|
||||
DEBUG_LOG(m_logger) << "getMatrixDataCSVString() : " << qs;
|
||||
return qs;
|
||||
} // end of getMatrixDataCSVString()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void LogisticalTermsModel::setEditMode(bool isEditMode)
|
||||
{
|
||||
m_isEditMode = isEditMode;
|
||||
// DEBUG_LOG(m_logger) << "emit dataChanged() 0/0 up to row: " <<rowCount() - 1 << " col: " << columnCount() - 1;
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1));
|
||||
} // end of setEditMode()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool LogisticalTermsModel::isEditMode() const
|
||||
{
|
||||
return m_isEditMode;
|
||||
} // end of isEditMode();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int LogisticalTermsModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return s_matrixCount + (m_isEditMode ? 1 : 0); // Matrixgroesse + 1 Character fuer RowIndex
|
||||
} // end of rowCount()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int LogisticalTermsModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return s_matrixCount + (m_isEditMode ? 1 : 0); // Matrixgroesse + 1 Character fuer ColumnIndex
|
||||
} // end of columnCount()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant LogisticalTermsModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QAbstractTableModel::headerData(section, orientation, role);
|
||||
|
||||
// Im header nichts anzeigen bzw. in der view die Vertical/horizontal header ausblenden
|
||||
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);
|
||||
} // end of headerData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant LogisticalTermsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole || role == Qt::EditRole)
|
||||
{
|
||||
if (!m_isEditMode)
|
||||
{
|
||||
// DEBUG_LOG(m_logger) << "data() showMode row: " <<index.row() << " col: " << index.column()
|
||||
// << " data: " << m_matrix[index.row() - 1][index.column() - 1];
|
||||
return m_matrix[index.row()][index.column()];
|
||||
}
|
||||
|
||||
if (index.column() == 0 && index.row() == 0)
|
||||
return QVariant();
|
||||
|
||||
// row index ==> column index values
|
||||
if (index.row() == 0 && index.column() <= m_ColumnSelectionValues.size())
|
||||
{
|
||||
// DEBUG_LOG(m_logger) << "data() editMode row: " <<index.row() << " col: " << index.column()
|
||||
// << " ColSelVal: " << m_ColumnSelectionValues[index.column() - 1];
|
||||
return m_ColumnSelectionValues.at(index.column() - 1);
|
||||
}
|
||||
|
||||
// column index ==> row index values
|
||||
if (index.column() == 0 && index.row() <= m_RowSelectionValues.size())
|
||||
{
|
||||
// DEBUG_LOG(m_logger) << "data() editMode row: " <<index.row() << " col: " << index.column()
|
||||
// << " RowSelVal: " << m_RowSelectionValues[index.row() - 1];
|
||||
return m_RowSelectionValues.at(index.row() - 1);
|
||||
}
|
||||
|
||||
// Code Matrix
|
||||
if (index.column() > 0 && index.row() > 0)
|
||||
{
|
||||
// DEBUG_LOG(m_logger) << "data() editMode row: " <<index.row() << " col: " << index.column()
|
||||
// << " data: " << m_matrix[index.row() - 1][index.column() - 1];
|
||||
return m_matrix[index.row() - 1][index.column() - 1]; // row/column fuer header abziehen
|
||||
}
|
||||
}
|
||||
|
||||
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); // Qt:: white
|
||||
return QGuiApplication::palette().color(QPalette::Active, QPalette::Base); // Qt:: white
|
||||
}
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base); // RDE_GRAY
|
||||
// return QGuiApplication::palette().color(QPalette::Active, QPalette::Base); // Qt:: white
|
||||
}
|
||||
return QVariant();
|
||||
} // end of data()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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)
|
||||
{
|
||||
// Input for ColumnSelectionValues
|
||||
if (index.row() == 0)
|
||||
{
|
||||
m_ColumnSelectionValues[index.column() - 1] = qs.at(0);
|
||||
// DEBUG_LOG(m_logger) << "setData() row: " <<index.row() << " col: " << index.column()
|
||||
// << " ColSelVal: " << m_ColumnSelectionValues[index.column() - 1];
|
||||
}
|
||||
|
||||
// Input for RowSelectionValues
|
||||
else if (index.column() == 0 && (index.row() > 0))
|
||||
m_RowSelectionValues[index.row() - 1] = qs.at(0);
|
||||
|
||||
// Matrix
|
||||
else if ((index.column() > 0) && (index.row() > 0))
|
||||
m_matrix[index.row() - 1][index.column() - 1] = qs;
|
||||
emit dataModified();
|
||||
}
|
||||
return true;
|
||||
} // end of setData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
} // end of flags()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void LogisticalTermsModel::onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType)
|
||||
{
|
||||
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;
|
||||
|
||||
if (m_codificationDataId != data.id())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "CodificationData was removed. id: " << id << " ToDo: 'ShowCodificationData' Tab loeschen !?";
|
||||
// set matrix to default values
|
||||
resetMatrix();
|
||||
setColumnSelectionValuesCSV(QString());
|
||||
setRowSelectionValuesCSV(QString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (modType == DataModification::eModified)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "CodificationData was modifed. id: " << id << " - " << data.note();
|
||||
|
||||
QString qs = QString::fromStdString(data.logisticalTermTableColumnIndex());
|
||||
setColumnSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(data.logisticalTermTableRowIndex());
|
||||
setRowSelectionValuesCSV(qs);
|
||||
|
||||
qs = QString::fromStdString(data.logisticalTermTableMatrix());
|
||||
setMatrixValuesCSV(qs);
|
||||
}
|
||||
} // end of onCodificationDataChanged()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QStringList LogisticalTermsModel::splitQuotedStringToRows(const QString &str)
|
||||
{
|
||||
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'))
|
||||
{
|
||||
row.append(str.at(i));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str.at(i) == QLatin1Char('\"'))
|
||||
{
|
||||
++i; // oeffnedes " nicht ausgeben
|
||||
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();
|
||||
}
|
||||
}
|
||||
// wenn die letzte row in String nicht mit \n endet muss sie hier noch angefuegt werden
|
||||
if (!row.isEmpty())
|
||||
slRows += row;
|
||||
return slRows;
|
||||
|
||||
} // end of splitQuotedStringToRows()
|
||||
//-----------------------------------------------------------------------------
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
/**
|
||||
* Model for logistical terms table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-01-13
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <CodificationManagement/cod_dtc.h>
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class LogisticalTermsModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LogisticalTermsModel(QWidget *parent);
|
||||
|
||||
/**
|
||||
* init model internal data matrix
|
||||
* @param dtc access to Data Topic Client
|
||||
* @param codificationDataId id of the used codification data set
|
||||
* @param isEditMode true means model used for edit, otherwise used for show only
|
||||
* in edit mode non update will be done by external data change
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
|
||||
/**
|
||||
* set the horizontal and vertical header to zero
|
||||
*/
|
||||
void resetHeader();
|
||||
|
||||
/**
|
||||
* set the 5x5 code matrix to zero
|
||||
*/
|
||||
void resetMatrix();
|
||||
|
||||
/**
|
||||
* set column selection values
|
||||
* @param data refernce to character set of column selection values
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool setColumnSelectionValuesCSV(const QString &csvData);
|
||||
|
||||
/**
|
||||
* set row selection values
|
||||
* @param data reference to character set of row selection values
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool setRowSelectionValuesCSV(const QString &csvData);
|
||||
|
||||
/**
|
||||
* set matrix values
|
||||
* @param data reference to int data set of matrix values
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool setMatrixValuesCSV(const QString &csvData);
|
||||
|
||||
/**
|
||||
* get horizontal header in csv format
|
||||
* @param -
|
||||
* @return Returns horizontal header in csv format;
|
||||
*/
|
||||
QString getHorizontalHeaderCSVString() const;
|
||||
|
||||
/**
|
||||
* get vertical header in csv format
|
||||
* @param -
|
||||
* @return Returns vertical header in csv format;
|
||||
*/
|
||||
QString getVerticalHeaderCSVString() const;
|
||||
|
||||
/**
|
||||
* get matrix data in csv format
|
||||
* @param -
|
||||
* @return Returns matrix data in csv format;
|
||||
*/
|
||||
QString getMatrixDataCSVString() const;
|
||||
|
||||
/**
|
||||
* set/get edit mode flag used for internal data handling
|
||||
* @param isEditMode true means set edit mode
|
||||
* @return Returns true if edit mode is set, otherwise false
|
||||
*/
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
|
||||
/**
|
||||
* get the row count (MVC-model)
|
||||
* @param ModelIndex
|
||||
* get vertical header in csv forma
|
||||
* @return int Returns the count
|
||||
*/
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
/**
|
||||
* get the row column (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return int Returns the count
|
||||
*/
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
/**
|
||||
* get the header data (MVC-model)
|
||||
* @param section (column)
|
||||
* @param Qt::Orientation
|
||||
* @param role
|
||||
* @return QVariant
|
||||
*/
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
/**
|
||||
* get the data (MVC-model)
|
||||
* @param QModelIndex
|
||||
* @return QVariant
|
||||
*/
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
/**
|
||||
* set the data (MVC-model)
|
||||
* @param QModelIndex
|
||||
* @return bool Returns true if successfull, otherwise returns false
|
||||
*/
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
/**
|
||||
* get flags for the given QModelIndex (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return flags Returns the flags
|
||||
*/
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
/**
|
||||
* split the 'inString' into 'row' substrings, where parts in quotation marks are not split
|
||||
* @param inString input string
|
||||
* @return stringlist of substrings. in case of an error the list will be empty.
|
||||
*/
|
||||
QStringList splitQuotedStringToRows(const QString &str);
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
/**
|
||||
* emits when data was changed (used to enable add/okay button)
|
||||
*/
|
||||
void dataModified();
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType);
|
||||
|
||||
|
||||
// /**
|
||||
// * split the 'inString' into 'row' substrings, where parts in quotation marks are not split
|
||||
// * @param inString input string
|
||||
// * @return stringlist of substrings. in case of an error the list will be empty.
|
||||
// */
|
||||
// QStringList splitQuotedStringToRows(const QString &str);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
QVector<QVector<QString>> m_matrix; ///< Hold the logistical terms table (without row/column select index fields)
|
||||
|
||||
QVector <QChar> m_RowSelectionValues; ///< Hold the row selection index field character
|
||||
QVector <QChar> m_ColumnSelectionValues; ///< Hold the column selection index field character
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
int m_codificationDataId; ///< Id of the used codification data set
|
||||
bool m_isEditMode; ///< Hold the dialog mode setting; if true the indices in row 0 and column 0 can be modified
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
|
||||
+436
@@ -0,0 +1,436 @@
|
||||
/**
|
||||
* Model for numeral code table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-09
|
||||
*/
|
||||
|
||||
|
||||
#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)
|
||||
, m_logger(getLogger("NumeralCodeTableModel"))
|
||||
{
|
||||
} // end of ctor()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool NumeralCodeModel::init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode)
|
||||
{
|
||||
if (!dtc)
|
||||
return false;
|
||||
|
||||
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_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');
|
||||
|
||||
resetHeader();
|
||||
initMatrix();
|
||||
|
||||
if (!isEditMode)
|
||||
{
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged,
|
||||
this, &NumeralCodeModel::onCodificationDataChanged);
|
||||
}
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void NumeralCodeModel::resetHeader()
|
||||
{
|
||||
// DefaultValues... werden spaeter mit den Werten aus csv-Datei oder DB gesetzt.
|
||||
m_ColumnSelectionValues = QVector<QChar>(columnCount() - 1, QLatin1Char('?'));
|
||||
m_RowSelectionValues = QVector<QChar>(rowCount() - 1, QLatin1Char('?'));
|
||||
} // end of resetHeader()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool NumeralCodeModel::setColumnSelectionValuesCSV(const QString &csvData)
|
||||
{
|
||||
m_ColumnSelectionValues = QVector<QChar>(columnCount() - 1, 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)
|
||||
{
|
||||
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;
|
||||
} // end of setColumnSelectionValuesCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool NumeralCodeModel::setRowSelectionValuesCSV(const QString &csvData)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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;
|
||||
} // end of setRowSelectionValuesCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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(';'));
|
||||
} // end of getHorizontalHeaderCSVString()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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"));
|
||||
} // end of getVerticalHeaderCSVString()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void NumeralCodeModel::setEditMode(bool isEditMode)
|
||||
{
|
||||
m_isEditMode = isEditMode;
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
} // end of setEditMode()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool NumeralCodeModel::isEditMode() const
|
||||
{
|
||||
return m_isEditMode;
|
||||
} // end of isEditMode();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int NumeralCodeModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 14; // Matrixgroesse + 1 Character fuer RowIndex
|
||||
} // end of rowCount()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int NumeralCodeModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 14; // Matrixgroesse + 1 Character fuer ColumnIndex
|
||||
} // end of columnCount()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant NumeralCodeModel::headerData(int column, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole )
|
||||
{
|
||||
if (isEditMode())
|
||||
{
|
||||
// Im header nichts anzeigen bzw. in der view die Vertical/horizontal header ausblenden
|
||||
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('?');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if (isEditMode())
|
||||
// group ist hier egal, liefert immer die selbe Farbe
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase); // RDE_LIGHTER_GRAY
|
||||
else
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base); // RDE_GRAY
|
||||
}
|
||||
|
||||
return QAbstractTableModel::headerData(column, orientation, role);
|
||||
} // end of headerData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant NumeralCodeModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if ((role == Qt::DisplayRole || role == Qt::EditRole))
|
||||
{
|
||||
// DEBUG_LOG(m_logger) << "data() display role row: " <<index.row() << " col: " << index.column();
|
||||
if ((index.column() == 0) && (index.row() == 0))
|
||||
return QVariant();
|
||||
|
||||
// row index ==> column index values
|
||||
if (index.row() == 0)
|
||||
{
|
||||
if (!m_ColumnSelectionValues.isEmpty())
|
||||
return m_ColumnSelectionValues[index.column() - 1];
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
|
||||
// column index ==> row index values
|
||||
if ((index.column() == 0))
|
||||
{
|
||||
if (!m_RowSelectionValues.isEmpty())
|
||||
return m_RowSelectionValues[index.row() - 1];
|
||||
return QChar::fromLatin1('?');
|
||||
}
|
||||
|
||||
// Code Matrix
|
||||
if ((index.column() > 0) && (index.row() > 0))
|
||||
{
|
||||
return m_matrix[index.row() - 1][index.column() - 1]; // row/column fuer header abziehen
|
||||
}
|
||||
|
||||
// return QString(QLatin1String("R%1, C%2"))
|
||||
// .arg(index.row() +1)
|
||||
// .arg(index.column() +1 );
|
||||
|
||||
}
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignCenter;
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if ((index.row() > 0) && (index.column() > 0))
|
||||
// Matrix immer disabled
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base); // RDE_GRAY
|
||||
else
|
||||
{
|
||||
if (isEditMode())
|
||||
// group ist hier egal, liefert immer die selbe Farbe
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase); // RDE_LIGHTER_GRAY
|
||||
else
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base); // RDE_GRAY
|
||||
}
|
||||
}
|
||||
|
||||
if (role == Qt::ForegroundRole)
|
||||
{
|
||||
if ((index.row() == 0) && (index.column() == 0))
|
||||
return QColor(Qt::red);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
||||
} // end of data()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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();
|
||||
|
||||
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;
|
||||
|
||||
const QChar c = tmp.at(0);
|
||||
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
// Input for ColumnSelectionValues
|
||||
if (index.row() == 0)
|
||||
m_ColumnSelectionValues[index.column() - 1] = c;
|
||||
// Input for RowSelectionValues
|
||||
if (index.column() == 0 && (index.row() > 0))
|
||||
m_RowSelectionValues[index.row() - 1] = c;
|
||||
emit dataModified();
|
||||
}
|
||||
|
||||
return true;
|
||||
} // end of setData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
} // end of flags()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void NumeralCodeModel::initMatrix()
|
||||
{
|
||||
int lastMatrixValueCnt = 0;
|
||||
int lastMatrixCharacterCnt = 0;
|
||||
int lastMatrixCharacterIndex = 0;
|
||||
int numOfCharacter = 4;
|
||||
|
||||
for (int row = 0; row < 13; ++row)
|
||||
{
|
||||
// Neue Zeile mit Ziffer der letzten Zeile beginnen
|
||||
if (row > 3)
|
||||
{
|
||||
numOfCharacter = 3;
|
||||
lastMatrixValueCnt -= 1;
|
||||
}
|
||||
|
||||
// Ab Zeile 9 CharacterSet2 verwenden
|
||||
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;
|
||||
}
|
||||
|
||||
// Im ersten Teil den CharacterSet1 verwenden
|
||||
if ((row < 9) && (lastMatrixCharacterIndex == 26))
|
||||
lastMatrixCharacterIndex = 0;
|
||||
|
||||
// Im restlichen Teil den CharacterSet2 verwenden
|
||||
if ((row >= 9) && (lastMatrixCharacterIndex == 12))
|
||||
lastMatrixCharacterIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Check m_matrix---
|
||||
// QString qs;
|
||||
// for (int row = 0; row < 13; ++row)
|
||||
// {
|
||||
// for (int col = 0; col < 13; ++col)
|
||||
// {
|
||||
// qs.append(m_matrix[row][col]);
|
||||
// qs.append(QLatin1String("; "));
|
||||
// }
|
||||
// qs.append(QLatin1String("\n"));
|
||||
// }
|
||||
// QString qs1(QLatin1String("\n"));
|
||||
// qs1.append(qs);
|
||||
// DEBUG_LOG(m_logger) << qs1;
|
||||
|
||||
return;
|
||||
} // end of initMatrix()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void NumeralCodeModel::onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType)
|
||||
{
|
||||
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;
|
||||
|
||||
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::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);
|
||||
}
|
||||
} // end of onCodificationDataChanged()
|
||||
//-----------------------------------------------------------------------------
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
/**
|
||||
* Model for numeral code table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-09
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <CodificationManagement/cod_dtc.h>
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class NumeralCodeModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NumeralCodeModel(QWidget *parent);
|
||||
|
||||
~NumeralCodeModel() = default;
|
||||
|
||||
/**
|
||||
* init model internal data matrix
|
||||
* @param dtc access to Data Topic Client
|
||||
* @param codificationDataId id of the used codification data set
|
||||
* @param isEditMode true means model used for edit, otherwise used for show only
|
||||
* in edit mode non update will be done by external data change
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
|
||||
/**
|
||||
* set the horizontal and vertical header to zero
|
||||
*/
|
||||
void resetHeader();
|
||||
|
||||
/**
|
||||
* set column selection values
|
||||
* @param data refernce to character set of column selection values
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool setColumnSelectionValuesCSV(const QString &csvData);
|
||||
|
||||
/**
|
||||
* set row selection values
|
||||
* @param data reference to character set of row selection values
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool setRowSelectionValuesCSV(const QString &csvData);
|
||||
|
||||
/**
|
||||
* get horizontal header in csv format
|
||||
* @param -
|
||||
* @return Returns horizontal header in csv format;
|
||||
*/
|
||||
QString getHorizontalHeaderCSVString() const;
|
||||
|
||||
/**
|
||||
* get vertical header in csv format
|
||||
* @param -
|
||||
* @return Returns vertical header in csv format;
|
||||
*/
|
||||
QString getVerticalHeaderCSVString() const;
|
||||
|
||||
/**
|
||||
* set/get edit mode flag used for internal data handling
|
||||
* @param isEditMode true means set edit mode
|
||||
* @return Returns true if edit mode is set, otherwise false
|
||||
*/
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
|
||||
/**
|
||||
* get the row count (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return int Returns the count
|
||||
*/
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
/**
|
||||
* get the row column (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return int Returns the count
|
||||
*/
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
/**
|
||||
* get the header data (MVC-model)
|
||||
* @param section (column)
|
||||
* @param Qt::Orientation
|
||||
* @param role
|
||||
* @return QVariant
|
||||
*/
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
/**
|
||||
* get the data (MVC-model)
|
||||
* @param QModelIndex
|
||||
* @return QVariant
|
||||
*/
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
/**
|
||||
* set the data (MVC-model)
|
||||
* @param QModelIndex
|
||||
* @return bool Returns true if successfull, otherwise returns false
|
||||
*/
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
/**
|
||||
* get flags for the given QModelIndex (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return flags Returns the flags
|
||||
*/
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
/**
|
||||
* emits when data was changed (used to enable add/okay button)
|
||||
*/
|
||||
void dataModified();
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* init the constant 13x13 code matrix
|
||||
*/
|
||||
void initMatrix();
|
||||
|
||||
QVector <QChar> m_MatrixNumeralSet; ///< Numeral Set 0-9
|
||||
QVector <QChar> m_MatrixCharacterSet1; ///< Character set 1 A-Z 26 Character
|
||||
QVector <QChar> m_MatrixCharacterSet2; ///< Character set 2 especially 12 Character D...U
|
||||
|
||||
QChar m_matrix[13][13]; ///< Hold the numeral code table (without row/column selcet index fields)
|
||||
|
||||
QVector <QChar> m_RowSelectionValues; ///< Hold the row selection index field character
|
||||
QVector <QChar> m_ColumnSelectionValues; ///< Hold the column selection index field character
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
int m_codificationDataId; ///< Id of the used codification data set
|
||||
bool m_isEditMode; ///< Hold the dialog mode setting; if true the indices in row 0 and column 0 can be modified
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
+307
@@ -0,0 +1,307 @@
|
||||
/**
|
||||
* Model for phrase table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-01-19
|
||||
*/
|
||||
|
||||
|
||||
#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)
|
||||
, m_logger(getLogger("PhraseTableModel"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ctor PhraseTableModel";
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
|
||||
m_dtc = dtc;
|
||||
m_codificationDataId = codificationDataId;
|
||||
m_isEditMode = isEditMode;
|
||||
|
||||
// non header values used, header not visible
|
||||
resetMatrix();
|
||||
|
||||
if (!isEditMode)
|
||||
{
|
||||
connect(m_dtc.get(), &CodificationManagement::Interface::Dtc::codificationDataChanged,
|
||||
this, &PhraseTableModel::onCodificationDataChanged);
|
||||
}
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PhraseTableModel::resetMatrix()
|
||||
{
|
||||
for (int row = 0; row < rowCount(); ++row)
|
||||
{
|
||||
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("--- ");
|
||||
}
|
||||
}
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
return ;
|
||||
} // end of resetMatrix()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool PhraseTableModel::setMatrixValuesCSV(const QString &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())
|
||||
{
|
||||
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;
|
||||
} // end of setMatrixValuesCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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)
|
||||
{
|
||||
const QString &cell = m_matrix[row][column];
|
||||
if (cell.contains(QLatin1Char(';')))
|
||||
slColumns += QLatin1Char('\"') + cell + QLatin1Char('\"');
|
||||
else
|
||||
slColumns += cell;
|
||||
}
|
||||
slRows << slColumns.join(QLatin1Char(';'));
|
||||
}
|
||||
return slRows.join(QLatin1Char('\n'));
|
||||
} // end of getMatrixDataCSVString()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PhraseTableModel::setEditMode(bool isEditMode)
|
||||
{
|
||||
m_isEditMode = isEditMode;
|
||||
// DEBUG_LOG(m_logger) << "emit dataChanged() 0/0 up to row: " <<rowCount() - 1 << " col: " << columnCount() - 1;
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
} // end of setEditMode()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool PhraseTableModel::isEditMode() const
|
||||
{
|
||||
return m_isEditMode;
|
||||
} // end of isEditMode();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int PhraseTableModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 13;
|
||||
} // end of rowCount()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int PhraseTableModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 2; // Matrixgroesse
|
||||
} // end of columnCount()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant PhraseTableModel::headerData(int column, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QAbstractTableModel::headerData(column, orientation, role);
|
||||
|
||||
// Im header nichts anzeigen bzw. in der view die Vertical/horizontal header ausblenden
|
||||
return QVariant();
|
||||
} // end of headerData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant PhraseTableModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if ((role == Qt::DisplayRole || role == Qt::EditRole))
|
||||
{
|
||||
// DEBUG_LOG(m_logger) << "data() showMode row: " <<index.row() << " col: " << index.column()
|
||||
// << " data: " << m_matrix[index.row()][index.column()];
|
||||
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 (m_isEditMode)
|
||||
{
|
||||
// return QColor(Qt::darkYellow);
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::AlternateBase); // RDE_LIGHTER_GRAY
|
||||
}
|
||||
else
|
||||
// return QColor(Qt::darkGray);
|
||||
return QGuiApplication::palette().color(QPalette::Disabled, QPalette::Base); // RDE_GRAY
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
} // end of data()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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();
|
||||
|
||||
// Input of ';' character works, but is also prevented because of the equal treatment to other tables
|
||||
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))
|
||||
{
|
||||
m_matrix[index.row()][index.column()] = qs;
|
||||
emit dataModified();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} // end of setData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Qt::ItemFlags PhraseTableModel::flags(const QModelIndex &index) const
|
||||
{
|
||||
Qt::ItemFlags flags = QAbstractTableModel::flags(index);
|
||||
|
||||
if (isEditMode())
|
||||
{
|
||||
if ((index.row() <= rowCount()-1) && (index.column() <= columnCount() - 1))
|
||||
flags |= Qt::ItemIsEditable;
|
||||
|
||||
// Die obersten 3 Felder der ersten Spalte sind nicht editierbar!
|
||||
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;
|
||||
} // end of flags()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PhraseTableModel::onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType)
|
||||
{
|
||||
const int id = data.id();
|
||||
|
||||
DEBUG_LOG(m_logger) << "onCodificationDataChanged for CodificationData id: " << id
|
||||
<< " - PhraseTableModel data: " << data.phraseTable().c_str()
|
||||
<< " - modType: " << (int)modType;
|
||||
|
||||
if (m_codificationDataId != data.id())
|
||||
return;
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
WARNING_LOG(m_logger) << "CodificationData was removed. id: " << id << " ToDo: 'ShowCodificationData' Tab loeschen !?";
|
||||
// set matrix to default values
|
||||
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);
|
||||
}
|
||||
} // end of onCodificationDataChanged()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
} // end of splitQuotedString()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* Model for phrase table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-01-19
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include <CodificationManagement/logger.h>
|
||||
#include <CodificationManagement/cod_dtc.h>
|
||||
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
|
||||
class PhraseTableModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PhraseTableModel(QWidget *parent);
|
||||
|
||||
~PhraseTableModel() = default;
|
||||
|
||||
/**
|
||||
* init model internal data matrix
|
||||
* @param dtc access to Data Topic Client
|
||||
* @param codificationDataId id of the used codification data set
|
||||
* @param isEditMode true means model used for edit, otherwise used for show only
|
||||
* in edit mode non update will be done by external data change
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool init(const std::shared_ptr<CodificationManagement::Interface::Dtc> &dtc,
|
||||
int codificationDataId,
|
||||
bool isEditMode = false);
|
||||
|
||||
/**
|
||||
* set the 13x2 code matrix to zero
|
||||
*/
|
||||
void resetMatrix();
|
||||
|
||||
/**
|
||||
* set matrix values
|
||||
* @param data reference to int data set of matrix values
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool setMatrixValuesCSV(const QString &csvData);
|
||||
|
||||
/**
|
||||
* get matrix data in csv format
|
||||
* @param -
|
||||
* @return Returns matrix data in csv format;
|
||||
*/
|
||||
QString getMatrixDataCSVString() const;
|
||||
|
||||
/**
|
||||
* set/get edit mode flag used for internal data handling
|
||||
* @param isEditMode true means set edit mode
|
||||
* @return Returns true if edit mode is set, otherwise false
|
||||
*/
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
|
||||
/**
|
||||
* get the row count (MVC-model)
|
||||
* @param ModelIndex
|
||||
* get vertical header in csv forma
|
||||
* @return int Returns the count
|
||||
*/
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
/**
|
||||
* get the row column (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return int Returns the count
|
||||
*/
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
/**
|
||||
* get the header data (MVC-model)
|
||||
* @param section (column)
|
||||
* @param Qt::Orientation
|
||||
* @param role
|
||||
* @return QVariant
|
||||
*/
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
/**
|
||||
* get the data (MVC-model)
|
||||
* @param QModelIndex
|
||||
* @return QVariant
|
||||
*/
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
/**
|
||||
* set the data (MVC-model)
|
||||
* @param QModelIndex
|
||||
* @return bool Returns true if successfull, otherwise returns false
|
||||
*/
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
/**
|
||||
* get flags for the given QModelIndex (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return flags Returns the flags
|
||||
*/
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
/**
|
||||
* emits when data was changed (used to enable add/okay button)
|
||||
*/
|
||||
void dataModified();
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCodificationDataChanged(const CodificationManagement::CodificationData &data,
|
||||
DataModification modType);
|
||||
|
||||
private:
|
||||
/**
|
||||
* split the 'inString' into substrings, where string in quotation marks are not split
|
||||
* If 'sep' does not match anywhere in the 'inString', function returns a single-element list containing this string.
|
||||
* @param sep seperator character
|
||||
* @param inString input string
|
||||
* @return stringlist of substrings
|
||||
*/
|
||||
QStringList splitQuotedString(const QChar &sep, const QString &inString);
|
||||
|
||||
private:
|
||||
|
||||
// /**
|
||||
// * set the 13x2 code matrix to zero
|
||||
// */
|
||||
// void resetMatrix();
|
||||
|
||||
QString m_matrix[13][2]; ///< Hold the phrase table (without row/column select index fields)
|
||||
|
||||
std::shared_ptr<CodificationManagement::Interface::Dtc> m_dtc;
|
||||
|
||||
int m_codificationDataId; ///< Id of the used codification data set
|
||||
bool m_isEditMode; ///< Hold the dialog mode setting; if true the indices in row 0 and column 0 can be modified
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
|
||||
|
||||
|
||||
SET(lt_SRCS
|
||||
main.cpp
|
||||
maindialog.h
|
||||
maindialog.cpp
|
||||
cod_numeral_code_model.h
|
||||
cod_numeral_code_model.cpp
|
||||
ui/maindialog.ui
|
||||
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(lt_SRCS ui/maindialog.ui)
|
||||
|
||||
NGL_ADD_EXECUTABLE(WS CODTest ${lt_SRCS})
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(CODTest
|
||||
Qt5::Widgets
|
||||
Qt5::Core
|
||||
nglapplication
|
||||
NGLLogger
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET_DEVEL(CODTest)
|
||||
NGL_INSTALL(WS FILES log4cxx_cod_test.props DESTINATION bin COMPONENT Devel)
|
||||
|
||||
@@ -0,0 +1,383 @@
|
||||
/**
|
||||
* Model for numeral code table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-02
|
||||
*/
|
||||
|
||||
|
||||
#include "cod_numeral_code_model.h"
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QTime>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
NumeralCodeModel::NumeralCodeModel(QWidget *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
, m_isEditMode(false)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("COD_Test_NumeralCodeTableModel"))
|
||||
{
|
||||
init();
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NumeralCodeModel::~NumeralCodeModel()
|
||||
{
|
||||
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool NumeralCodeModel::init()
|
||||
{
|
||||
m_MatrixNumeralSet << '0' << '1' << '2' << '3' << '4'
|
||||
<< '5' << '6' << '7' << '8' << '9';
|
||||
|
||||
|
||||
m_MatrixCharacterSet1 << 'A' << 'B' << 'C' << 'D' << 'E' << 'F'
|
||||
<< 'G' << 'H' << 'I' << 'J' << 'K' << 'L'
|
||||
<< 'M' << 'N' << 'O' << 'P' << 'Q' << 'R'
|
||||
<< 'S' << 'T' << 'U' << 'V' << 'W' << 'X'
|
||||
<< 'Y' << 'Z';
|
||||
|
||||
m_MatrixCharacterSet2 << 'D' << 'E' << 'G' << 'H' << 'I' << 'L'
|
||||
<< 'N' << 'O' << 'R' << 'S' << 'T' << 'U';
|
||||
|
||||
|
||||
|
||||
// DefaultValues... werden spaeter mit den Werten aus csv-Datei oder DB gesetzt.
|
||||
m_ColumnSelectionValues << 'A' << 'B' << 'C'
|
||||
<< 'D' << 'E' << 'F'
|
||||
<< 'G' << 'H' << 'I'
|
||||
<< 'J' << 'K' << 'L'
|
||||
<< 'M' ;
|
||||
|
||||
// DefaultValues... werden spaeter mit den Werten aus csv-Datei oder DB gesetzt.
|
||||
m_RowSelectionValues << 'a' << 'b' << 'c'
|
||||
<< 'd' << 'e' << 'f'
|
||||
<< 'g' << 'h' << 'i'
|
||||
<< 'j' << 'k' << 'l'
|
||||
<< 'm' ;
|
||||
|
||||
|
||||
return initMatrix();
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool NumeralCodeModel::setColumnSelectionValues(const QVector <char> &data)
|
||||
{
|
||||
m_ColumnSelectionValues = data;
|
||||
emit dataChanged(createIndex(0, 0), createIndex(0, columnCount() - 1));
|
||||
return true;
|
||||
} // end of setColumnSelectionValues()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool NumeralCodeModel::setColumnSelectionValuesCSV(const QVector<char> &csvData)
|
||||
{
|
||||
QStringList qsList;
|
||||
for (int i = 0; i < csvData.size(); ++i)
|
||||
{
|
||||
if (QLatin1Char(csvData.at(i)) != QLatin1Char(';'))
|
||||
qsList.append(QString(QLatin1Char(csvData.at(i))));
|
||||
}
|
||||
|
||||
// DEBUG_LOG(m_logger) << "setColumnSelectionValuesCSV() "
|
||||
// << " csvData.size(): " << csvData.size()
|
||||
// << " qsList.size: " << qsList.size()
|
||||
// ;
|
||||
|
||||
QVector <char> data;
|
||||
for (int i = 0; i < qsList.size(); ++i)
|
||||
{
|
||||
const QString &qs = qsList.at(i);
|
||||
if (qs.isEmpty())
|
||||
continue;
|
||||
|
||||
char c = qs.at(0).toLatin1();
|
||||
data.append(c);
|
||||
}
|
||||
return setColumnSelectionValues(data);;
|
||||
} // end of setColumnSelectionValuesCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool NumeralCodeModel::setRowSelectionValues(const QVector <char> &data)
|
||||
{
|
||||
m_RowSelectionValues = data;
|
||||
emit dataChanged(createIndex(0, 0), createIndex(0, columnCount() - 1));
|
||||
return true;
|
||||
} // end of setRowSelectionValues()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool NumeralCodeModel::setRowSelectionValuesCSV(const QVector<char> &csvData)
|
||||
{
|
||||
QStringList qsList;
|
||||
for (int i = 0; i < csvData.size(); ++i)
|
||||
{
|
||||
if (QLatin1Char(csvData.at(i)) != QLatin1Char(';'))
|
||||
qsList.append(QString(QLatin1Char(csvData.at(i))));
|
||||
}
|
||||
|
||||
QVector <char> data;
|
||||
for (int i = 0; i < qsList.size(); ++i)
|
||||
{
|
||||
const QString &qs = qsList.at(i);
|
||||
if (qs.isEmpty())
|
||||
continue;
|
||||
|
||||
char c = qs.at(0).toLatin1();
|
||||
data.append(c);
|
||||
}
|
||||
return setRowSelectionValues(data);
|
||||
} // end of setRowSelectionValuesCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVector<char> NumeralCodeModel::getHorizontalHeaderCSV() const
|
||||
{
|
||||
QVector <char> qVec;
|
||||
qVec.reserve(m_ColumnSelectionValues.size() * 2);
|
||||
for (int i = 0; i < m_ColumnSelectionValues.size(); ++i)
|
||||
{
|
||||
qVec.append(m_ColumnSelectionValues.at(i));
|
||||
qVec.append(';');
|
||||
}
|
||||
// remove last separator
|
||||
qVec.remove(m_ColumnSelectionValues.size() * 2 - 1);
|
||||
|
||||
return qVec;
|
||||
} // end of getHorizontalHeaderCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVector <char> NumeralCodeModel::getVerticalHeaderCSV() const
|
||||
{
|
||||
QVector <char> qVec;
|
||||
qVec.reserve(m_RowSelectionValues.size() * 2);
|
||||
for (int i = 0; i < m_RowSelectionValues.size(); ++i)
|
||||
{
|
||||
qVec.append(m_RowSelectionValues.at(i));
|
||||
qVec.append(';');
|
||||
}
|
||||
// remove last separator
|
||||
qVec.remove(m_RowSelectionValues.size() * 2 - 1);
|
||||
|
||||
return qVec;
|
||||
} // end of getVerticalHeaderCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void NumeralCodeModel::setEditMode(bool isEditMode)
|
||||
{
|
||||
m_isEditMode = isEditMode;
|
||||
// DEBUG_LOG(m_logger) << "emit dataChanged() 0/0 up to row: " <<rowCount() << " col: " << columnCount();
|
||||
emit dataChanged(createIndex(0, 0), createIndex(rowCount() - 1, columnCount() - 1));
|
||||
|
||||
} // end of setEditMode()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool NumeralCodeModel::isEditMode() const
|
||||
{
|
||||
return m_isEditMode;
|
||||
} // end of isEditMode();
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int NumeralCodeModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 14; // Matrixgroesse + 1 Character fuer RowIndex
|
||||
} // end of rowCount()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
int NumeralCodeModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return 14; // Matrixgroesse + 1 Character fuer ColumnIndex
|
||||
} // end of columnCount()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant NumeralCodeModel::headerData(int column, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role != Qt::DisplayRole)
|
||||
return QAbstractTableModel::headerData(column, orientation, role);
|
||||
|
||||
if (isEditMode())
|
||||
{
|
||||
// Im header nichts anzeigen bzw. in der view die Vertical/horizontal header ausblenden
|
||||
return QVariant();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (column == 0)
|
||||
return QVariant();
|
||||
if (orientation == Qt::Horizontal)
|
||||
return QChar::fromLatin1(m_ColumnSelectionValues.at(column - 1));
|
||||
if (orientation == Qt::Vertical)
|
||||
return QChar::fromLatin1(m_RowSelectionValues.at(column - 1));
|
||||
}
|
||||
|
||||
return QAbstractTableModel::headerData(column, orientation, role);
|
||||
} // end of headerData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
QVariant NumeralCodeModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if ((role == Qt::DisplayRole || role == Qt::EditRole))
|
||||
{
|
||||
// DEBUG_LOG(m_logger) << "data() display role row: " <<index.row() << " col: " << index.column();
|
||||
if ((index.column() == 0) && (index.row() == 0))
|
||||
return QVariant();
|
||||
|
||||
// row index ==> column index values
|
||||
if (index.row() == 0)
|
||||
return QChar::fromLatin1(m_ColumnSelectionValues[index.column() - 1]);
|
||||
|
||||
// column index ==> row index values
|
||||
if ((index.column() == 0))
|
||||
return QChar::fromLatin1(m_RowSelectionValues[index.row() - 1]);
|
||||
|
||||
// Code Matrix
|
||||
if ((index.column() > 0) && (index.row() > 0))
|
||||
{
|
||||
return QChar::fromLatin1(m_matrix[index.row() - 1][index.column() - 1]); // row/column fuer header abziehen
|
||||
}
|
||||
|
||||
// return QString(QLatin1String("R%1, C%2"))
|
||||
// .arg(index.row() +1)
|
||||
// .arg(index.column() +1 );
|
||||
|
||||
}
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
return Qt::AlignCenter;
|
||||
|
||||
if (role == Qt::BackgroundRole)
|
||||
{
|
||||
if ((index.row() > 0) && (index.column() > 0))
|
||||
{
|
||||
if (m_isEditMode)
|
||||
return QColor(Qt::darkRed);
|
||||
else
|
||||
return QColor(Qt::darkGray);
|
||||
}
|
||||
else
|
||||
return QColor(Qt::darkYellow);
|
||||
}
|
||||
|
||||
if (role == Qt::ForegroundRole)
|
||||
{
|
||||
if ((index.row() == 0) && (index.column() == 0))
|
||||
return QColor(Qt::red);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
||||
} // end of data()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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();
|
||||
|
||||
QString tmp = value.toString();
|
||||
if (tmp.isEmpty())
|
||||
return false;
|
||||
|
||||
const char c = tmp.at(0).toLatin1();
|
||||
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
// Input for ColumnSelectionValues
|
||||
if (index.row() == 0)
|
||||
m_ColumnSelectionValues[index.column() - 1] = c;
|
||||
// Input for RowSelectionValues
|
||||
if (index.column() == 0 && (index.row() > 0))
|
||||
m_RowSelectionValues[index.row() - 1] = c;
|
||||
}
|
||||
|
||||
return true;
|
||||
} // end of setData()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
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)))
|
||||
flags |= Qt::ItemIsEditable;
|
||||
|
||||
return flags;
|
||||
} // end of flags()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool NumeralCodeModel::initMatrix()
|
||||
{
|
||||
int lastMatrixValueCnt = 0;
|
||||
int lastMatrixCharacterCnt = 0;
|
||||
int lastMatrixCharacterIndex = 0;
|
||||
int numOfCharacter = 4;
|
||||
|
||||
for (int row = 0; row < 13; ++row)
|
||||
{
|
||||
// Neue Zeile mit Ziffer der letzten Zeile beginnen
|
||||
if (row > 3)
|
||||
{
|
||||
numOfCharacter = 3;
|
||||
lastMatrixValueCnt -= 1;
|
||||
}
|
||||
|
||||
// Ab Zeile 9 CharacterSet2 verwenden
|
||||
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;
|
||||
}
|
||||
|
||||
// Im ersten Teil den CharacterSet1 verwenden
|
||||
if ((row < 9) && (lastMatrixCharacterIndex == 26))
|
||||
lastMatrixCharacterIndex = 0;
|
||||
|
||||
// Im restlichen Teil den CharacterSet2 verwenden
|
||||
if ((row >= 9) && (lastMatrixCharacterIndex == 12))
|
||||
lastMatrixCharacterIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Check m_matrix---
|
||||
QString qs;
|
||||
for (int row = 0; row < 13; ++row)
|
||||
{
|
||||
for (int col = 0; col < 13; ++col)
|
||||
{
|
||||
qs.append(QLatin1Char(m_matrix[row][col]));
|
||||
qs.append(QLatin1String("; "));
|
||||
}
|
||||
qs.append(QLatin1String("\n"));
|
||||
}
|
||||
QString qs1(QLatin1String("\n"));
|
||||
qs1.append(qs);
|
||||
// DEBUG_LOG(m_logger) << qs1;
|
||||
|
||||
return true;
|
||||
} // end of initMatrix()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* Model for numeral code table
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-02
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
class NumeralCodeModel final : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NumeralCodeModel(QWidget *parent);
|
||||
|
||||
~NumeralCodeModel();
|
||||
|
||||
/**
|
||||
* init model internal data matrix
|
||||
* @param -
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool init();
|
||||
|
||||
/**
|
||||
* set column selection values
|
||||
* @param data refernce to character set of column selection values
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool setColumnSelectionValues(const QVector<char> &data);
|
||||
bool setColumnSelectionValuesCSV(const QVector<char> &csvData);
|
||||
|
||||
/**
|
||||
* set model internal data matrix
|
||||
* @param data reference to character set of row selection values
|
||||
* @return Returns true on success, otherwise false
|
||||
*/
|
||||
bool setRowSelectionValues(const QVector<char> &data);
|
||||
bool setRowSelectionValuesCSV(const QVector<char> &csvData);
|
||||
|
||||
/**
|
||||
* get horizontal header in csv format
|
||||
* @param -
|
||||
* @return Returns horizontal header in csv format; (vectorsize must be 26).
|
||||
*/
|
||||
QVector <char> getHorizontalHeaderCSV() const;
|
||||
/**
|
||||
* get vertical header in csv format
|
||||
* @param -
|
||||
* @return Returns vertical header in csv format; (vectorsize must be 26).
|
||||
*/
|
||||
QVector <char> getVerticalHeaderCSV() const;
|
||||
|
||||
|
||||
/**
|
||||
* set/get edit mode flag used for internal data handling
|
||||
* @param isEditMode true means set edit mode
|
||||
* @return Returns true if edit mode is set, otherwise false
|
||||
*/
|
||||
void setEditMode(bool isEditMode);
|
||||
bool isEditMode() const;
|
||||
|
||||
/**
|
||||
* get the row count (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return int Returns the count
|
||||
*/
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
/**
|
||||
* get the row column (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return int Returns the count
|
||||
*/
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
|
||||
/**
|
||||
* get the header data (MVC-model)
|
||||
* @param section (column)
|
||||
* @param Qt::Orientation
|
||||
* @param role
|
||||
* @return QVariant
|
||||
*/
|
||||
QVariant headerData(int column, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
||||
|
||||
/**
|
||||
* get the data (MVC-model)
|
||||
* @param QModelIndex
|
||||
* @return QVariant
|
||||
*/
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
/**
|
||||
* set the data (MVC-model)
|
||||
* @param QModelIndex
|
||||
* @return bool Returns true if successfull, otherwise returns false
|
||||
*/
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||
|
||||
/**
|
||||
* get flags for the given QModelIndex (MVC-model)
|
||||
* @param ModelIndex
|
||||
* @return flags Returns the flags
|
||||
*/
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* init the constant 13x13 code matrix
|
||||
* @param ModelIndex
|
||||
* @return flags Returns the flags
|
||||
*/
|
||||
bool initMatrix();
|
||||
|
||||
QVector <char> m_MatrixNumeralSet; ///< Numeral Set 0-9
|
||||
QVector <char> m_MatrixCharacterSet1; ///< Character set 1 A-Z 26 Character
|
||||
QVector <char> m_MatrixCharacterSet2; ///< Character set 2 especially 12 Character D...U
|
||||
|
||||
char m_matrix[13][13]; ///< Hold the numeral code table (without row/column selcet index fields)
|
||||
|
||||
QVector <char> m_RowSelectionValues; ///< Hold the row selcetion index field character
|
||||
QVector <char> m_ColumnSelectionValues; ///< Hold the column selcetion index field character
|
||||
|
||||
bool m_isEditMode; ///< Hold the dialog mode setting; if true the indices in row 0 and column 0 can be modified
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
@@ -0,0 +1,78 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# Test: Codification
|
||||
###########################################################
|
||||
|
||||
log4j.logger.COD_Test_NumeralCodeTableMainDialog=DEBUG
|
||||
log4j.logger.COD_Test_NumeralCodeTableModel=DEBUG
|
||||
|
||||
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.file=${LOG4QT_LOGDIR}/${LOG4QT_USER}_cod.log
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# INFO,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
# Examples for files:
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <nglapplication/nglapplication.h>
|
||||
#include "maindialog.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLApplication app(argc, argv);
|
||||
QCoreApplication::setApplicationName(QLatin1String("Numeral Codification Table"));
|
||||
QCoreApplication::setOrganizationName(QLatin1String("RME"));
|
||||
|
||||
app.createLogger("CodificationTable", "log4cxx_cod_test.props");
|
||||
NGL::INGLLogger &logger = app.baseLogger();
|
||||
|
||||
STARTUP_LOG(logger);
|
||||
|
||||
MainDialog w;
|
||||
w.init();
|
||||
w.show();
|
||||
|
||||
// app.setQuitOnLastWindowClosed(true);
|
||||
|
||||
int retval = app.exec();
|
||||
|
||||
SHUTDOWN_LOG(logger);
|
||||
|
||||
return retval;
|
||||
}
|
||||
+216
@@ -0,0 +1,216 @@
|
||||
/**
|
||||
* Maindialog for codification dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-02
|
||||
*/
|
||||
|
||||
#include "maindialog.h"
|
||||
#include "ui_maindialog.h"
|
||||
|
||||
#include "cod_numeral_code_model.h"
|
||||
|
||||
#include <QVector>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
|
||||
MainDialog::MainDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(new Ui::MainDialog)
|
||||
, m_numCodeModel(new NumeralCodeModel(parent))
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("COD_Test_NumeralCodeTableMainDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
MainDialog::~MainDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool MainDialog::init()
|
||||
{
|
||||
bool bOk = initNumeralModel();
|
||||
|
||||
connect(m_ui->cbEditMode, &QCheckBox::toggled,
|
||||
this, &MainDialog::onCbEditModeToggled);
|
||||
|
||||
|
||||
// connect(m_ui->pbSetHorizontalHeader, &QPushButton::clicked,
|
||||
// this, &MainDialog::onPbSetHorizontalHeader);
|
||||
|
||||
connect(m_ui->pbSetHorizontalHeader, &QPushButton::clicked,
|
||||
this, &MainDialog::onPbSetHorizontalHeaderCSV);
|
||||
|
||||
// connect(m_ui->pbSetVerticalHeader, &QPushButton::clicked,
|
||||
// this, &MainDialog::onPbSetVerticalHeader);
|
||||
|
||||
connect(m_ui->pbSetVerticalHeader, &QPushButton::clicked,
|
||||
this, &MainDialog::onPbSetVerticalHeaderCSV);
|
||||
|
||||
// Starten im UserMode (nicht editierbar)
|
||||
m_ui->cbEditMode->setChecked(false);
|
||||
onCbEditModeToggled(false);
|
||||
m_ui->pbSetHorizontalHeader->setEnabled(false);
|
||||
m_ui->pbSetVerticalHeader->setEnabled(false);
|
||||
|
||||
return bOk;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool MainDialog::initNumeralModel()
|
||||
{
|
||||
m_ui->tvNumeralCode->setModel(m_numCodeModel);
|
||||
|
||||
QHeaderView *header = m_ui->tvNumeralCode->horizontalHeader();
|
||||
// header->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
header->setVisible(true);
|
||||
|
||||
QHeaderView *vheader = m_ui->tvNumeralCode->verticalHeader();
|
||||
vheader->setVisible(true);
|
||||
|
||||
m_ui->tvNumeralCode->setShowGrid(true);
|
||||
|
||||
m_ui->tvNumeralCode->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
return true;
|
||||
} // end of initNumeralModel()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void MainDialog::onCbEditModeToggled(bool isChecked)
|
||||
{
|
||||
m_numCodeModel->setEditMode(isChecked);
|
||||
|
||||
QHeaderView *header = m_ui->tvNumeralCode->horizontalHeader();
|
||||
QHeaderView *vheader = m_ui->tvNumeralCode->verticalHeader();
|
||||
|
||||
if (isChecked)
|
||||
{
|
||||
header->setVisible(false);
|
||||
vheader->setVisible(false);
|
||||
m_ui->tvNumeralCode->setColumnHidden(0, false);
|
||||
m_ui->tvNumeralCode->setRowHidden(0, false);
|
||||
|
||||
m_ui->pbSetHorizontalHeader->setEnabled(true);
|
||||
m_ui->pbSetVerticalHeader->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
header->setVisible(true);
|
||||
vheader->setVisible(true);
|
||||
m_ui->tvNumeralCode->setColumnHidden(0, true);
|
||||
m_ui->tvNumeralCode->setRowHidden(0, true);
|
||||
|
||||
m_ui->pbSetHorizontalHeader->setEnabled(false);
|
||||
m_ui->pbSetVerticalHeader->setEnabled(false);
|
||||
|
||||
getNumeralCodeHeader();
|
||||
}
|
||||
} // end of onCbEditModeToggled()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void MainDialog::onPbSetHorizontalHeader()
|
||||
{
|
||||
QVector <char> columnSelectionValues;
|
||||
columnSelectionValues << 'h' << 'o' << 'r'
|
||||
<< 'i' << 'z' << 'o'
|
||||
<< 'n' << 't' << 'a'
|
||||
<< 'l' << 'i' << 'd'
|
||||
<< 'x';
|
||||
|
||||
m_numCodeModel->setColumnSelectionValues(columnSelectionValues);
|
||||
} // end of onPbSetHorizontalHeader()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void MainDialog::onPbSetHorizontalHeaderCSV()
|
||||
{
|
||||
QVector <char> columnSelectionValues;
|
||||
columnSelectionValues << 'h' << 'o' << 'r'
|
||||
<< 'i' << 'z' << 'o'
|
||||
<< 'n' << 't' << 'a'
|
||||
<< 'l' << 'c' << 's'
|
||||
<< 'v';
|
||||
|
||||
QVector <char> csvVec;
|
||||
csvVec.reserve(columnSelectionValues.size() * 2);
|
||||
for (int i = 0; i < columnSelectionValues.size(); ++i)
|
||||
{
|
||||
csvVec.append(columnSelectionValues.at(i));
|
||||
csvVec.append(';');
|
||||
}
|
||||
// remove last separator
|
||||
csvVec.remove(columnSelectionValues.size() * 2 - 1);
|
||||
|
||||
DEBUG_LOG(m_logger) << "onPbSetHorizontalHeaderCSV() "
|
||||
<< " csvVec.size(): " << csvVec.size();
|
||||
|
||||
m_numCodeModel->setColumnSelectionValuesCSV(csvVec);
|
||||
} // end of onPbSetHorizontalHeaderCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void MainDialog::onPbSetVerticalHeader()
|
||||
{
|
||||
QVector <char> rowSelectionValues;
|
||||
rowSelectionValues << 'v' << 'e' << 'r'
|
||||
<< 't' << 'i' << 'c'
|
||||
<< 'a' << 'l' << 'i'
|
||||
<< 'n' << 'd' << 'e'
|
||||
<< 'x' ;
|
||||
|
||||
m_numCodeModel->setRowSelectionValues(rowSelectionValues);
|
||||
} // end of onPbSetVerticalHeader()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void MainDialog::onPbSetVerticalHeaderCSV()
|
||||
{
|
||||
QVector <char> rowSelectionValues;
|
||||
rowSelectionValues << 'v' << 'e' << 'r'
|
||||
<< 't' << 'i' << 'c'
|
||||
<< 'a' << 'l' << 'i'
|
||||
<< 'n' << 'c' << 's'
|
||||
<< 'v';
|
||||
|
||||
QVector <char> csvVec;
|
||||
csvVec.reserve(rowSelectionValues.size() * 2);
|
||||
for (int i = 0; i < rowSelectionValues.size(); ++i)
|
||||
{
|
||||
csvVec.append(rowSelectionValues.at(i));
|
||||
csvVec.append(';');
|
||||
}
|
||||
// remove last separator
|
||||
csvVec.remove(rowSelectionValues.size() * 2 - 1);
|
||||
|
||||
DEBUG_LOG(m_logger) << "onPbSetVerticalHeaderCSV() "
|
||||
<< " csvVec.size(): " << csvVec.size();
|
||||
|
||||
m_numCodeModel->setRowSelectionValuesCSV(csvVec);
|
||||
} // end of onPbSetVerticalHeaderCSV()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void MainDialog::getNumeralCodeHeader()
|
||||
{
|
||||
QVector <char> qVecHH = m_numCodeModel->getHorizontalHeaderCSV();
|
||||
QByteArray qbaHH;
|
||||
|
||||
for (int i = 0; i < qVecHH.size(); ++i)
|
||||
qbaHH.append(qVecHH.at(i));
|
||||
|
||||
QVector <char> qVecVH = m_numCodeModel->getVerticalHeaderCSV();
|
||||
QByteArray qbaVH;
|
||||
|
||||
for (int i = 0; i < qVecVH.size(); ++i)
|
||||
qbaVH.append(qVecVH.at(i));
|
||||
|
||||
DEBUG_LOG(m_logger) << "getNumeralCodeHeader()"
|
||||
<< " HH: " << qbaHH << " size: " << qbaHH.size()
|
||||
<< " VH: " << qbaVH << " size: " << qbaVH.size();
|
||||
|
||||
|
||||
// -> DDS schicken
|
||||
|
||||
} // end of getNumeralCodeHeader()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Maindialog for codification dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-11-02
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class MainDialog;
|
||||
}
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
class NumeralCodeModel;
|
||||
|
||||
class MainDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainDialog(QWidget *parent = nullptr);
|
||||
~MainDialog();
|
||||
|
||||
bool init();
|
||||
bool initNumeralModel();
|
||||
|
||||
private Q_SLOTS:
|
||||
void onCbEditModeToggled(bool isChecked);
|
||||
|
||||
void onPbSetHorizontalHeader();
|
||||
void onPbSetHorizontalHeaderCSV();
|
||||
void onPbSetVerticalHeader();
|
||||
void onPbSetVerticalHeaderCSV();
|
||||
|
||||
void getNumeralCodeHeader();
|
||||
|
||||
private:
|
||||
Ui::MainDialog *m_ui;
|
||||
NumeralCodeModel *m_numCodeModel;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainDialog</class>
|
||||
<widget class="QWidget" name="MainDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>610</width>
|
||||
<height>513</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Codification Table</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="tvNumeralCode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||
<number>30</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>30</number>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderDefaultSectionSize">
|
||||
<number>30</number>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderMinimumSectionSize">
|
||||
<number>30</number>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbEditMode">
|
||||
<property name="text">
|
||||
<string>Edit&Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbSetHorizontalHeader">
|
||||
<property name="text">
|
||||
<string>Set default horizontal header</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbSetVerticalHeader">
|
||||
<property name="text">
|
||||
<string>Set default vertical header</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* CodificationManagement Data Plugin Interface
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-01
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <PluginInterfaces/data_plugin_interface.h>
|
||||
#include <CodificationManagement/cod_dtc.h>
|
||||
#include <CodificationManagement/cod_ftc.h>
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
/**
|
||||
* @brief The DataInterface class provides the Topics Clients only for the GUI Plugins
|
||||
*/
|
||||
class DataInterface : public DataPluginBase::Interface
|
||||
{
|
||||
public:
|
||||
using DataPluginBase::Interface::Interface;
|
||||
|
||||
virtual std::shared_ptr<CodificationManagement::Interface::Dtc> getDtc() = 0;
|
||||
virtual std::shared_ptr<CodificationManagement::Interface::Ftc> getFtc() = 0;
|
||||
};
|
||||
|
||||
} // namespace MeteoDataManagement
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for CodificationManagement (Interface for access from other Plugins)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2016-12-01
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
class ForeignGuiInterface
|
||||
{
|
||||
public:
|
||||
ForeignGuiInterface() = default;
|
||||
virtual ~ForeignGuiInterface() = default;
|
||||
};
|
||||
|
||||
} //namespace CodificationManagement
|
||||
Reference in new issue
Block a user