Files
qelectrotech-source-mirror/sources/ui/conductorpropertieseditorwidget.h
T
ispyisail a556204ba1 Edit several wires at once in the Selection properties panel
Selecting more than one wire left the Selection properties panel empty,
and so did a box selection over a single wire, because it also picks up
the wire's number label.

Now the panel opens for any number of selected wires. A selected wire
label counts as its wire, once, so a box drawn over wires works. The
fields show the first wire's values, a line above them says how many
wires are selected, and an edit is applied to each wire field by field:
setting the function on ten wires leaves each with its own number,
cable and section. With "apply to all conductors of this potential"
ticked, the potentials of all the selected wires follow the same rule.
Each edit is one undo step.

Fields whose values differ between the selected wires are not marked as
such; that can follow if wanted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 23:15:32 +13:00

83 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();
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;
};
#endif // CONDUCTORPROPERTIESEDITORWIDGET_H