Fix layout of RecordPanel

This commit is contained in:
Eelke Klein 2026-10-27 09:01:08 +01:00
parent 0dcee5f76c
commit 9dcca99e4c
No known key found for this signature in database
2 changed files with 15 additions and 4 deletions

View file

@ -132,7 +132,10 @@ void RecordPanel::rebuild()
clearFields(); clearFields();
auto content = new QWidget; auto content = new QWidget;
auto layout = new QFormLayout(content); auto outer = new QVBoxLayout(content);
outer->setContentsMargins(0, 0, 0, 0);
auto form = new QWidget(content);
auto layout = new QFormLayout(form);
layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
int row = m_rowIndex.row(); int row = m_rowIndex.row();
@ -142,7 +145,7 @@ void RecordPanel::rebuild()
QString name = newline < 0 ? header : header.left(newline); QString name = newline < 0 ? header : header.left(newline);
QString typeName = newline < 0 ? QString() : header.mid(newline + 1); QString typeName = newline < 0 ? QString() : header.mid(newline + 1);
auto caption = new QWidget(content); auto caption = new QWidget(form);
auto captionLayout = new QVBoxLayout(caption); auto captionLayout = new QVBoxLayout(caption);
captionLayout->setContentsMargins(0, 0, 0, 0); captionLayout->setContentsMargins(0, 0, 0, 0);
auto nameLabel = new QLabel(name, caption); auto nameLabel = new QLabel(name, caption);
@ -159,7 +162,7 @@ void RecordPanel::rebuild()
QWidget *fieldWidget = nullptr; QWidget *fieldWidget = nullptr;
if (isLongTextType(oid)) { if (isLongTextType(oid)) {
auto container = new QWidget(content); auto container = new QWidget(form);
auto containerLayout = new QVBoxLayout(container); auto containerLayout = new QVBoxLayout(container);
containerLayout->setContentsMargins(0, 0, 0, 0); containerLayout->setContentsMargins(0, 0, 0, 0);
@ -189,7 +192,7 @@ void RecordPanel::rebuild()
fieldWidget = container; fieldWidget = container;
} }
else { else {
auto edit = new QLineEdit(content); auto edit = new QLineEdit(form);
edit->setPlaceholderText(tr("null")); edit->setPlaceholderText(tr("null"));
connect(edit, &QLineEdit::editingFinished, this, [this, edit]() { commitEditor(edit); }); connect(edit, &QLineEdit::editingFinished, this, [this, edit]() { commitEditor(edit); });
@ -201,6 +204,9 @@ void RecordPanel::rebuild()
m_fields.push_back(field); m_fields.push_back(field);
} }
outer->addWidget(form);
outer->addStretch(1);
setWidget(content); setWidget(content);
} }

View file

@ -0,0 +1,5 @@
---
fixes:
- |
Keep record panel fields compact at the top instead of spreading them
over the available height when a record has few fields.