Fix table header issues in a more portable way

This undoes 9e2f8e5ede and try to solve the
issues present in Linux with Qt 5.9 and the one in Windows with the Dark
Style at the same time.

I think both issues come from using the filter box height as y offset. The
real offset has to be the original table header height. In Windows+Dark the
box is apparently shorter, so after moving, part of the header is clipped.
In Linux+Qt5.9, the original header height is shorter than the filter box,
so moving by the filter box height clips the filter box at the bottom.

The new height increment for the table header is also reduced to 4, so the
margin is 2 in both the bottom and the top of the filter boxes.
See issue #1493
This commit is contained in:
mgrojo
2019-03-03 20:29:59 +01:00
parent 4b5b5c6238
commit baaeea8844

View File

@@ -50,7 +50,7 @@ QSize FilterTableHeader::sizeHint() const
// For the size hint just take the value of the standard implementation and add the height of a input widget to it if necessary
QSize s = QHeaderView::sizeHint();
if(filterWidgets.size())
s.setHeight(s.height() + filterWidgets.at(0)->sizeHint().height() + 5); // The 5 adds just adds some extra space
s.setHeight(s.height() + filterWidgets.at(0)->sizeHint().height() + 4); // The 4 adds just adds some extra space
return s;
}
@@ -74,15 +74,14 @@ void FilterTableHeader::adjustPositions()
{
// Get the current widget, move it and resize it
QWidget* w = filterWidgets.at(i);
// The two adds some extra space between the header label and the input widget
int y = QHeaderView::sizeHint().height() + 2;
if (QApplication::layoutDirection() == Qt::RightToLeft)
w->move(width() - (sectionPosition(i) + sectionSize(i) - offset()), w->sizeHint().height() + 2); // The two adds some extra space between the header label and the input widget
w->move(width() - (sectionPosition(i) + sectionSize(i) - offset()), y);
else
w->move(sectionPosition(i) - offset(), w->sizeHint().height() + 2); // The two adds some extra space between the header label and the input widget
w->move(sectionPosition(i) - offset(), y);
w->resize(sectionSize(i), w->sizeHint().height());
}
// And finally add that extra space to the header so the filter box is not clipped.
if(filterWidgets.size() > 0)
setMinimumSize(sizeHint().width(), sizeHint().height() + 2);
}
void FilterTableHeader::inputChanged(const QString& new_value)