property-dialog: hide a section if it's empty

This commit is contained in:
Gary Wang 2020-12-23 22:19:30 +08:00
parent 44d04e98e5
commit b50b69e9b8

View File

@ -20,9 +20,13 @@ protected:
{ {
QTreeView::rowsInserted(parent, start, end); QTreeView::rowsInserted(parent, start, end);
if (!parent.isValid()) { if (!parent.isValid()) {
// we are inserting a section group
for (int row = start; row <= end; ++row) { for (int row = start; row <= end; ++row) {
setupSection(row); setupSection(row);
} }
} else {
// we are inserting a property
setRowHidden(parent.row(), QModelIndex(), false);
} }
} }
@ -41,6 +45,7 @@ private:
{ {
expand(model()->index(row, 0)); expand(model()->index(row, 0));
setFirstColumnSpanned(row, QModelIndex(), true); setFirstColumnSpanned(row, QModelIndex(), true);
setRowHidden(row, QModelIndex(), !model()->hasChildren(model()->index(row, 0)));
} }
}; };