From 49c367d1d46cbe65de367ccb763f072399c6c05b Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Tue, 19 Feb 2019 00:33:07 +0100 Subject: The sizeHint seems to not be affected by invisible zero size problem. Enable number of columns computation even for invisible QLabels to restore wide registers dock with multiple columns instead of only one. Signed-off-by: Pavel Pisa --- qtmips_gui/statictable.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'qtmips_gui/statictable.cpp') diff --git a/qtmips_gui/statictable.cpp b/qtmips_gui/statictable.cpp index 14fbc81..54b475f 100644 --- a/qtmips_gui/statictable.cpp +++ b/qtmips_gui/statictable.cpp @@ -186,17 +186,18 @@ int StaticTableLayout::layout_count_approx(const QRect &rect) const { if (items.size() <= 0 || rect.width() < rect.height()) return 1; // Note: for some reason (probably optimalisation) when qlabel is not visible it reports 0 size. So we have to found at least one that is visible + // !items[vis][0]->widget()->isVisible() int vis = 0; - while (items[vis].size() <= 0 || !items[vis][0]->widget()->isVisible()) { + while (items[vis].size() <= 0 || items[vis][0]->widget()->sizeHint().width() == 0) { vis++; if (vis >= items.size()) - return 1; // If non is visible then just say that it has to be single column + return 1; // If none is visible then just say that it has to be single column } int w = 0; for (int i = 0; i < items[vis].size(); i++) w += items[vis][i]->sizeHint().width() + shspace; - w -= shspace; // subtract lastest spacing + w -= shspace; // subtract latest spacing int width = rect.right() / w; // Note: this always rounds down so this always founds maximal possible count return width <= 0 ? 1 : width; // We have to fit at least one column } @@ -282,7 +283,7 @@ int StaticTableLayout::layout_height(int width) const { int count; layout_parms(reff, row_h, row_w, count); - return (row_h + vspace) * (items.size() / count); + return (row_h + vspace) * ((items.size() + count - 1) / count); } QVector StaticTableLayout::list2vec(QList w) { -- cgit v1.2.3