diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-08-26 17:23:41 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-08-26 14:17:15 -0700 |
commit | 75650bd65f928cfc5de1453491fc03d6f7717d24 (patch) | |
tree | 7b5c503034b71848487772b557883def221042f6 /qt-ui/divelistview.cpp | |
parent | bded7d3ae072a25f31a5563f76f46324d743f200 (diff) | |
download | subsurface-75650bd65f928cfc5de1453491fc03d6f7717d24.tar.gz |
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
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; |