Level of real terminal can be edited

The level of each real terminal who compose a physical terminal can be
edited. Several real terminal can be edited in one shot.
This commit is contained in:
joshua
2021-10-12 19:25:35 +02:00
parent 8b1f2fb0d9
commit 107d7ff806
11 changed files with 245 additions and 50 deletions

View File

@@ -0,0 +1,43 @@
/*
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "changeterminallevel.h"
ChangeTerminalLevel::ChangeTerminalLevel(TerminalStrip *strip,
const RealTerminalData &real_terminal,
int level,
QUndoCommand *parent) :
QUndoCommand(parent),
m_strip(strip),
m_real_terminal(real_terminal),
m_new_level(level),
m_old_level(real_terminal.level_)
{}
void ChangeTerminalLevel::undo()
{
if (m_strip) {
m_strip->setLevel(m_real_terminal, m_old_level);
}
}
void ChangeTerminalLevel::redo()
{
if (m_strip) {
m_strip->setLevel(m_real_terminal, m_new_level);
}
}

View File

@@ -0,0 +1,42 @@
/*
Copyright 2006-2021 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CHANGETERMINALLEVEL_H
#define CHANGETERMINALLEVEL_H
#include <QUndoCommand>
#include <QPointer>
#include "../terminalstrip.h"
class ChangeTerminalLevel : public QUndoCommand
{
public:
ChangeTerminalLevel(TerminalStrip *strip,
const RealTerminalData &real_terminal,
int level,
QUndoCommand *parent = nullptr);
void undo() override;
void redo() override;
private:
QPointer<TerminalStrip> m_strip;
RealTerminalData m_real_terminal;
int m_new_level, m_old_level;
};
#endif // CHANGETERMINALLEVEL_H

View File

@@ -289,6 +289,23 @@ class PhysicalTerminal
return m_real_terminal.indexOf(terminal); return m_real_terminal.indexOf(terminal);
} }
/**
* @brief setLevelOf
* Change the level of \p terminal
* @param terminal
* @param level
*/
bool setLevelOf(shared_real_terminal terminal, int level)
{
const int i = m_real_terminal.indexOf(terminal);
if (i >= 0)
{
m_real_terminal.swapItemsAt(i, std::min(level, m_real_terminal.size()-1));
return true;
}
return false;
}
/** /**
* @brief terminals * @brief terminals
* @return A vector of real terminal who compose this physical terminal * @return A vector of real terminal who compose this physical terminal
@@ -570,14 +587,14 @@ QVector<PhysicalTerminalData> TerminalStrip::physicalTerminalData() const
* @param sorted_vector * @param sorted_vector
* @return true is successfully sorted. * @return true is successfully sorted.
*/ */
bool TerminalStrip::setOrderTo(QVector<PhysicalTerminalData> sorted_vector) bool TerminalStrip::setOrderTo(const QVector<PhysicalTerminalData> &sorted_vector)
{ {
if (sorted_vector.size() != m_physical_terminals.size()) { if (sorted_vector.size() != m_physical_terminals.size()) {
return false; return false;
} }
QVector<QSharedPointer<PhysicalTerminal>> new_order; QVector<QSharedPointer<PhysicalTerminal>> new_order;
for (auto ptd : sorted_vector) for (const auto &ptd : sorted_vector)
{ {
const auto physical_t = physicalTerminalForUuid(ptd.uuid_); const auto physical_t = physicalTerminalForUuid(ptd.uuid_);
if (physical_t.isNull()) { if (physical_t.isNull()) {
@@ -677,6 +694,32 @@ void TerminalStrip::unGroupTerminals(const QVector<RealTerminalData> &terminals_
} }
} }
/**
* @brief TerminalStrip::setLevel
* @param real_terminal_data
* @param level
* @return
*/
bool TerminalStrip::setLevel(const RealTerminalData &real_terminal_data, int level)
{
auto real_terminal = realTerminalForUuid(real_terminal_data.real_terminal_uuid);
if (real_terminal)
{
auto physical_terminal = physicalTerminal(real_terminal);
if (physical_terminal)
{
if (physical_terminal->terminals().size() > 1 &&
physical_terminal->setLevelOf(real_terminal, level))
{
emit orderChanged();
return true;
}
}
}
return false;
}
/** /**
* @brief TerminalStrip::terminalElement * @brief TerminalStrip::terminalElement
* @return A vector of all terminal element owned by this strip * @return A vector of all terminal element owned by this strip

View File

@@ -117,9 +117,10 @@ class TerminalStrip : public QObject
PhysicalTerminalData physicalTerminalData(int index) const; PhysicalTerminalData physicalTerminalData(int index) const;
PhysicalTerminalData physicalTerminalData (const RealTerminalData &real_data) const; PhysicalTerminalData physicalTerminalData (const RealTerminalData &real_data) const;
QVector<PhysicalTerminalData> physicalTerminalData() const; QVector<PhysicalTerminalData> physicalTerminalData() const;
bool setOrderTo(QVector<PhysicalTerminalData> sorted_vector); bool setOrderTo(const QVector<PhysicalTerminalData> &sorted_vector);
bool groupTerminals(const PhysicalTerminalData &receiver_terminal, const QVector<RealTerminalData> &added_terminals); bool groupTerminals(const PhysicalTerminalData &receiver_terminal, const QVector<RealTerminalData> &added_terminals);
void unGroupTerminals(const QVector<RealTerminalData> &terminals_to_ungroup); void unGroupTerminals(const QVector<RealTerminalData> &terminals_to_ungroup);
bool setLevel(const RealTerminalData &real_terminal_data, int level);
QVector<QPointer<Element>> terminalElement() const; QVector<QPointer<Element>> terminalElement() const;

View File

@@ -32,6 +32,7 @@
#include "../diagram.h" #include "../diagram.h"
#include "../UndoCommand/sortterminalstripcommand.h" #include "../UndoCommand/sortterminalstripcommand.h"
#include "../UndoCommand/groupterminalscommand.h" #include "../UndoCommand/groupterminalscommand.h"
#include "../UndoCommand/changeterminallevel.h"
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
@@ -352,10 +353,12 @@ void TerminalStripEditor::selectionChanged()
const auto index_list = ui->m_table_widget->selectionModel()->selectedIndexes(); const auto index_list = ui->m_table_widget->selectionModel()->selectedIndexes();
const auto terminal_vector = m_model->physicalTerminalDataForIndex(index_list); const auto terminal_vector = m_model->physicalTerminalDataForIndex(index_list);
const auto real_terminal_vector = m_model->realTerminalDataForIndex(index_list);
//Enable/disable group button
ui->m_group_terminals_pb->setEnabled(terminal_vector.size() > 1 ? true : false); ui->m_group_terminals_pb->setEnabled(terminal_vector.size() > 1 ? true : false);
//Enable/disable ungroup button
auto it_= std::find_if(terminal_vector.constBegin(), terminal_vector.constEnd(), [](auto &data) auto it_= std::find_if(terminal_vector.constBegin(), terminal_vector.constEnd(), [](auto &data)
{ {
if (data.real_terminals_vector.size() >= 2) { if (data.real_terminals_vector.size() >= 2) {
@@ -500,17 +503,22 @@ void TerminalStripEditor::on_m_dialog_button_box_clicked(QAbstractButton *button
if (m_model) if (m_model)
{ {
for (auto modified_data : m_model->modifiedRealTerminalData()) for (const auto &data_ : m_model->modifiedRealTerminalData())
{ {
auto element = modified_data.element_; auto original_ = data_.first;
auto edited_ = data_.second;
auto element = original_.element_;
if (element) { if (element) {
auto current_data = element->elementData(); auto current_data = element->elementData();
current_data.setTerminalType(modified_data.type_); current_data.setTerminalType(edited_.type_);
current_data.setTerminalFunction(modified_data.function_); current_data.setTerminalFunction(edited_.function_);
current_data.setTerminalLED(modified_data.led_); current_data.setTerminalLED(edited_.led_);
current_data.m_informations.addValue(QStringLiteral("label"), modified_data.label_); current_data.m_informations.addValue(QStringLiteral("label"), edited_.label_);
m_project->undoStack()->push(new ChangeElementDataCommand(element, current_data)); if (element->elementData() != current_data)
m_project->undoStack()->push(new ChangeElementDataCommand(element, current_data));
if (edited_.level_)
m_project->undoStack()->push(new ChangeTerminalLevel(m_current_strip, original_, edited_.level_));
} }
} }
} }
@@ -560,3 +568,24 @@ void TerminalStripEditor::on_m_ungroup_pb_clicked()
} }
} }
/**
* @brief TerminalStripEditor::on_m_level_sb_valueChanged
* @param arg1
*/
void TerminalStripEditor::on_m_level_sb_valueChanged(int arg1)
{
if (m_model)
{
const auto index_list = ui->m_table_widget->selectionModel()->selectedIndexes();
for (auto index : index_list)
{
auto level_index = m_model->index(index.row(), 1, index.parent());
if (level_index.isValid())
{
m_model->setData(level_index, arg1);
}
}
}
}

View File

@@ -62,6 +62,7 @@ class TerminalStripEditor : public QDialog
void on_m_auto_ordering_pb_clicked(); void on_m_auto_ordering_pb_clicked();
void on_m_group_terminals_pb_clicked(); void on_m_group_terminals_pb_clicked();
void on_m_ungroup_pb_clicked(); void on_m_ungroup_pb_clicked();
void on_m_level_sb_valueChanged(int arg1);
private: private:
Ui::TerminalStripEditor *ui; Ui::TerminalStripEditor *ui;

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1260</width> <width>1289</width>
<height>579</height> <height>645</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -179,6 +179,13 @@
<widget class="QWidget" name="widget" native="true"> <widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="3" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Étage :</string>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@@ -191,24 +198,27 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="0"> <item row="3" column="1">
<widget class="QPushButton" name="m_auto_ordering_pb"> <widget class="QSpinBox" name="m_level_sb"/>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="m_ungroup_pb">
<property name="text"> <property name="text">
<string>Position automatique</string> <string>Degrouper les bornes</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0" colspan="2">
<widget class="QPushButton" name="m_group_terminals_pb"> <widget class="QPushButton" name="m_group_terminals_pb">
<property name="text"> <property name="text">
<string>Grouper les bornes</string> <string>Grouper les bornes</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="0" column="0" colspan="2">
<widget class="QPushButton" name="m_ungroup_pb"> <widget class="QPushButton" name="m_auto_ordering_pb">
<property name="text"> <property name="text">
<string>Degrouper les bornes</string> <string>Position automatique</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -289,13 +299,21 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>m_add_terminal_strip_pb</tabstop>
<tabstop>m_remove_terminal_strip_pb</tabstop>
<tabstop>m_reload_pb</tabstop>
<tabstop>m_auto_ordering_pb</tabstop>
<tabstop>m_group_terminals_pb</tabstop>
<tabstop>m_ungroup_pb</tabstop>
<tabstop>m_level_sb</tabstop>
<tabstop>m_terminal_strip_tw</tabstop>
<tabstop>m_table_widget</tabstop>
<tabstop>m_description_te</tabstop>
<tabstop>m_comment_le</tabstop>
<tabstop>m_name_le</tabstop>
<tabstop>m_tab_widget</tabstop> <tabstop>m_tab_widget</tabstop>
<tabstop>m_installation_le</tabstop> <tabstop>m_installation_le</tabstop>
<tabstop>m_location_le</tabstop> <tabstop>m_location_le</tabstop>
<tabstop>m_name_le</tabstop>
<tabstop>m_comment_le</tabstop>
<tabstop>m_description_te</tabstop>
<tabstop>m_table_widget</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="../../../qelectrotech.qrc"/> <include location="../../../qelectrotech.qrc"/>

View File

@@ -52,7 +52,7 @@ TerminalStripModel::TerminalStripModel(TerminalStrip *terminal_strip, QObject *p
QAbstractTableModel(parent), QAbstractTableModel(parent),
m_terminal_strip(terminal_strip) m_terminal_strip(terminal_strip)
{ {
fillRealTerminalData(); fillPhysicalTerminalData();
} }
int TerminalStripModel::rowCount(const QModelIndex &parent) const int TerminalStripModel::rowCount(const QModelIndex &parent) const
@@ -64,7 +64,7 @@ int TerminalStripModel::rowCount(const QModelIndex &parent) const
} }
auto count = 0; auto count = 0;
for (const auto &ptd : m_physical_terminal_data) { for (const auto &ptd : m_edited_terminal_data) {
count += ptd.real_terminals_vector.size(); count += ptd.real_terminals_vector.size();
} }
@@ -133,7 +133,14 @@ bool TerminalStripModel::setData(const QModelIndex &index, const QVariant &value
int modified_cell = -1; int modified_cell = -1;
auto column_ = index.column(); auto column_ = index.column();
if (column_ == LED_CELL && if (column_ == LEVEL_CELL &&
role == Qt::EditRole)
{
rtd.level_ = value.toInt();
modified_ = true;
modified_cell = LEVEL_CELL;
}
else if (column_ == LED_CELL &&
role == Qt::CheckStateRole) role == Qt::CheckStateRole)
{ {
rtd.led_ = value.toBool(); rtd.led_ = value.toBool();
@@ -180,6 +187,7 @@ bool TerminalStripModel::setData(const QModelIndex &index, const QVariant &value
vector_.replace(modified_cell, true); vector_.replace(modified_cell, true);
m_modified_cell.insert(rtd.element_, vector_); m_modified_cell.insert(rtd.element_, vector_);
} }
emit dataChanged(index, index);
return true; return true;
} }
@@ -226,18 +234,25 @@ Qt::ItemFlags TerminalStripModel::flags(const QModelIndex &index) const
/** /**
* @brief TerminalStripModel::modifiedRealTerminalData * @brief TerminalStripModel::modifiedRealTerminalData
* @return the modified real terminal data * @return a vector of QPair of modified terminal.
* the first value of the QPair is the original data, the second value is the edited data
*/ */
QVector<RealTerminalData> TerminalStripModel::modifiedRealTerminalData() const QVector<QPair<RealTerminalData, RealTerminalData>> TerminalStripModel::modifiedRealTerminalData() const
{ {
QVector<RealTerminalData> returned_vector; QVector<QPair<RealTerminalData, RealTerminalData>> returned_vector;
const auto modified_real_terminal = m_modified_cell.keys(); const auto modified_real_terminal = m_modified_cell.keys();
for (const auto &ptd : m_physical_terminal_data) { for (auto i = 0 ; i<m_edited_terminal_data.size() ; ++i)
for (const auto &rtd : ptd.real_terminals_vector) { {
if (modified_real_terminal.contains(rtd.element_)) { auto ptd_ = m_edited_terminal_data.at(i);
returned_vector.append(rtd); for (auto j = 0 ; j < ptd_.real_terminals_vector.size() ; ++j)
{
auto rtd_ = ptd_.real_terminals_vector.at(j);
if (modified_real_terminal.contains(rtd_.element_))
{
returned_vector.append(qMakePair(m_original_terminal_data.at(i).real_terminals_vector.at(j),
m_edited_terminal_data.at(i).real_terminals_vector.at(j)));
} }
} }
} }
@@ -329,13 +344,14 @@ QVector<RealTerminalData> TerminalStripModel::realTerminalDataForIndex(QModelInd
return vector_; return vector_;
} }
void TerminalStripModel::fillRealTerminalData() void TerminalStripModel::fillPhysicalTerminalData()
{ {
//Get all physical terminal //Get all physical terminal
if (m_terminal_strip) { if (m_terminal_strip) {
for (auto i=0 ; i < m_terminal_strip->physicalTerminalCount() ; ++i) { for (auto i=0 ; i < m_terminal_strip->physicalTerminalCount() ; ++i) {
m_physical_terminal_data.append(m_terminal_strip->physicalTerminalData(i)); m_original_terminal_data.append(m_terminal_strip->physicalTerminalData(i));
} }
m_edited_terminal_data = m_original_terminal_data;
} }
} }
@@ -347,7 +363,7 @@ RealTerminalData TerminalStripModel::dataAtRow(int row) const
else else
{ {
auto current_row = 0; auto current_row = 0;
for (const auto &physical_data : m_physical_terminal_data) for (const auto &physical_data : m_edited_terminal_data)
{ {
for (const auto &real_data : physical_data.real_terminals_vector) for (const auto &real_data : physical_data.real_terminals_vector)
{ {
@@ -379,15 +395,15 @@ void TerminalStripModel::replaceDataAtRow(RealTerminalData data, int row)
auto current_row = 0; auto current_row = 0;
auto current_physical = 0; auto current_physical = 0;
for (const auto &physical_data : qAsConst(m_physical_terminal_data)) for (const auto &physical_data : qAsConst(m_edited_terminal_data))
{ {
auto current_real = 0; auto current_real = 0;
for (int i=0 ; i<physical_data.real_terminals_vector.count() ; ++i) for (int i=0 ; i<physical_data.real_terminals_vector.count() ; ++i)
{ {
if (current_row == row) { if (current_row == row) {
auto physical_data = m_physical_terminal_data.at(current_physical); auto physical_data = m_edited_terminal_data.at(current_physical);
physical_data.real_terminals_vector.replace(current_real, data); physical_data.real_terminals_vector.replace(current_real, data);
m_physical_terminal_data.replace(current_physical, physical_data); m_edited_terminal_data.replace(current_physical, physical_data);
return; return;
} else { } else {
++current_real; ++current_real;
@@ -410,7 +426,7 @@ void TerminalStripModel::replaceDataAtRow(RealTerminalData data, int row)
*/ */
PhysicalTerminalData TerminalStripModel::physicalDataAtIndex(int index) const PhysicalTerminalData TerminalStripModel::physicalDataAtIndex(int index) const
{ {
if (m_physical_terminal_data.isEmpty()) { if (m_edited_terminal_data.isEmpty()) {
return PhysicalTerminalData(); return PhysicalTerminalData();
} }
@@ -418,7 +434,7 @@ PhysicalTerminalData TerminalStripModel::physicalDataAtIndex(int index) const
int current_phy = -1; int current_phy = -1;
bool match_ = false; bool match_ = false;
for (const auto &ptd_ : qAsConst(m_physical_terminal_data)) for (const auto &ptd_ : qAsConst(m_edited_terminal_data))
{ {
current_checked_index += ptd_.real_terminals_vector.size(); current_checked_index += ptd_.real_terminals_vector.size();
++current_phy; ++current_phy;
@@ -430,7 +446,7 @@ PhysicalTerminalData TerminalStripModel::physicalDataAtIndex(int index) const
} }
if (match_) { if (match_) {
return m_physical_terminal_data.at(current_phy); return m_edited_terminal_data.at(current_phy);
} else { } else {
return PhysicalTerminalData(); return PhysicalTerminalData();
} }
@@ -443,13 +459,13 @@ PhysicalTerminalData TerminalStripModel::physicalDataAtIndex(int index) const
*/ */
RealTerminalData TerminalStripModel::realDataAtIndex(int index) const RealTerminalData TerminalStripModel::realDataAtIndex(int index) const
{ {
if (m_physical_terminal_data.isEmpty()) { if (m_edited_terminal_data.isEmpty()) {
return RealTerminalData(); return RealTerminalData();
} }
int current_checked_index = -1; int current_checked_index = -1;
for (const auto & ptd_ : qAsConst(m_physical_terminal_data)) for (const auto & ptd_ : qAsConst(m_edited_terminal_data))
{ {
for (const auto & rtd_ : qAsConst(ptd_.real_terminals_vector)) { for (const auto & rtd_ : qAsConst(ptd_.real_terminals_vector)) {
++current_checked_index; ++current_checked_index;

View File

@@ -22,6 +22,7 @@
#include <QObject> #include <QObject>
#include <QPointer> #include <QPointer>
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include <QPair>
#include "../terminalstrip.h" #include "../terminalstrip.h"
@@ -40,14 +41,14 @@ class TerminalStripModel : public QAbstractTableModel
virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
virtual Qt::ItemFlags flags (const QModelIndex &index) const override; virtual Qt::ItemFlags flags (const QModelIndex &index) const override;
QVector<RealTerminalData> modifiedRealTerminalData() const; QVector<QPair<RealTerminalData, RealTerminalData>> modifiedRealTerminalData() const;
bool isXrefCell(const QModelIndex &index, Element **element = nullptr); bool isXrefCell(const QModelIndex &index, Element **element = nullptr);
QVector<PhysicalTerminalData> physicalTerminalDataForIndex(QModelIndexList index_list) const; QVector<PhysicalTerminalData> physicalTerminalDataForIndex(QModelIndexList index_list) const;
QVector<RealTerminalData> realTerminalDataForIndex(QModelIndexList index_list) const; QVector<RealTerminalData> realTerminalDataForIndex(QModelIndexList index_list) const;
private: private:
void fillRealTerminalData(); void fillPhysicalTerminalData();
RealTerminalData dataAtRow(int row) const; RealTerminalData dataAtRow(int row) const;
void replaceDataAtRow(RealTerminalData data, int row); void replaceDataAtRow(RealTerminalData data, int row);
PhysicalTerminalData physicalDataAtIndex(int index) const; PhysicalTerminalData physicalDataAtIndex(int index) const;
@@ -55,7 +56,7 @@ class TerminalStripModel : public QAbstractTableModel
private: private:
QPointer<TerminalStrip> m_terminal_strip; QPointer<TerminalStrip> m_terminal_strip;
QVector<PhysicalTerminalData> m_physical_terminal_data; QVector<PhysicalTerminalData> m_edited_terminal_data, m_original_terminal_data;
QHash<Element *, QVector<bool>> m_modified_cell; QHash<Element *, QVector<bool>> m_modified_cell;
}; };

View File

@@ -18,7 +18,8 @@
#include "changeelementdatacommand.h" #include "changeelementdatacommand.h"
#include "../qetgraphicsitem/element.h" #include "../qetgraphicsitem/element.h"
ChangeElementDataCommand::ChangeElementDataCommand(Element *element, ElementData new_data) : ChangeElementDataCommand::ChangeElementDataCommand(Element *element, ElementData new_data, QUndoCommand *parent) :
QUndoCommand(parent),
m_element(element), m_element(element),
m_old_data(element->elementData()), m_old_data(element->elementData()),
m_new_data(new_data) m_new_data(new_data)

View File

@@ -26,7 +26,7 @@ class Element;
class ChangeElementDataCommand : public QUndoCommand class ChangeElementDataCommand : public QUndoCommand
{ {
public: public:
ChangeElementDataCommand(Element *element, ElementData new_data); ChangeElementDataCommand(Element *element, ElementData new_data, QUndoCommand *parent = nullptr);
void undo() override; void undo() override;
void redo() override; void redo() override;