summaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-26 17:23:41 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-26 14:17:15 -0700
commit75650bd65f928cfc5de1453491fc03d6f7717d24 (patch)
tree7b5c503034b71848487772b557883def221042f6 /qt-ui/divelistview.cpp
parentbded7d3ae072a25f31a5563f76f46324d743f200 (diff)
downloadsubsurface-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.cpp14
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;