Files
qelectrotech-source-mirror/sources/ui/conductorpropertieseditorwidget.h
T
Shane Ringrose 280051745a Conductor dock: apply edits live, edit via label, fill height (#500)
Addresses the testing feedback on the conductor selection-properties
prototype:

1. Edits were never applied. The dock drives every editor through
   setLiveEdit(true), which each editor overrides to connect its field
   changes to apply(); ConductorPropertiesEditorWidget didn't override it,
   so the call was a no-op. Implement setLiveEdit() to connect the hosted
   ConductorPropertiesWidget's controls (commit-style signals) to apply().
   A m_updating guard suppresses the signals emitted while the widget is
   loaded programmatically, so a partial mid-load state is never committed.

2. Clicking a conductor's text label showed nothing, because the label is
   a ConductorTextItem, not a Conductor. Map it to its parentConductor() in
   the editor factory, mirroring the double-click-the-label dialog behaviour.

3. The panel sat at a small size hint with empty space below it. Give the
   editor an Expanding vertical size policy (and a minimum height) so it
   fills the dock like the other editors.

Refs #500

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-18 10:35:49 +12:00

69 lines
2.2 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;
/**
@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).
Prototype: single-conductor editing; applying to the whole potential is the
open design question (the modal dialog offers it via a prompt).
*/
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;
private:
void connectChangeSignals();
void disconnectChangeSignals();
private:
ConductorPropertiesWidget *m_cpw = nullptr;
Conductor *m_conductor = nullptr;
ConductorProperties m_initial;
QList<QMetaObject::Connection> m_live_connections;
bool m_updating = false;
};
#endif // CONDUCTORPROPERTIESEDITORWIDGET_H