mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
bded7d3ae0
commit
75650bd65f
1 changed files with 11 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue