aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-19 00:33:07 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-19 00:33:07 +0100
commit49c367d1d46cbe65de367ccb763f072399c6c05b (patch)
treefc9c11f5ccce87710f38ccbbe811040a685be765
parentb84f6222261998d1a34f6fd184f4859aaa67d0d1 (diff)
downloadqtmips-49c367d1d46cbe65de367ccb763f072399c6c05b.tar.gz
qtmips-49c367d1d46cbe65de367ccb763f072399c6c05b.tar.bz2
qtmips-49c367d1d46cbe65de367ccb763f072399c6c05b.zip
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 <pisa@cmp.felk.cvut.cz>
-rw-r--r--qtmips_gui/registersdock.cpp1
-rw-r--r--qtmips_gui/statictable.cpp9
2 files changed, 6 insertions, 4 deletions
diff --git a/qtmips_gui/registersdock.cpp b/qtmips_gui/registersdock.cpp
index b75aa44..2823abc 100644
--- a/qtmips_gui/registersdock.cpp
+++ b/qtmips_gui/registersdock.cpp
@@ -114,6 +114,7 @@ void RegistersDock::setup(machine::QtMipsMachine *machine) {
lo->setText("");
for (int i = 0; i < 32; i++)
gp[i]->setText("");
+ return;
}
const machine::Registers *regs = machine->registers();
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<QLayoutItem*> StaticTableLayout::list2vec(QList<QWidget*> w) {