166 lines
5.4 KiB
C++
Executable File
166 lines
5.4 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* Evaluations - Crtierium Overview Dialog
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*
|
|
* Created by Hanna E. Rathje, SLSE, 2017-11-01
|
|
*/
|
|
|
|
#include "evl_element_dialog.h"
|
|
#include "ui_evl_element_dialog.h"
|
|
#include "evl_element_model.h"
|
|
#include "evl_edit_element_dialog.h"
|
|
|
|
#include <LtsUtilsGuiDds/request_helper.h>
|
|
#include <LtsSession/lts_session.h>
|
|
|
|
|
|
namespace Evaluations
|
|
{
|
|
ElementDialog::ElementDialog(QWidget *parent)
|
|
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
|
, m_model(new ElementDialogModel(this))
|
|
, m_ui(new Ui::ElementDialog)
|
|
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
|
, m_logger(getLogger("ElementDialog"))
|
|
{
|
|
DEBUG_LOG(m_logger) << "ElementDialog ctor";
|
|
m_ui->setupUi(this);
|
|
|
|
setOnlineHelpFilename(QStringLiteral("Situation-Own_Evaluation_Criteria"));
|
|
}
|
|
|
|
ElementDialog::~ElementDialog()
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
void ElementDialog::retranslate()
|
|
{
|
|
translate(m_ui, m_dtc->evaluationCriterium(m_criteriumId), tr("Evaluation Elements"));
|
|
}
|
|
|
|
void ElementDialog::enaDisa()
|
|
{
|
|
int selected = m_ui->widget->selectedRows().size();
|
|
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Add, true);
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, (selected == 1));
|
|
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, (selected > 0));
|
|
|
|
}
|
|
|
|
void ElementDialog::slotAdd()
|
|
{
|
|
DEBUG_LOG(m_logger) << "ElementDialog::slotAdd";
|
|
|
|
addElementEditDialog(/* new element */);
|
|
}
|
|
|
|
void ElementDialog::slotEdit()
|
|
{
|
|
DEBUG_LOG(m_logger) << "ElementDialog::slotEdit";
|
|
|
|
addElementEditDialog(m_model->getRowData(m_ui->widget->currentIndex().row()).id() /* existing - edit element */);
|
|
}
|
|
|
|
|
|
void ElementDialog::addElementEditDialog(int elementId)
|
|
{
|
|
addDialog(LtsWidgets::initDialog(new ElementEditDialog(),
|
|
elementId, m_criteriumId, m_exerciseId, m_dtc, m_ftc, m_exmDtc, m_avmDataIfc, m_fltParticipantIfc, m_fltAesIfc, m_fltBuildingComponentIfc, m_session),
|
|
m_menuGroup, QStringLiteral("ElementEditDialog%1").arg(elementId), LtsWidgets::LayoutArea::eDialogTab);
|
|
}
|
|
|
|
void ElementDialog::tableColumnOrganiserSetting()
|
|
{
|
|
//LtsColumnOrganiser
|
|
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
|
}
|
|
|
|
|
|
void ElementDialog::slotRemove()
|
|
{
|
|
DEBUG_LOG(m_logger) << "ElementDialog::slotRemove";
|
|
QModelIndex selIndex = m_ui->widget->currentIndex();
|
|
if (!selIndex.isValid())
|
|
return;
|
|
|
|
m_requestHelper->startSingleRequest([this]()
|
|
{
|
|
DEBUG_LOG(m_logger) << "Removing element id = " << m_model->getRowData(m_ui->widget->currentIndex().row()).id();
|
|
return m_ftc->evlElementRemoveRequest(EvlElementRemoveRequest(m_model->getRowData(m_ui->widget->currentIndex().row()).id(), m_criteriumId), this);
|
|
});
|
|
|
|
if (m_requestHelper->failed())
|
|
ERROR_LOG(m_logger) << "Failed to remove criterium";
|
|
}
|
|
|
|
QString ElementDialog::dialogIdentifier()
|
|
{
|
|
return QStringLiteral("Evl.EditElements");
|
|
}
|
|
|
|
bool ElementDialog::init(int criteriumId,
|
|
int exerciseId,
|
|
const QString &menuGroup,
|
|
const std::shared_ptr<Interface::Dtc> &dtc,
|
|
const std::shared_ptr<Interface::Ftc> &ftc,
|
|
const std::shared_ptr<ExerciseManagement::Interface::Dtc> &exmDtc,
|
|
const std::shared_ptr<AudioVideoManagement::ForeignDataInterface> &avmDataIfc,
|
|
const std::shared_ptr<FilterManagement::ForeignFltParticipantGuiInterface> &fltParticipantIfc,
|
|
const std::shared_ptr<FilterManagement::ForeignAesGuiInterface> &fltAesIfc,
|
|
const std::shared_ptr<FilterManagement::ForeignFltBuildingComponentGuiInterface> &fltBuildingComponentIfc,
|
|
LtsSession::LtsSession *session)
|
|
{
|
|
DEBUG_LOG(m_logger) << "ElementDialog::init";
|
|
m_criteriumId = criteriumId;
|
|
m_exerciseId = exerciseId;
|
|
m_dtc = dtc;
|
|
m_ftc = ftc;
|
|
m_exmDtc = exmDtc;
|
|
m_avmDataIfc = avmDataIfc;
|
|
m_fltParticipantIfc = fltParticipantIfc;
|
|
m_fltAesIfc = fltAesIfc;
|
|
m_fltBuildingComponentIfc = fltBuildingComponentIfc;
|
|
m_session = session;
|
|
m_menuGroup = menuGroup;
|
|
|
|
m_model = new ElementDialogModel(this);
|
|
|
|
m_model->initModel(dtc, exmDtc, avmDataIfc, criteriumId);
|
|
|
|
m_proxyModel = new ElementDialogProxyModel(this);
|
|
m_proxyModel->setSourceModel(m_model);
|
|
m_proxyModel->setCriteriumId(m_criteriumId);
|
|
m_ui->widget->setModel(m_proxyModel);
|
|
|
|
#ifndef LTS_DEBUG
|
|
m_ui->widget->hideColumn(ElementDialogModel::Id);
|
|
#endif
|
|
|
|
auto cb = [this](const Evaluations::EvaluationElement &e)
|
|
{
|
|
DEBUG_LOG(m_logger) << "Element: id = " << e.id() << ", medium = " << e.rating();
|
|
};
|
|
m_dtc->evaluationElements(cb);
|
|
|
|
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged, this, &ElementDialog::enaDisa, Qt::UniqueConnection);
|
|
|
|
|
|
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &ElementDialog::slotAdd, Qt::UniqueConnection);
|
|
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &ElementDialog::slotEdit, Qt::UniqueConnection);
|
|
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &ElementDialog::slotRemove, Qt::UniqueConnection);
|
|
|
|
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &ElementDialog::slotEdit, Qt::UniqueConnection);
|
|
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this, &ElementDialog::slotEdit, Qt::UniqueConnection);
|
|
|
|
enaDisa();
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace Evaluations
|