Files
qelectrotech-source-mirror/sources/ui/conductorpropertieswidget.h
T
ispyisail 1c5fd5a284 Multi-wire panel: stable first wire, mixed fields, locked text, one reload
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>
2026-10-02 06:20:17 +13:00

82 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 CONDUCTORPROPERTIESWIDGET_H
#define CONDUCTORPROPERTIESWIDGET_H
#include "../conductormultiedit.h"
#include "../conductorproperties.h"
#include <QWidget>
class QTextOrientationSpinBoxWidget;
class QComboBox;
class QPushButton;
namespace Ui {
class ConductorPropertiesWidget;
}
class ConductorPropertiesWidget : public QWidget
{
Q_OBJECT
public:
explicit ConductorPropertiesWidget(QWidget *parent = nullptr);
explicit ConductorPropertiesWidget(
const ConductorProperties &properties,
QWidget *parent = nullptr);
~ConductorPropertiesWidget() override;
//METHODS
void setProperties(const ConductorProperties &properties);
ConductorProperties properties() const;
void setReadOnly(const bool &ro);
void addAutonumWidget (QWidget *widget);
void setHiddenOneTextPerFolio (const bool &hide);
void setDisabledShowText (const bool &disable = true);
void setHiddenAvailableAutonum (const bool &hide);
void setMixedTextFields(const QList<ConductorMultiEdit::TextField> &mixed);
void setTextLocked(bool locked);
QComboBox *autonumComboBox() const;
QPushButton *editAutonumPushButton() const;
private:
void initWidget();
void setConductorType(ConductorProperties::ConductorType type);
protected:
bool event(QEvent *event) override;
//SLOTS
public slots:
void updatePreview(bool b = true);
private slots:
void on_m_earth_cb_toggled(bool checked);
void on_m_neutral_cb_toggled(bool checked);
void on_m_update_preview_pb_clicked();
private:
Ui::ConductorPropertiesWidget *ui;
ConductorProperties m_properties;
QTextOrientationSpinBoxWidget *m_verti_select, *m_horiz_select;
bool m_text_locked = false;
};
#endif // CONDUCTORPROPERTIESWIDGET_H