Desktop: Add notes column to dive list table.

Add a column for dive notes to the dive list table.
The column is disabled by default.
As requested in
https://groups.google.com/g/subsurface-divelog/c/PEFre85Ek1M.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2023-03-16 13:29:43 +13:00 committed by Robert C. Helling
parent d44787a0b3
commit 5b263a8f4e
4 changed files with 27 additions and 13 deletions

View file

@ -1,3 +1,4 @@
desktop: add column for dive notes to the dive list table
desktop: fix bug when printing a dive plan with multiple segments desktop: fix bug when printing a dive plan with multiple segments
desktop: fix bug in bailout gas selection for CCR dives desktop: fix bug in bailout gas selection for CCR dives
desktop: fix crash on cylinder update of multiple dives desktop: fix crash on cylinder update of multiple dives

View file

@ -69,15 +69,16 @@ DiveListView::DiveListView(QWidget *parent) : QTreeView(parent),
QString title = QString("%1").arg(model()->headerData(i, Qt::Horizontal).toString()); QString title = QString("%1").arg(model()->headerData(i, Qt::Horizontal).toString());
QString settingName = QString("showColumn%1").arg(i); QString settingName = QString("showColumn%1").arg(i);
QAction *a = new QAction(title, header()); QAction *a = new QAction(title, header());
bool showHeaderFirstRun = !(i == DiveTripModelBase::MAXCNS || bool showHeaderFirstRun = i == DiveTripModelBase::NR ||
i == DiveTripModelBase::GAS || i == DiveTripModelBase::DATE ||
i == DiveTripModelBase::OTU || i == DiveTripModelBase::RATING ||
i == DiveTripModelBase::TEMPERATURE || i == DiveTripModelBase::DEPTH ||
i == DiveTripModelBase::TOTALWEIGHT || i == DiveTripModelBase::DURATION ||
i == DiveTripModelBase::SUIT || i == DiveTripModelBase::PHOTOS ||
i == DiveTripModelBase::CYLINDER || i == DiveTripModelBase::BUDDIES ||
i == DiveTripModelBase::SAC || i == DiveTripModelBase::DIVEGUIDE ||
i == DiveTripModelBase::TAGS); i == DiveTripModelBase::COUNTRY ||
i == DiveTripModelBase::LOCATION;
bool shown = s.value(settingName, showHeaderFirstRun).toBool(); bool shown = s.value(settingName, showHeaderFirstRun).toBool();
a->setCheckable(true); a->setCheckable(true);
a->setChecked(shown); a->setChecked(shown);

View file

@ -57,6 +57,7 @@ static QVariant dive_table_alignment(int column)
case DiveTripModelBase::BUDDIES: case DiveTripModelBase::BUDDIES:
case DiveTripModelBase::DIVEGUIDE: case DiveTripModelBase::DIVEGUIDE:
case DiveTripModelBase::LOCATION: case DiveTripModelBase::LOCATION:
case DiveTripModelBase::NOTES:
return int(Qt::AlignLeft | Qt::AlignVCenter); return int(Qt::AlignLeft | Qt::AlignVCenter);
} }
return QVariant(); return QVariant();
@ -256,6 +257,8 @@ QString DiveTripModelBase::getDescription(int column)
return tr("Dive guide"); return tr("Dive guide");
case LOCATION: case LOCATION:
return tr("Location"); return tr("Location");
case NOTES:
return tr("Notes");
default: default:
return QString(); return QString();
} }
@ -352,10 +355,14 @@ QVariant DiveTripModelBase::diveData(const struct dive *d, int column, int role)
case LOCATION: case LOCATION:
return QString(get_dive_location(d)); return QString(get_dive_location(d));
case GAS: case GAS:
char *gas_string = get_dive_gas_string(d); {
QString ret(gas_string); char *gas_string = get_dive_gas_string(d);
free(gas_string); QString ret(gas_string);
return ret; free(gas_string);
return ret;
}
case NOTES:
return QString(d->notes);
} }
break; break;
case Qt::DecorationRole: case Qt::DecorationRole:
@ -444,6 +451,8 @@ QVariant DiveTripModelBase::headerData(int section, Qt::Orientation orientation,
return tr("Dive guide"); return tr("Dive guide");
case LOCATION: case LOCATION:
return tr("Location"); return tr("Location");
case NOTES:
return tr("Notes");
} }
break; break;
case Qt::ToolTipRole: case Qt::ToolTipRole:
@ -1745,5 +1754,7 @@ bool DiveTripModelList::lessThan(const QModelIndex &i1, const QModelIndex &i2) c
return lessThanHelper(strCmp(d1->diveguide, d2->diveguide), row_diff); return lessThanHelper(strCmp(d1->diveguide, d2->diveguide), row_diff);
case LOCATION: case LOCATION:
return lessThanHelper(strCmp(get_dive_location(d1), get_dive_location(d2)), row_diff); return lessThanHelper(strCmp(get_dive_location(d1), get_dive_location(d2)), row_diff);
case NOTES:
return lessThanHelper(strCmp(d1->notes, d2->notes), row_diff);
} }
} }

View file

@ -43,6 +43,7 @@ public:
DIVEGUIDE, DIVEGUIDE,
COUNTRY, COUNTRY,
LOCATION, LOCATION,
NOTES,
COLUMNS COLUMNS
}; };