Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+104
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* WarehouseManagement - Operator Edit Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
#include "charge_edit_dialog.h"
|
||||
#include "ui_charge_edit_dialog.h"
|
||||
#include <Plugins/ProjectDataManagement/pdm_data_plugin_interface.h>
|
||||
|
||||
#include <ProjectDataManagement/pdm_dtc.h>
|
||||
#include <LtsSession/lts_session.h>
|
||||
#include <LtsUtilsGuiDds/request_helper.h>
|
||||
|
||||
namespace ProjectDataManagement
|
||||
{
|
||||
ChargeEditDialog::ChargeEditDialog(const int chargeId,
|
||||
LtsSession::LtsSession *session,
|
||||
QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::OkApplyCancel)
|
||||
, m_ui(new Ui::ChargeEditDialog)
|
||||
, m_session(session)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(ProjectDataManagement::getLogger("InjuryModelEditDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
m_uiRequirements->addRequirement({m_ui->lbxLongName, [this]()
|
||||
{
|
||||
m_ui->leLongName->setText(m_ui->leLongName->text().simplified());
|
||||
return (m_ui->leLongName->text().size() > 0);
|
||||
}});
|
||||
m_uiRequirements->addRequirement({m_ui->lbxShortName, [this]()
|
||||
{
|
||||
m_ui->leShortName->setText(m_ui->leShortName->text().simplified());
|
||||
return (m_ui->leShortName->text().size() > 0);
|
||||
}});
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-ChargeEdit"));
|
||||
m_chargeType.id(chargeId);
|
||||
}
|
||||
|
||||
ChargeEditDialog::~ChargeEditDialog()
|
||||
{
|
||||
delete m_requestHelper;
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
bool ChargeEditDialog::init()
|
||||
{
|
||||
std::shared_ptr<ProjectDataManagement::Interface::Dtc> dtc;
|
||||
|
||||
if (!m_session->getDtc<ProjectDataManagement::DataInterface>(dtc) ||
|
||||
!dtc->enableChargeType() ||
|
||||
!m_session->getFtc<ProjectDataManagement::DataInterface>(m_ftc) ||
|
||||
!m_ftc->enableUpdateChargeNames())
|
||||
return false;
|
||||
|
||||
m_chargeType = dtc->chargeType(m_chargeType.id());
|
||||
loadUiValues();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChargeEditDialog::loadUiValues()
|
||||
{
|
||||
// Todo: Why is it always hasChanges()?
|
||||
m_ui->leLongName->setText(QString::fromStdString(m_chargeType.name()));
|
||||
m_ui->leShortName->setText(QString::fromStdString(m_chargeType.shortName()));
|
||||
m_ui->lbPredefinedName->setText(QString::fromStdString(m_chargeType.predefinedName()));
|
||||
retranslate();
|
||||
}
|
||||
|
||||
void ChargeEditDialog::onUpdateChargeNamesReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_requestHelper->requestReply(reply);
|
||||
}
|
||||
|
||||
void ChargeEditDialog::retranslate()
|
||||
{
|
||||
// Todo: Either no Charge Type specified or Predefined name falls back to default text
|
||||
// translate(m_ui, m_chargeType, tr("Charge Type"));
|
||||
|
||||
if (m_ui->lbPredefinedName->text().contains(QLatin1Char('\n')))
|
||||
translate(m_ui, tr("Edit Charge Type '%1[...]'").arg(m_ui->lbPredefinedName->text().split(QLatin1Char('\n')).first()));
|
||||
else
|
||||
translate(m_ui, tr("Edit Charge Type '%1'").arg(m_ui->lbPredefinedName->text()));
|
||||
}
|
||||
|
||||
bool ChargeEditDialog::apply()
|
||||
{
|
||||
ProjectDataManagement::UpdateChargeNamesRequest req(m_chargeType.id(),m_ui->leLongName->text().toStdString(),m_ui->leShortName->text().toStdString());
|
||||
return m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->updateChargeNamesRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace ProjectDataManagement
|
||||
Reference in new issue
Block a user