mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-03 17:34:12 +02:00
a8699f6f62
With "Show the properties of a selected conductor in the Selection properties panel" switched on, editing a wire there could change things the user never touched: - Enter in a field (Function, Section...) is not used by the line edit, so it reaches the checkable "Multifilaire" group box around it, which takes it as a click. The wire was switched to single-line, gaining ground, neutral and phase symbols. The modal dialog never shows this because its OK button takes Enter first. - Every edit wrote back the whole set of properties as the widget holds them, so a value the widget cannot show exactly was rewritten: a dash size of 1 became 2. The panel now swallows Enter at its checkable group boxes, and writes only the fields that differ from what it showed, through the new ConductorProperties::applyChanges(). "Apply to all conductors of this potential" uses the same rule, so the rest of the potential keeps its own values too. tst_conductorapplychanges checks each field on its own: change that one field, and a wire whose every field differs takes it and keeps the rest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
76 lines
2.4 KiB
C++
76 lines
2.4 KiB
C++
/*
|
|
Copyright 2006-2026 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 CONDUCTORPROPERTIESEDITORWIDGET_H
|
|
#define CONDUCTORPROPERTIESEDITORWIDGET_H
|
|
|
|
#include "../PropertiesEditor/propertieseditorwidget.h"
|
|
#include "../conductorproperties.h"
|
|
|
|
#include <QList>
|
|
#include <QMetaObject>
|
|
|
|
class Conductor;
|
|
class ConductorPropertiesWidget;
|
|
class QCheckBox;
|
|
|
|
/**
|
|
@brief The ConductorPropertiesEditorWidget class
|
|
Hosts the existing ConductorPropertiesWidget in the dockable selection-
|
|
properties panel, so a selected conductor can be edited in place like the
|
|
other item types, instead of only through the modal dialog (issue #500).
|
|
A pinned "apply to all conductors of the potential" checkbox (persisted)
|
|
mirrors the modal dialog's option to propagate edits to the whole potential.
|
|
*/
|
|
class ConductorPropertiesEditorWidget : public PropertiesEditorWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ConductorPropertiesEditorWidget(
|
|
Conductor *conductor = nullptr, QWidget *parent = nullptr);
|
|
~ConductorPropertiesEditorWidget() override;
|
|
|
|
void setConductor(Conductor *conductor);
|
|
|
|
void apply() override;
|
|
void reset() override;
|
|
void updateUi() override;
|
|
QUndoCommand *associatedUndo() const override;
|
|
QString title() const override;
|
|
bool setLiveEdit(bool live_edit) override;
|
|
|
|
protected:
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
|
|
|
private:
|
|
void connectChangeSignals();
|
|
void disconnectChangeSignals();
|
|
|
|
private:
|
|
ConductorPropertiesWidget *m_cpw = nullptr;
|
|
QCheckBox *m_apply_all_cb = nullptr;
|
|
Conductor *m_conductor = nullptr;
|
|
//What the widget showed before the edit: the fields that
|
|
//differ from it are the ones the user changed.
|
|
ConductorProperties m_shown;
|
|
QList<QMetaObject::Connection> m_live_connections;
|
|
bool m_updating = false;
|
|
};
|
|
|
|
#endif // CONDUCTORPROPERTIESEDITORWIDGET_H
|