Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* HMI Plugin for OperatorManangement - Group Overview Dialog
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2016-02-29
|
||||
*/
|
||||
|
||||
|
||||
#include "preset_dialog.h"
|
||||
#include "ui_preset_dialog.h"
|
||||
|
||||
#include "group_edit_dialog.h"
|
||||
#include "CustomViews/opm_group.h"
|
||||
|
||||
namespace OperatorManagement
|
||||
{
|
||||
PresetDialog::PresetDialog(const QString &menuGroup, QWidget *parent)
|
||||
: LtsWidgets::LtsDialog(parent, LtsWidgets::ButtonCombination::CloseOnly)
|
||||
, m_menuGroup(menuGroup)
|
||||
, m_model(nullptr)
|
||||
, m_ui(new Ui::PresetDialog)
|
||||
, m_dtc(nullptr)
|
||||
, m_ftc(nullptr)
|
||||
, m_requestHelper(new LtsUtils::RequestHelper(this))
|
||||
, m_logger(getLogger("PresetDialog"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Add, this, &PresetDialog::onAddGroup);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Edit, this, &PresetDialog::onEditGroup);
|
||||
m_buttonBox->connectButton(LtsWidgets::DialogButton::Remove, this, &PresetDialog::onRemoveGroup);
|
||||
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalDoubleClicked, this, &PresetDialog::onEditGroup);
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalEnterPressed, this, &PresetDialog::onEditGroup);
|
||||
|
||||
setOnlineHelpFilename(QStringLiteral("Administrator-Presets"));
|
||||
}
|
||||
|
||||
PresetDialog::~PresetDialog()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void PresetDialog::retranslate()
|
||||
{
|
||||
translate(m_ui, tr("Presets"));
|
||||
}
|
||||
|
||||
void PresetDialog::tableColumnOrganiserSetting()
|
||||
{
|
||||
//LtsColumnOrganiser
|
||||
m_ui->widget->setColumnsOrganiserEnabled(identifier(), true);
|
||||
}
|
||||
|
||||
bool PresetDialog::init(const std::shared_ptr<OperatorManagement::Interface::Dtc> &dtc,
|
||||
const std::shared_ptr<OperatorManagement::Interface::Ftc> &ftc,
|
||||
bool hideHidden)
|
||||
{
|
||||
m_dtc = dtc;
|
||||
m_ftc = ftc;
|
||||
|
||||
m_model = new GroupModel(this);
|
||||
m_model->initModel(dtc, hideHidden);
|
||||
m_ui->widget->setModel(m_model, [this]() { return new CustomViewGroup(this); });
|
||||
#ifndef LTS_DEBUG
|
||||
m_ui->widget->setColumnHidden(GroupModel::Id, true);
|
||||
#endif
|
||||
connect(m_ui->widget, &LtsDataView::LtsDataView::signalSelectionChanged,
|
||||
this, &PresetDialog::enaDisa);
|
||||
|
||||
enaDisa();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PresetDialog::enaDisa()
|
||||
{
|
||||
QModelIndexList selectedRows = m_ui->widget->selectedRows();
|
||||
const int cntSelectedRows = selectedRows.size();
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Edit, cntSelectedRows == 1 );
|
||||
|
||||
bool deletable = cntSelectedRows > 0 &&
|
||||
(m_model->getRowData(selectedRows.at(0).row()).type() == GroupType_def::PresetGroup);
|
||||
|
||||
m_buttonBox->setButtonEnabled(LtsWidgets::DialogButton::Remove, deletable );
|
||||
}
|
||||
|
||||
void PresetDialog::onRemoveGroup()
|
||||
{
|
||||
QModelIndex idx = m_ui->widget->currentIndex();
|
||||
Core::RemoveElementRequest req(m_model->getRowData(idx.row()).id());
|
||||
m_requestHelper->startSingleRequest([req, this]()
|
||||
{
|
||||
return m_ftc->groupRemoveRequest(req, this);
|
||||
});
|
||||
}
|
||||
|
||||
void PresetDialog::onAddGroup()
|
||||
{
|
||||
GroupEditDialog *dialog = new GroupEditDialog(this);
|
||||
Group grp;
|
||||
grp.type(GroupType_def::PresetGroup);
|
||||
dialog->init(grp, m_dtc, m_ftc);
|
||||
|
||||
addDialog(dialog, m_menuGroup, QLatin1String("NewPreset"), LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
void PresetDialog::onEditGroup()
|
||||
{
|
||||
const QModelIndex idx = m_ui->widget->currentIndex();
|
||||
const OperatorManagement::Group group = m_model->getRowData(idx.row());
|
||||
|
||||
if (group.id() <= 0)
|
||||
return;
|
||||
|
||||
GroupEditDialog *dialog = new GroupEditDialog(this);
|
||||
dialog->init(group, m_dtc, m_ftc);
|
||||
const QString identifier = QLatin1String("editPreset") + QString::number(group.id());
|
||||
|
||||
addDialog(dialog, m_menuGroup, identifier, LtsWidgets::LayoutArea::eDialogTab);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user