mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-13 10:04:13 +02:00
Three connects paired a zero-argument signal with a slot that has a default-valued parameter (e.g. void applyEnable(bool = true)).
Default arguments aren't part of a function's pointer-to-member type, so &Class::slot has a type requiring the argument regardless of its default value -- incompatible with a signal providing none, and &Class::slot alone won't compile against these signals at all. When migrating to the modern member pointer connect, replaced with a lambda that calls the slot with no arguments, letting the default apply exactly as before. - SelectAutonumW::applyEnable(bool = true), connected to each NumPartEditorW's changed() signal in both setContext() and on_add_button_clicked(). The corresponding disconnect() in on_remove_button_clicked() is removed rather than reimplemented: a lambda-based connection can't be matched and removed by a separately-written disconnect() call, and the explicit disconnect was already redundant -- the very next line deletes the part object, which Qt automatically disconnects on destruction (the same guarantee setContext()'s own qDeleteAll() cleanup already relies on). - PartText::adjustItemPosition(int = 0), connected to QTextDocument::contentsChanged(). - ExportDialog::slot_changeFilesExtension(bool = false), connected to ExportPropertiesWidget::formatChanged().
This commit is contained in:
@@ -112,7 +112,7 @@ void SelectAutonumW::setContext(const NumerotationContext &context)
|
||||
else {
|
||||
for (int i=0; i<m_context.size(); ++i) { //build with the content of @context
|
||||
NumPartEditorW *part= new NumPartEditorW(m_context, i, m_edited_type, this);
|
||||
connect (part, SIGNAL(changed()), this, SLOT(applyEnable()));
|
||||
connect(part, &NumPartEditorW::changed, this, [this]() { applyEnable(); });
|
||||
num_part_list_ << part;
|
||||
ui -> editor_layout -> addWidget(part);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ void SelectAutonumW::on_add_button_clicked()
|
||||
{
|
||||
applyEnable(false);
|
||||
NumPartEditorW *part = new NumPartEditorW(m_edited_type, this);
|
||||
connect (part, SIGNAL(changed()), this, SLOT(applyEnable()));
|
||||
connect(part, &NumPartEditorW::changed, this, [this]() { applyEnable(); });
|
||||
num_part_list_ << part;
|
||||
ui -> editor_layout -> addWidget(part);
|
||||
ui -> remove_button -> setEnabled(true);
|
||||
@@ -160,7 +160,7 @@ void SelectAutonumW::on_remove_button_clicked()
|
||||
//remove if @num_part_list contains more than one item
|
||||
if (num_part_list_.size() > 1) {
|
||||
NumPartEditorW *part = num_part_list_.takeLast();
|
||||
disconnect(part, SIGNAL(changed()), this, SLOT(applyEnable()));
|
||||
// deliberately not disconnecting as not possible to resolve with lambda and will happen automatically when the object "part" is destroyed.
|
||||
delete part;
|
||||
if (num_part_list_.size() == 1) {
|
||||
ui -> remove_button -> setDisabled(true);
|
||||
|
||||
@@ -55,9 +55,9 @@ PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent) :
|
||||
this,
|
||||
&PartText::adjustItemPosition);
|
||||
connect(document(),
|
||||
SIGNAL(contentsChanged()),
|
||||
&QTextDocument::contentsChanged,
|
||||
this,
|
||||
SLOT(adjustItemPosition()));
|
||||
[this]() { adjustItemPosition(); });
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
|
||||
@@ -98,7 +98,7 @@ ExportDialog::ExportDialog(
|
||||
layout -> addWidget(buttons);
|
||||
|
||||
// connexions signaux/slots
|
||||
connect(epw, SIGNAL(formatChanged()), this, SLOT(slot_changeFilesExtension()));
|
||||
connect(epw, &ExportPropertiesWidget::formatChanged, this, [this]() { slot_changeFilesExtension(); });
|
||||
connect(epw, &ExportPropertiesWidget::exportedAreaChanged, this, &ExportDialog::slot_changeUseBorder);
|
||||
connect(buttons, &QDialogButtonBox::accepted, this, &ExportDialog::slot_export);
|
||||
connect(buttons, &QDialogButtonBox::rejected, this, &ExportDialog::reject);
|
||||
|
||||
Reference in New Issue
Block a user