mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-03 09:14:12 +02:00
1c5fd5a284
Review of #1205: - The scene gives no order for its selection, so the "first" wire whose values the panel shows could change between two selections of the same wires. The wires are now sorted top to bottom, then left to right. - A text field the selected wires do not agree on (function, section, cable...) is shown blank with the hint "Plusieurs valeurs". Typing any value there, including the first wire's own, now differs from what was shown, so it reaches every wire: 1.5 mm² on a 1.5 and a 2.5 wire works. - The conductor text is locked while several wires are selected: the same number on all of them would make duplicates. "Apply to all conductors of this potential" with one wire selected still sets the number on the whole potential. - One edit of N wires emitted N signals, each reloading the panel. They are now gathered into one reload, which matters since a reload reads every selected wire to find the mixed fields. Selections and targets are de-duplicated with sets, and a wire reached through an earlier wire's potential is not walked again. An edit that changes nothing returns before any potential is walked. The rules move to sources/conductormultiedit.h, templates over the wire type, so tst_conductormultiedit can check them against a fake wire: order, targets with and without potentials, one undo step and its redo for three wires, and the mixed fields. tst_conductorapplychanges now gives the other wire the opposite value in every boolean field, so copying one by mistake fails the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
85 lines
2.7 KiB
C++
85 lines
2.7 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>
|
|
#include <QPointer>
|
|
|
|
class Conductor;
|
|
class ConductorPropertiesWidget;
|
|
class QCheckBox;
|
|
class QLabel;
|
|
|
|
/**
|
|
@brief The ConductorPropertiesEditorWidget class
|
|
Hosts the existing ConductorPropertiesWidget in the dockable selection-
|
|
properties panel, so selected conductors 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.
|
|
When several conductors are selected, the panel shows the first one and
|
|
applies to each only the fields the user changed.
|
|
*/
|
|
class ConductorPropertiesEditorWidget : public PropertiesEditorWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ConductorPropertiesEditorWidget(
|
|
const QList<Conductor *> &conductors = {},
|
|
QWidget *parent = nullptr);
|
|
~ConductorPropertiesEditorWidget() override;
|
|
|
|
void setConductors(const QList<Conductor *> &conductors);
|
|
|
|
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();
|
|
void scheduleUpdateUi();
|
|
Conductor *firstConductor() const;
|
|
|
|
private:
|
|
ConductorPropertiesWidget *m_cpw = nullptr;
|
|
QCheckBox *m_apply_all_cb = nullptr;
|
|
QLabel *m_count_label = nullptr;
|
|
QList<QPointer<Conductor>> m_conductors;
|
|
//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;
|
|
bool m_update_pending = false;
|
|
};
|
|
|
|
#endif // CONDUCTORPROPERTIESEDITORWIDGET_H
|