mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
Element editor : minor fix
In the part list widget, the terminal name is empty if terminal haven't got name. Now "terminal" is always displayed and if the terminal have a name the name is appended to "terminal". Example : if the terminal name is 24 then the the part list widget show "terminal : 24"
This commit is contained in:
@@ -179,10 +179,10 @@ qreal PartTerminal::rotation() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief PartTerminal::setName
|
@brief PartTerminal::setTerminalName
|
||||||
@param name
|
@param name
|
||||||
*/
|
*/
|
||||||
void PartTerminal::setName(QString& name) {
|
void PartTerminal::setTerminalName(const QString& name) {
|
||||||
if (d -> m_name == name) return;
|
if (d -> m_name == name) return;
|
||||||
d -> m_name = name;
|
d -> m_name = name;
|
||||||
emit nameChanged();
|
emit nameChanged();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class PartTerminal : public CustomElementGraphicPart
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(Qet::Orientation orientation READ orientation WRITE setOrientation)
|
Q_PROPERTY(Qet::Orientation orientation READ orientation WRITE setOrientation)
|
||||||
Q_PROPERTY(QString name READ name WRITE setName)
|
Q_PROPERTY(QString terminal_name READ terminalName WRITE setTerminalName)
|
||||||
Q_PROPERTY(TerminalData::Type terminal_type READ terminalType WRITE setTerminalType)
|
Q_PROPERTY(TerminalData::Type terminal_type READ terminalType WRITE setTerminalType)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -78,8 +78,10 @@ class PartTerminal : public CustomElementGraphicPart
|
|||||||
void setRotation(qreal angle);
|
void setRotation(qreal angle);
|
||||||
|
|
||||||
|
|
||||||
QString name() const override { return d -> m_name; }
|
QString terminalName() const { return d -> m_name; }
|
||||||
void setName(QString& name);
|
void setTerminalName(const QString& name);
|
||||||
|
|
||||||
|
QString name() const override { return QObject::tr("Borne");}
|
||||||
|
|
||||||
TerminalData::Type terminalType() const {return d->m_type;}
|
TerminalData::Type terminalType() const {return d->m_type;}
|
||||||
void setTerminalType(TerminalData::Type type);
|
void setTerminalType(TerminalData::Type type);
|
||||||
|
|||||||
@@ -469,6 +469,12 @@ void QETElementEditor::fillPartsList()
|
|||||||
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi))
|
if (CustomElementPart *cep = dynamic_cast<CustomElementPart *>(qgi))
|
||||||
{
|
{
|
||||||
QString part_desc = cep -> name();
|
QString part_desc = cep -> name();
|
||||||
|
if (PartTerminal *terminal = dynamic_cast<PartTerminal *>(qgi)) {
|
||||||
|
const auto t_name { terminal->terminalName() } ;
|
||||||
|
if (!t_name.isEmpty()) {
|
||||||
|
part_desc += QLatin1String(" : ") + t_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
QListWidgetItem *qlwi = new QListWidgetItem(part_desc);
|
QListWidgetItem *qlwi = new QListWidgetItem(part_desc);
|
||||||
QVariant v;
|
QVariant v;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // ### Qt 6: remove
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ void TerminalEditor::updateForm()
|
|||||||
ui->m_x_dsb->setValue(m_part->property("x").toReal());
|
ui->m_x_dsb->setValue(m_part->property("x").toReal());
|
||||||
ui->m_y_dsb->setValue(m_part->property("y").toReal());
|
ui->m_y_dsb->setValue(m_part->property("y").toReal());
|
||||||
ui->m_orientation_cb->setCurrentIndex(ui->m_orientation_cb->findData(m_part->property("orientation")));
|
ui->m_orientation_cb->setCurrentIndex(ui->m_orientation_cb->findData(m_part->property("orientation")));
|
||||||
ui->m_name_le->setText(m_part->name());
|
ui->m_name_le->setText(m_part->terminalName());
|
||||||
ui->m_type_cb->setCurrentIndex(ui->m_orientation_cb->findData(m_part->terminalType()));
|
ui->m_type_cb->setCurrentIndex(ui->m_orientation_cb->findData(m_part->terminalType()));
|
||||||
|
|
||||||
activeConnections(true);
|
activeConnections(true);
|
||||||
@@ -181,9 +181,9 @@ void TerminalEditor::nameEdited()
|
|||||||
m_locked = true;
|
m_locked = true;
|
||||||
QString name_(ui->m_name_le->text());
|
QString name_(ui->m_name_le->text());
|
||||||
|
|
||||||
if (m_part->name() != name_)
|
if (m_part->terminalName() != name_)
|
||||||
{
|
{
|
||||||
auto undo = new QPropertyUndoCommand(m_part, "name", m_part->property("name"), name_);
|
auto undo = new QPropertyUndoCommand(m_part, "terminal_name", m_part->property("terminal_name"), name_);
|
||||||
undo->setText(tr("Modifier le nom du terminal"));
|
undo->setText(tr("Modifier le nom du terminal"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user