diff --git a/pglab/crud/RecordPanel.cpp b/pglab/crud/RecordPanel.cpp index 8183771..771bb0e 100644 --- a/pglab/crud/RecordPanel.cpp +++ b/pglab/crud/RecordPanel.cpp @@ -132,7 +132,10 @@ void RecordPanel::rebuild() clearFields(); 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); int row = m_rowIndex.row(); @@ -142,7 +145,7 @@ void RecordPanel::rebuild() QString name = newline < 0 ? header : header.left(newline); QString typeName = newline < 0 ? QString() : header.mid(newline + 1); - auto caption = new QWidget(content); + auto caption = new QWidget(form); auto captionLayout = new QVBoxLayout(caption); captionLayout->setContentsMargins(0, 0, 0, 0); auto nameLabel = new QLabel(name, caption); @@ -159,7 +162,7 @@ void RecordPanel::rebuild() QWidget *fieldWidget = nullptr; if (isLongTextType(oid)) { - auto container = new QWidget(content); + auto container = new QWidget(form); auto containerLayout = new QVBoxLayout(container); containerLayout->setContentsMargins(0, 0, 0, 0); @@ -189,7 +192,7 @@ void RecordPanel::rebuild() fieldWidget = container; } else { - auto edit = new QLineEdit(content); + auto edit = new QLineEdit(form); edit->setPlaceholderText(tr("null")); connect(edit, &QLineEdit::editingFinished, this, [this, edit]() { commitEditor(edit); }); @@ -201,6 +204,9 @@ void RecordPanel::rebuild() m_fields.push_back(field); } + outer->addWidget(form); + outer->addStretch(1); + setWidget(content); } diff --git a/releasenotes/notes/record-panel-compact-layout-8a5f1c3d7e2b6049.yaml b/releasenotes/notes/record-panel-compact-layout-8a5f1c3d7e2b6049.yaml new file mode 100644 index 0000000..8feb4a6 --- /dev/null +++ b/releasenotes/notes/record-panel-compact-layout-8a5f1c3d7e2b6049.yaml @@ -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.