Merge pull request #1240 from ispyisail/fix/project-properties-ok-marks-modified

Fix Project properties > OK marking the project modified with no edit
This commit is contained in:
Laurent Trinques
2026-10-02 12:54:46 +02:00
committed by GitHub
7 changed files with 49 additions and 4 deletions
+1
View File
@@ -42,6 +42,7 @@ void DiagramContext::add(DiagramContext other)
*/
void DiagramContext::remove(const QString &key) {
m_content.remove(key);
m_content_show.remove(key);
}
/**
+6
View File
@@ -126,6 +126,12 @@ ConductorProperties ConductorPropertiesWidget::properties() const
properties_.m_bicolor = ui->m_color_2_gb->isChecked();
properties_.m_color_2 = ui->m_color_2_kpb->color();
properties_.m_dash_size = ui->m_dash_size_sb->value();
//The box starts at 2, so the default size 1 shows as 2: keep the
//stored size unless the box shows something else.
if (properties_.m_dash_size == qBound(ui->m_dash_size_sb->minimum(),
m_properties.m_dash_size,
ui->m_dash_size_sb->maximum()))
properties_.m_dash_size = m_properties.m_dash_size;
properties_.style = ui -> m_line_style_cb->itemData(ui->m_line_style_cb->currentIndex()).value<QPen>().style();
properties_.m_formula = ui->m_formula_le->text();
properties_.text = ui -> m_text_le -> text();
+4 -2
View File
@@ -233,8 +233,10 @@ void NewDiagramPage::applyConf()
pg.color = g.color;
proj_guides.append(pg);
}
m_project->setDefaultGuides(proj_guides);
modified_project = true;
if (m_project->defaultGuides() != proj_guides) {
m_project->setDefaultGuides(proj_guides);
modified_project = true;
}
if (modified_project) {
m_project -> setModified(modified_project);
@@ -168,6 +168,7 @@ void TitleBlockPropertiesWidget::setProperties(
// Show the saved custom values, plus any of the template's custom variables
// that aren't defined yet, so the user only fills in the missing ones (#271).
DiagramContext context = properties.context;
m_context_keys = context.keys();
addTemplateVariables(context, index);
m_dcw -> setContext(context);
}
@@ -217,6 +218,14 @@ TitleBlockProperties TitleBlockPropertiesWidget::properties() const
}
prop.context = m_dcw -> context();
//The template's custom variables are only offered for filling in
//(#271): one left empty is not part of the properties.
const QList<QString> keys = prop.context.keys();
for (const QString &key : keys) {
if (!m_context_keys.contains(key)
&& prop.context.value(key).toString().isEmpty())
prop.context.remove(key);
}
//The combo box cannot show "no folio numbering": it shows its
//placeholder entry, or the project's first numbering. Return what
+2
View File
@@ -100,6 +100,8 @@ class TitleBlockPropertiesWidget : public QWidget
private:
Ui::TitleBlockPropertiesWidget *ui;
DiagramContextWidget *m_dcw;
/// keys of the context given to setProperties()
QStringList m_context_keys;
QAction *m_tbt_edit, *m_tbt_duplicate;
QMenu *m_tbt_menu;
QList <TitleBlockTemplatesCollection *> m_tbt_collection_list;
+9 -2
View File
@@ -151,8 +151,15 @@ void XRefPropertiesWidget::saveProperties(int index) {
xrp.setPrefix("switch", ui->m_switch_prefix_le->text());
xrp.setMasterLabel(ui->m_master_le->text());
xrp.setSlaveLabel(ui->m_slave_le->text());
xrp.setOffset(ui->m_offset_sb->value());
xrp.setSlaveOffset(ui->m_slave_offset_sb->value());
//The boxes cannot show a value below their minimum (the offset's
//minimum is its "Default" entry, standing for the stored 0): keep
//the stored value unless the box shows something else.
if (ui->m_offset_sb->value() != qBound(ui->m_offset_sb->minimum(), xrp.offset(),
ui->m_offset_sb->maximum()))
xrp.setOffset(ui->m_offset_sb->value());
if (ui->m_slave_offset_sb->value() != qBound(ui->m_slave_offset_sb->minimum(), xrp.slaveOffset(),
ui->m_slave_offset_sb->maximum()))
xrp.setSlaveOffset(ui->m_slave_offset_sb->value());
m_properties.insert(type, xrp);
}
+18
View File
@@ -65,6 +65,24 @@ private slots:
QCOMPARE(fromDom(xml(value)), expected);
QCOMPARE(fromPugi(xml(value)), expected);
}
// remove() forgets the key entirely: a context with a key added
// then removed equals one that never had it. remove() used to keep
// the key's show flag, so the two never compared equal, and
// Project properties > OK saw a change where there was none.
void removeForgetsTheKey()
{
DiagramContext edited;
edited.addValue(QStringLiteral("author"), QStringLiteral("N.V."));
edited.addValue(QStringLiteral("01-numprojet"), QString());
edited.remove(QStringLiteral("01-numprojet"));
DiagramContext stored;
stored.addValue(QStringLiteral("author"), QStringLiteral("N.V."));
QCOMPARE(edited.keys(), stored.keys());
QVERIFY(edited == stored);
}
};
QTEST_APPLESS_MAIN(tst_diagramcontext)