From 75650bd65f928cfc5de1453491fc03d6f7717d24 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 26 Aug 2014 17:23:41 -0700 Subject: DiveList: don't save default column width This is an elegant way around our problem with people who have the horrible old "100px" column width in their settings. The first time they run Subsurface after this fix things won't get better, but the offending keys will be deleted at exit. And the second time they run, they'll get the much more sensible new default widths. Thanks to Thiago for this idea. Signed-off-by: Dirk Hohndel --- qt-ui/divelistview.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 3c71699a1..9641d4210 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -61,19 +61,27 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelec connect(&searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString))); } +// # Date Rtg Dpth Dur Tmp Wght Suit Cyl Gas SAC OTU CNS Loc +static int defaultWidth[] = { 70, 140, 90, 50, 50, 50, 50, 70, 50, 50, 70, 50, 50, 500}; + DiveListView::~DiveListView() { QSettings settings; settings.beginGroup("ListWidget"); - for (int i = DiveTripModel::NR; i < DiveTripModel::COLUMNS; i++) { + // don't set a width for the last column - location is supposed to be "the rest" + for (int i = DiveTripModel::NR; i < DiveTripModel::COLUMNS - 1; i++) { if (isColumnHidden(i)) continue; - settings.setValue(QString("colwidth%1").arg(i), columnWidth(i)); + // we used to hardcode them all to 100 - so that might still be in the settings + if (columnWidth(i) == 100 || columnWidth(i) == defaultWidth[i]) + settings.remove(QString("colwidth%1").arg(i)); + else + settings.setValue(QString("colwidth%1").arg(i), columnWidth(i)); } + settings.remove(QString("colwidth%1").arg(DiveTripModel::COLUMNS - 1)); settings.endGroup(); } -static int defaultWidth[] = { 70, 130, 100, 50, 50, 50, 50, 70, 50, 50, 70, 50, 50, 500 }; void DiveListView::setupUi() { QSettings settings; -- cgit v1.2.3-70-g09d2