Dive list view: move column width logic back from DiveTripModel

Conceptually, the width of the columns should probably reside in
the view not the model. But much more severly, the old code didn't
work: Columns were set in a DiveTripModel, which was deleted
right away.

Therefore, move the logic back to the DiveListView. Introduce
a QVector<int> of the initial column widths, so that they can be
erased from the setting if unchanged.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-07-25 20:40:47 +02:00 committed by Dirk Hohndel
parent d3dc698bba
commit 079b99135a
4 changed files with 53 additions and 92 deletions

View file

@ -71,12 +71,14 @@ private:
QModelIndex contextMenuIndex;
bool dontEmitDiveChangedSignal;
bool selectionSaved;
DiveTripModel *tripModel;
// Remember the initial column widths, to avoid writing unchanged widths to the settings
QVector<int> initialColumnWidths;
/* if dive_trip_t is null, there's no problem. */
QMultiHash<dive_trip_t *, int> selectedDives;
void merge_trip(const QModelIndex &a, const int offset);
void setupUi();
void calculateInitialColumnWidth(const DiveTripModel &tripModel, int col);
void backupExpandedRows();
void restoreExpandedRows();
int lastVisibleColumn();