Skip to content

Commit

Permalink
#1748 Fix ltable last row sizing.
Browse files Browse the repository at this point in the history
Signed-off-by: cneben <[email protected]>
  • Loading branch information
cneben committed Aug 28, 2024
1 parent 46943de commit 31fe8e9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/RectGradientBackground.qml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Item {
//! User component hook to set a header background (component has to specify it's height).
property Component headerBackground: null

property real headerHeight: 35

// PRIVATE ////////////////////////////////////////////////////////////////
// Note: Top level item is used to isolate rendering of:
// - background with a gradient effect
Expand Down Expand Up @@ -78,6 +80,7 @@ Item {
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: headerHeight
sourceComponent: headerBackground
}
Rectangle {
Expand Down
3 changes: 3 additions & 0 deletions src/RectGroupTemplate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Item {
anchors.fill: parent
style: template.groupItem?.style
visible: !groupItem.collapsed
headerHeight: Math.max(35, groupLabel.implicitHeight)
}
ColumnLayout {
anchors.fill: parent
Expand All @@ -84,6 +85,7 @@ Item {
id: headerLayout
Layout.fillWidth: true
Layout.fillHeight: false
Layout.preferredHeight: Math.max(35, groupLabel.implicitHeight)
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
z: 2
spacing: 0
Expand Down Expand Up @@ -122,6 +124,7 @@ Item {
groupItem.group ? groupItem.group.label :
" "
visible: !labelEditor.visible
onImplicitHeightChanged: console.error('implicitHeight=' + implicitHeight)
verticalAlignment: Text.AlignVCenter
font.bold: groupItem.style.fontBold
font.pointSize: labelEditorControl.labelPointSize
Expand Down
22 changes: 12 additions & 10 deletions src/qanTableBorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,19 @@ void TableBorder::onVerticalMove() { layoutCells(); }

void TableBorder::layoutCells()
{
const auto tableGroupItem = _tableGroup ? qobject_cast<const qan::TableGroupItem*>(_tableGroup->getGroupItem()) :
nullptr;
if (_tableGroup == nullptr)
return;
const auto tableGroupItem = qobject_cast<const qan::TableGroupItem*>(_tableGroup->getGroupItem());
if (tableGroupItem == nullptr ||
tableGroupItem->getContainer() == nullptr)
return;
const auto padding = _tableGroup ? _tableGroup->getTablePadding() :
2.;
const auto spacing = _tableGroup ? _tableGroup->getCellSpacing() :
5.;
const auto spacing2 = spacing / 2.;
const auto tableWidth = tableGroupItem->getContainer()->width();
const auto tableHeight = tableGroupItem->getContainer()->height();

if (getOrientation() == Qt::Vertical) {
const auto vCenter = verticalCenter();
Expand All @@ -165,10 +171,8 @@ void TableBorder::layoutCells()
_nextBorder->verticalCenter() > (x() + spacing)) // nextBorder might still not be initialized...
nextCell->setWidth(_nextBorder->verticalCenter() - x() - spacing);

if (!_nextBorder && // For last column, set cell witdh too (no next border will do it).
_tableGroup && tableGroupItem != nullptr) {
nextCell->setWidth(tableGroupItem->width() - vCenter - padding - spacing2);
}
if (!_nextBorder) // For last column, set cell witdh too (no next border will do it).
nextCell->setWidth(tableWidth - vCenter - padding - spacing2);
}
} // Vertical orientation
else if (getOrientation() == Qt::Horizontal) {
Expand All @@ -193,10 +197,8 @@ void TableBorder::layoutCells()
_nextBorder->horizontalCenter() > (y() + spacing)) // nextBorder might still not be initialized...
nextCell->setHeight(_nextBorder->horizontalCenter() - y() - spacing);

if (!_nextBorder && // For last column, set cell witdh too (no next border will do it).
_tableGroup && tableGroupItem != nullptr) {
nextCell->setHeight(tableGroupItem->height() - hCenter - padding - spacing2);
}
if (!_nextBorder) // For last column, set cell witdh too (no next border will do it).
nextCell->setHeight(tableHeight - hCenter - padding - spacing2);
}
} // Horizontal orientation
}
Expand Down

0 comments on commit 31fe8e9

Please sign in to comment.