mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
Change made inside the free terminal table can be applied
This commit is contained in:
@@ -17,9 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
#include "freeterminaleditor.h"
|
#include "freeterminaleditor.h"
|
||||||
#include "ui_freeterminaleditor.h"
|
#include "ui_freeterminaleditor.h"
|
||||||
|
|
||||||
|
#include "../undocommand/changeelementdatacommand.h"
|
||||||
|
#include "../../diagram.h"
|
||||||
#include "../../elementprovider.h"
|
#include "../../elementprovider.h"
|
||||||
#include "freeterminalmodel.h"
|
#include "freeterminalmodel.h"
|
||||||
#include "../../diagram.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief FreeTerminalEditor::FreeTerminalEditor
|
* @brief FreeTerminalEditor::FreeTerminalEditor
|
||||||
@@ -79,3 +81,36 @@ FreeTerminalEditor::~FreeTerminalEditor()
|
|||||||
void FreeTerminalEditor::reload() {
|
void FreeTerminalEditor::reload() {
|
||||||
m_model->clear();
|
m_model->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief FreeTerminalEditor::apply
|
||||||
|
* Applu current edited values
|
||||||
|
*/
|
||||||
|
void FreeTerminalEditor::apply()
|
||||||
|
{
|
||||||
|
const auto modified_data = m_model->modifiedModelRealTerminalData();
|
||||||
|
if (modified_data.size())
|
||||||
|
{
|
||||||
|
m_project->undoStack()->beginMacro(tr("Modifier des propriétés de borniers"));
|
||||||
|
|
||||||
|
for (const auto &data_ : modified_data)
|
||||||
|
{
|
||||||
|
if (auto element_ = data_.element_)
|
||||||
|
{
|
||||||
|
auto current_data = element_->elementData();
|
||||||
|
current_data.setTerminalType(data_.type_);
|
||||||
|
current_data.setTerminalFunction(data_.function_);
|
||||||
|
current_data.setTerminalLED(data_.led_);
|
||||||
|
current_data.m_informations.addValue(QStringLiteral("label"), data_.label_);
|
||||||
|
|
||||||
|
if (element_->elementData() != current_data) {
|
||||||
|
m_project->undoStack()->push(new ChangeElementDataCommand(element_, current_data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_project->undoStack()->endMacro();
|
||||||
|
}
|
||||||
|
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class FreeTerminalEditor : public QWidget
|
|||||||
~FreeTerminalEditor();
|
~FreeTerminalEditor();
|
||||||
|
|
||||||
void reload();
|
void reload();
|
||||||
|
void apply();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ void TerminalStripEditorWindow::on_m_button_box_clicked(QAbstractButton *button)
|
|||||||
{
|
{
|
||||||
switch (ui->m_stacked_widget->currentIndex()) {
|
switch (ui->m_stacked_widget->currentIndex()) {
|
||||||
case FREE_TERMINAL_PAGE:
|
case FREE_TERMINAL_PAGE:
|
||||||
|
m_free_terminal_editor->apply();
|
||||||
break;
|
break;
|
||||||
case TERMINAL_STRIP_PAGE:
|
case TERMINAL_STRIP_PAGE:
|
||||||
m_terminal_strip_editor->apply();
|
m_terminal_strip_editor->apply();
|
||||||
|
|||||||
Reference in New Issue
Block a user