From d1366257f081fc28939bd6abe9b67b1dba3fb07a Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 25 May 2014 07:28:22 -0700 Subject: [PATCH] Dive list: make saving / restoring column widths actually work It's a testament to how much I mess around with things that I hadn't noticed that saving the column width doesn't actually work. Or actually, saving them worked, loading them back failed as it was done too early and the setColumnWidth() calls had no effect - and so the next time we quit subsurface, the default width of 100 was written over all the saved values. This seems like an incredible hack but it has the advantage of actually working. I look forward to someone with better insides into the inner workings of Qt to properly fix this. Signed-off-by: Dirk Hohndel --- qt-ui/divelistview.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 29157737f..cbb75c102 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -59,7 +59,8 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec searchBox.hide(); connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit())); connect(&searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString))); - setupUi(); + // calling setupUi() here appears to be too early; it does NOT correctly set the column widths + // setupUi(); } DiveListView::~DiveListView() @@ -315,6 +316,13 @@ void DiveListView::headerClicked(int i) void DiveListView::reload(DiveTripModel::Layout layout, bool forceSort) { + // we want to run setupUi() once we actually are displaying something + // in the widget + static bool first = true; + if (first && dive_table.nr > 0) { + setupUi(); + first = false; + } if (layout == DiveTripModel::CURRENT) layout = currentLayout; else