Gui: Fix too enthusiastic auto-collapse

This commit is contained in:
Pieter Hijma
2025-10-09 16:31:45 +02:00
committed by Chris Hennes
parent 8f3d9d9cdf
commit 90f9996fdb
3 changed files with 22 additions and 7 deletions

View File

@@ -239,9 +239,12 @@ void PropertyView::slotAppendDynamicProperty(const App::Property& prop)
return;
App::PropertyContainer* parent = prop.getContainer();
if (propertyEditorData->propOwners.contains(parent)
|| propertyEditorView->propOwners.contains(parent))
{
if (propertyEditorData->propOwners.contains(parent)) {
propertyEditorData->blockCollapseAll();
timer->start(ViewParams::instance()->getPropertyViewTimer());
}
if ( propertyEditorView->propOwners.contains(parent)) {
propertyEditorView->blockCollapseAll();
timer->start(ViewParams::instance()->getPropertyViewTimer());
}
}

View File

@@ -673,6 +673,11 @@ void Gui::PropertyEditor::PropertyEditor::drawRow(QPainter* painter,
QTreeView::drawRow(painter, options, index);
}
void PropertyEditor::blockCollapseAll()
{
blockCollapse = true;
}
void PropertyEditor::buildUp(PropertyModel::PropertyList&& props, bool _checkDocument)
{
checkDocument = _checkDocument;
@@ -724,7 +729,10 @@ void PropertyEditor::buildUp(PropertyModel::PropertyList&& props, bool _checkDoc
expandAll();
break;
case ExpansionMode::AutoCollapse:
collapseAll();
if (!blockCollapse) {
collapseAll();
}
blockCollapse = false;
break;
}
}
@@ -735,6 +743,7 @@ void PropertyEditor::updateProperty(const App::Property& prop)
if (!committing) {
propertyModel->updateProperty(prop);
}
blockCollapseAll();
}
void PropertyEditor::setEditorMode(const QModelIndex& parent, int start, int end)
@@ -751,10 +760,9 @@ void PropertyEditor::setEditorMode(const QModelIndex& parent, int start, int end
void PropertyEditor::removeProperty(const App::Property& prop)
{
for (PropertyModel::PropertyList::iterator it = propList.begin(); it != propList.end(); ++it) {
for (auto it = propList.begin(); it != propList.end(); ++it) {
// find the given property in the list and remove it if it's there
std::vector<App::Property*>::iterator pos =
std::ranges::find(it->second, &prop);
auto pos = std::ranges::find(it->second, &prop);
if (pos != it->second.end()) {
it->second.erase(pos);
// if the last property of this name is removed then also remove the whole group
@@ -765,6 +773,7 @@ void PropertyEditor::removeProperty(const App::Property& prop)
break;
}
}
blockCollapseAll();
}
void PropertyEditor::renameProperty(const App::Property& prop)
@@ -777,6 +786,7 @@ void PropertyEditor::renameProperty(const App::Property& prop)
break;
}
}
blockCollapseAll();
}
enum MenuAction

View File

@@ -83,6 +83,7 @@ public:
/** Builds up the list view with the properties. */
void buildUp(PropertyModel::PropertyList&& props = PropertyModel::PropertyList(),
bool checkDocument = false);
void blockCollapseAll();
void updateProperty(const App::Property&);
void removeProperty(const App::Property&);
void renameProperty(const App::Property&);
@@ -161,6 +162,7 @@ private:
bool autoupdate;
bool committing;
bool delaybuild;
bool blockCollapse;
bool binding;
bool checkDocument;
bool closingEditor;